function TwigMarkupInterfaceTest::providerTestMarkupInterfaceEmpty

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php \Drupal\KernelTests\Core\Theme\TwigMarkupInterfaceTest::providerTestMarkupInterfaceEmpty()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php \Drupal\KernelTests\Core\Theme\TwigMarkupInterfaceTest::providerTestMarkupInterfaceEmpty()
  3. 11.x core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php \Drupal\KernelTests\Core\Theme\TwigMarkupInterfaceTest::providerTestMarkupInterfaceEmpty()

Provide test examples.

File

core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php, line 41

Class

TwigMarkupInterfaceTest
Tests Twig with MarkupInterface objects.

Namespace

Drupal\KernelTests\Core\Theme

Code

public static function providerTestMarkupInterfaceEmpty() {
    return [
        // The first argument to \Drupal\Core\StringTranslation\TranslatableMarkup
        // is not supposed to be an empty string.
        // phpcs:ignore Drupal.Semantics.FunctionT.EmptyString
'empty TranslatableMarkup' => [
            '',
            new TranslatableMarkup(''),
        ],
        'non-empty TranslatableMarkup' => [
            '<span>test</span>',
            new TranslatableMarkup('test'),
        ],
        'empty FormattableMarkup' => [
            '',
            new FormattableMarkup('', [
                '@foo' => 'bar',
            ]),
        ],
        'non-empty FormattableMarkup' => [
            '<span>bar</span>',
            new FormattableMarkup('@foo', [
                '@foo' => 'bar',
            ]),
        ],
        'non-empty Markup' => [
            '<span>test</span>',
            Markup::create('test'),
        ],
        'empty GeneratedLink' => [
            '',
            new GeneratedLink(),
        ],
        'non-empty GeneratedLink' => [
            '<span><a hef="http://www.example.com">test</a></span>',
            (new GeneratedLink())->setGeneratedLink('<a hef="http://www.example.com">test</a>'),
        ],
        // Test objects that do not implement \Countable.
'empty SafeMarkupTestMarkup' => [
            '',
            SafeMarkupTestMarkup::create(''),
        ],
        'non-empty SafeMarkupTestMarkup' => [
            '<span>test</span>',
            SafeMarkupTestMarkup::create('test'),
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.