TextNormalizerTest.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the league/commonmark package.
  5. *
  6. * (c) Colin O'Dell <colinodell@gmail.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace League\CommonMark\Tests\Unit\Normalizer;
  12. use League\CommonMark\Normalizer\TextNormalizer;
  13. use PHPUnit\Framework\TestCase;
  14. final class TextNormalizerTest extends TestCase
  15. {
  16. /**
  17. * @dataProvider dataProviderForTestNormalize
  18. */
  19. public function testNormalize(string $input, string $expectedOutput): void
  20. {
  21. $this->assertEquals($expectedOutput, (new TextNormalizer())->normalize($input));
  22. }
  23. /**
  24. * @return iterable<string[]>
  25. */
  26. public function dataProviderForTestNormalize(): iterable
  27. {
  28. yield ['', ''];
  29. yield ['hello world', 'hello world'];
  30. yield ['hello-world', 'hello-world'];
  31. yield ['hello world', 'hello world'];
  32. yield ['Hello World!', 'hello world!'];
  33. yield ['456*(&^3484389462342#$#$#$#$', '456*(&^3484389462342#$#$#$#$'];
  34. yield ['me&you', 'me&you'];
  35. yield ['special char ὐ here', 'special char ὐ here'];
  36. yield ['ПРИСТАНЯМ СТРЕМЯТСЯ', 'пристаням стремятся'];
  37. yield ['пристаням стремятся', 'пристаням стремятся'];
  38. yield ['emoji 😂 example', 'emoji 😂 example'];
  39. yield ['One ½ half', 'one ½ half'];
  40. yield ['Roman ↁ example', 'roman ↁ example'];
  41. yield ['Here\'s a DŽ digraph', 'here\'s a dž digraph'];
  42. yield ['Here\'s another dž digraph', 'here\'s another dž digraph'];
  43. yield ['Unicode x² superscript', 'unicode x² superscript'];
  44. yield ['Equal = sign', 'equal = sign'];
  45. yield ['Tabs in here', 'tabs in here'];
  46. yield ['Tabs- -in- -here-too', 'tabs- -in- -here-too'];
  47. yield ['We-love---dashes even with -lots- of spaces', 'we-love---dashes even with -lots- of spaces'];
  48. yield ['LOUD NOISES', 'loud noises'];
  49. yield ['ťęŝŧ', 'ťęŝŧ'];
  50. yield ['ŤĘŜŦ', 'ťęŝŧ'];
  51. yield ["\nWho\nput\n\n newlines \nin here?!\n", 'who put newlines in here?!'];
  52. yield ['අත්හදා බලන මාතෘකාව', 'අත්හදා බලන මාතෘකාව'];
  53. yield ['අත්හදා බලන මාතෘකාව -', 'අත්හදා බලන මාතෘකාව -'];
  54. yield ['අත්හදා බලන මාතෘකාව - ', 'අත්හදා බලන මාතෘකාව -'];
  55. yield ['අත්හදා බලන මාතෘකාව - අ', 'අත්හදා බලන මාතෘකාව - අ'];
  56. yield ['测试标题', '测试标题'];
  57. yield ['测试 # 标题', '测试 # 标题'];
  58. yield ['测试 x² 标题', '测试 x² 标题'];
  59. yield ['試験タイトル', '試験タイトル'];
  60. }
  61. }