File: UTF8UtilsTest.php

package info (click to toggle)
php-masterminds-html5 2.7.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 736 kB
  • sloc: php: 9,565; makefile: 19
file content (28 lines) | stat: -rw-r--r-- 730 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

namespace Masterminds\HTML5\Tests\Parser;

use Masterminds\HTML5\Parser\UTF8Utils;

class UTF8UtilsTest extends \Masterminds\HTML5\Tests\TestCase
{
    public function testConvertToUTF8()
    {
        $out = UTF8Utils::convertToUTF8('éàa', 'ISO-8859-1');
        $this->assertEquals('éàa', $out);
    }

    /**
     * @todo add tests for invalid codepoints
     */
    public function testCheckForIllegalCodepoints()
    {
        $smoke = 'Smoke test';
        $err = UTF8Utils::checkForIllegalCodepoints($smoke);
        $this->assertEmpty($err);

        $data = "Foo Bar \0 Baz";
        $errors = UTF8Utils::checkForIllegalCodepoints($data);
        $this->assertContains('null-character', $errors);
    }
}