UTF8UtilsTest.php 730 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Masterminds\HTML5\Tests\Parser;
  3. use Masterminds\HTML5\Parser\UTF8Utils;
  4. class UTF8UtilsTest extends \Masterminds\HTML5\Tests\TestCase
  5. {
  6. public function testConvertToUTF8()
  7. {
  8. $out = UTF8Utils::convertToUTF8('éàa', 'ISO-8859-1');
  9. $this->assertEquals('éàa', $out);
  10. }
  11. /**
  12. * @todo add tests for invalid codepoints
  13. */
  14. public function testCheckForIllegalCodepoints()
  15. {
  16. $smoke = 'Smoke test';
  17. $err = UTF8Utils::checkForIllegalCodepoints($smoke);
  18. $this->assertEmpty($err);
  19. $data = "Foo Bar \0 Baz";
  20. $errors = UTF8Utils::checkForIllegalCodepoints($data);
  21. $this->assertContains('null-character', $errors);
  22. }
  23. }