You are here

public function PlainTextOutputTest::providerRenderFromHtml in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Render/PlainTextOutputTest.php \Drupal\Tests\Component\Render\PlainTextOutputTest::providerRenderFromHtml()
  2. 9 core/tests/Drupal/Tests/Component/Render/PlainTextOutputTest.php \Drupal\Tests\Component\Render\PlainTextOutputTest::providerRenderFromHtml()

Data provider for ::testRenderFromHtml()

File

core/tests/Drupal/Tests/Component/Render/PlainTextOutputTest.php, line 39

Class

PlainTextOutputTest
@coversDefaultClass \Drupal\Component\Render\PlainTextOutput @group Utility

Namespace

Drupal\Tests\Component\Render

Code

public function providerRenderFromHtml() {
  $data = [];
  $data['simple-text'] = [
    'Giraffes and wombats',
    'Giraffes and wombats',
  ];
  $data['simple-html'] = [
    'Giraffes and wombats',
    '<a href="/muh">Giraffes</a> and <strong>wombats</strong>',
  ];
  $data['html-with-quote'] = [
    'Giraffes and quote"s',
    '<a href="/muh">Giraffes</a> and <strong>quote"s</strong>',
  ];
  $expected = 'The <em> tag makes your text look like "this".';
  $string = 'The &lt;em&gt; tag makes your text look like <em>"this"</em>.';
  $data['escaped-html-with-quotes'] = [
    $expected,
    $string,
  ];
  $safe_string = $this
    ->prophesize(MarkupInterface::class);
  $safe_string
    ->__toString()
    ->willReturn('<em>"this"</em>');
  $safe_string = $safe_string
    ->reveal();
  $data['escaped-html-with-quotes-and-placeholders'] = [
    $expected,
    'The @tag tag makes your text look like @result.',
    [
      '@tag' => '<em>',
      '@result' => $safe_string,
    ],
  ];
  $safe_string = $this
    ->prophesize(MarkupInterface::class);
  $safe_string
    ->__toString()
    ->willReturn($string);
  $safe_string = $safe_string
    ->reveal();
  $data['safe-string'] = [
    $expected,
    $safe_string,
  ];
  return $data;
}