22
33namespace Masterminds \HTML5 \Tests ;
44
5+ use Masterminds \HTML5 ;
6+
57class Html5Test extends TestCase
68{
9+ /**
10+ * @var HTML5
11+ */
12+ private $ html5 ;
13+
714 public function setUp ()
815 {
916 $ this ->html5 = $ this ->getInstance ();
@@ -50,8 +57,8 @@ public function testLoadOptions()
5057 {
5158 // doc
5259 $ dom = $ this ->html5 ->loadHTML ($ this ->wrap ('<t:tag/> ' ), array (
53- 'implicitNamespaces ' => array ('t ' => 'http://example.com ' ),
54- 'xmlNamespaces ' => true ,
60+ 'implicitNamespaces ' => array ('t ' => 'http://example.com ' ),
61+ 'xmlNamespaces ' => true ,
5562 ));
5663 $ this ->assertInstanceOf ('\DOMDocument ' , $ dom );
5764 $ this ->assertEmpty ($ this ->html5 ->getErrors ());
@@ -63,8 +70,8 @@ public function testLoadOptions()
6370
6471 // doc fragment
6572 $ frag = $ this ->html5 ->loadHTMLFragment ('<t:tag/> ' , array (
66- 'implicitNamespaces ' => array ('t ' => 'http://example.com ' ),
67- 'xmlNamespaces ' => true ,
73+ 'implicitNamespaces ' => array ('t ' => 'http://example.com ' ),
74+ 'xmlNamespaces ' => true ,
6875 ));
6976 $ this ->assertInstanceOf ('\DOMDocumentFragment ' , $ frag );
7077 $ this ->assertEmpty ($ this ->html5 ->getErrors ());
@@ -76,6 +83,29 @@ public function testLoadOptions()
7683 $ this ->assertEquals (1 , $ xpath ->query ('//t:tag ' , $ frag )->length );
7784 }
7885
86+ public function testEncodingUtf8 ()
87+ {
88+ $ dom = $ this ->html5 ->load (__DIR__ .'/Fixtures/encoding/utf-8.html ' );
89+ $ this ->assertInstanceOf ('\DOMDocument ' , $ dom );
90+ $ this ->assertEmpty ($ this ->html5 ->getErrors ());
91+ $ this ->assertFalse ($ this ->html5 ->hasErrors ());
92+
93+ $ this ->assertContains ('Žťčýů ' , $ dom ->saveHTML ());
94+ }
95+
96+ public function testEncodingWindows1252 ()
97+ {
98+ $ dom = $ this ->html5 ->load (__DIR__ .'/Fixtures/encoding/windows-1252.html ' , array (
99+ 'encoding ' => 'Windows-1252 ' ,
100+ ));
101+
102+ $ this ->assertInstanceOf ('\DOMDocument ' , $ dom );
103+ $ this ->assertEmpty ($ this ->html5 ->getErrors ());
104+ $ this ->assertFalse ($ this ->html5 ->hasErrors ());
105+
106+ $ this ->assertContains ('Ž�èýù ' , mb_convert_encoding ($ dom ->saveHTML (), 'UTF-8 ' , 'Windows-1252 ' ));
107+ }
108+
79109 public function testErrors ()
80110 {
81111 $ dom = $ this ->html5 ->loadHTML ('<xx as> ' );
0 commit comments