You are here

public function AlinkPostRendererTest::replaceProvider in Alinks 8

File

tests/src/Kernel/AlinkPostRendererTest.php, line 46

Class

AlinkPostRendererTest
Class AlinkPostRendererTest.

Namespace

Drupal\Tests\alinks\Kernel

Code

public function replaceProvider() {
  $data = [];
  $data[] = [
    '<p>Foobar</p>',
    '<p><a href="/example">Foobar</a></p>',
  ];
  $data[] = [
    '<p>Foo bar</p>',
    '<p>Foo bar</p>',
  ];
  $data[] = [
    '<p>Foobar Foobar</p>',
    '<p><a href="/example">Foobar</a> Foobar</p>',
  ];
  $data[] = [
    '<p>FoobarFoobar</p>',
    '<p>FoobarFoobar</p>',
  ];
  $data[] = [
    '<p>This is Foobar.</p>',
    '<p>This is <a href="/example">Foobar</a>.</p>',
  ];
  $data[] = [
    '<p>This is Foobar, a test with punctuation.</p>',
    '<p>This is <a href="/example">Foobar</a>, a test with punctuation.</p>',
  ];
  $data[] = [
    '<p>Foobar?</p>',
    '<p><a href="/example">Foobar</a>?</p>',
  ];
  $data[] = [
    '<p>Foobar!</p>',
    '<p><a href="/example">Foobar</a>!</p>',
  ];
  $data[] = [
    '<p><a href="/example">Foobar</a> Foobar</p>',
    '<p><a href="/example">Foobar</a> Foobar</p>',
  ];
  $data[] = [
    '<blockquote><p>Foobar</p></blockquote>',
    '<blockquote><p><a href="/example">Foobar</a></p></blockquote>',
  ];

  // Test Stemming.
  // @see http://snowball.tartarus.org/algorithms/german/stemmer.html
  $data[] = [
    '<p>Ich habe eine Katze.</p>',
    '<p>Ich habe eine <a href="/cat">Katze</a>.</p>',
  ];
  $data[] = [
    '<p>Hunde und Katzen sind beliebte Haustiere.</p>',
    '<p>Hunde und <a href="/cat">Katzen</a> sind beliebte Haustiere.</p>',
  ];

  /*
      $data[] = [
      '<p>Kätzchen die Verkleinerungsform für Katze.</p>',
      '<p><a href="/cat">Kätzchen</a> ist die Verkleinerungsform für Katze.</p>',
      ];
  */
  $data[] = [
    '<p>Weidenkätzchen</p>',
    '<p>Weidenkätzchen</p>',
  ];
  $original = '<p>ABC <script>Foobar</script></p>';
  $replacement = <<<EOT
<p>ABC <script>
<!--//--><![CDATA[// ><!--
Foobar
//--><!]]>
</script></p>
EOT;
  $data[] = [
    $original,
    $replacement,
  ];
  $data[] = [
    '<p>ABC <span data-alink-ignore>Foobar</span></p>',
    '<p>ABC <span data-alink-ignore="">Foobar</span></p>',
  ];
  $data[] = [
    '<p data-alink-ignore>ABC Foobar</p>',
    '<p data-alink-ignore="">ABC Foobar</p>',
  ];
  return $data;
}