diff options
author | Titouan Galopin <[email protected]> | 2018-12-29 16:51:06 +0100 |
---|---|---|
committer | Titouan Galopin <[email protected]> | 2018-12-29 16:53:44 +0100 |
commit | ab776a0cd0f02a579b8aae6acdd6c3fe6e9d33e2 (patch) | |
tree | 5eb981d56a028e891c05476cc9520f7a91e78d13 /test/HTML5/Html5Test.php | |
parent | 8cacb989a3d98dd6177a3be03b8dc4d610b186dd (diff) |
Add encoding tests
Diffstat (limited to 'test/HTML5/Html5Test.php')
-rw-r--r-- | test/HTML5/Html5Test.php | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/test/HTML5/Html5Test.php b/test/HTML5/Html5Test.php index 47bcafd..812d179 100644 --- a/test/HTML5/Html5Test.php +++ b/test/HTML5/Html5Test.php @@ -2,8 +2,15 @@ namespace Masterminds\HTML5\Tests; +use Masterminds\HTML5; + class Html5Test extends TestCase { + /** + * @var HTML5 + */ + private $html5; + public function setUp() { $this->html5 = $this->getInstance(); @@ -50,8 +57,8 @@ class Html5Test extends TestCase { // doc $dom = $this->html5->loadHTML($this->wrap('<t:tag/>'), array( - 'implicitNamespaces' => array('t' => 'http://example.com'), - 'xmlNamespaces' => true, + 'implicitNamespaces' => array('t' => 'http://example.com'), + 'xmlNamespaces' => true, )); $this->assertInstanceOf('\DOMDocument', $dom); $this->assertEmpty($this->html5->getErrors()); @@ -63,8 +70,8 @@ class Html5Test extends TestCase // doc fragment $frag = $this->html5->loadHTMLFragment('<t:tag/>', array( - 'implicitNamespaces' => array('t' => 'http://example.com'), - 'xmlNamespaces' => true, + 'implicitNamespaces' => array('t' => 'http://example.com'), + 'xmlNamespaces' => true, )); $this->assertInstanceOf('\DOMDocumentFragment', $frag); $this->assertEmpty($this->html5->getErrors()); @@ -76,6 +83,29 @@ class Html5Test extends TestCase $this->assertEquals(1, $xpath->query('//t:tag', $frag)->length); } + public function testEncodingUtf8() + { + $dom = $this->html5->load(__DIR__.'/Fixtures/encoding/utf-8.html'); + $this->assertInstanceOf('\DOMDocument', $dom); + $this->assertEmpty($this->html5->getErrors()); + $this->assertFalse($this->html5->hasErrors()); + + $this->assertContains('Žťčýů', $dom->saveHTML()); + } + + public function testEncodingWindows1252() + { + $dom = $this->html5->load(__DIR__.'/Fixtures/encoding/windows-1252.html', array( + 'encoding' => 'Windows-1252', + )); + + $this->assertInstanceOf('\DOMDocument', $dom); + $this->assertEmpty($this->html5->getErrors()); + $this->assertFalse($this->html5->hasErrors()); + + $this->assertContains('Ž�èýù', mb_convert_encoding($dom->saveHTML(), 'UTF-8', 'Windows-1252')); + } + public function testErrors() { $dom = $this->html5->loadHTML('<xx as>'); |