XmlTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
  9. * - (c) John MacFarlane
  10. *
  11. * For the full copyright and license information, please view the LICENSE
  12. * file that was distributed with this source code.
  13. */
  14. namespace League\CommonMark\Tests\Unit\Util;
  15. use League\CommonMark\Util\Xml;
  16. use PHPUnit\Framework\TestCase;
  17. final class XmlTest extends TestCase
  18. {
  19. /**
  20. * @dataProvider dataProviderForTestEscape
  21. */
  22. public function testEscape(string $input, string $expectedOutput): void
  23. {
  24. $this->assertEquals($expectedOutput, Xml::escape($input));
  25. }
  26. /**
  27. * @return iterable<string[]>
  28. */
  29. public function dataProviderForTestEscape(): iterable
  30. {
  31. yield ['foo', 'foo'];
  32. yield ['&copy;', '&amp;copy;'];
  33. yield ['<script>', '&lt;script&gt;'];
  34. yield ['&#x0000;', '&amp;#x0000;'];
  35. }
  36. }