You are here

public function TwigMarkupInterfaceTest::providerTestMarkupInterfaceEmpty in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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 46
Contains \Drupal\KernelTests\Core\Theme\ThemeRenderAndAutoescapeTest.

Class

TwigMarkupInterfaceTest
Tests Twig with MarkupInterface objects.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function providerTestMarkupInterfaceEmpty() {
  return [
    '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' => [
      '<span></span>',
      SafeMarkupTestMarkup::create(''),
    ],
    'non-empty SafeMarkupTestMarkup' => [
      '<span>test</span>',
      SafeMarkupTestMarkup::create('test'),
    ],
  ];
}