Browse Source

Add test for loadHtml method

Fernando Herrero 7 years ago
parent
commit
c0961d1f69
2 changed files with 29 additions and 0 deletions
  1. 15 0
      tests/Fixture/sample.html
  2. 14 0
      tests/TestCase/Utility/XmlTest.php

+ 15 - 0
tests/Fixture/sample.html

@@ -0,0 +1,15 @@
+<html>
+<body>
+
+<p>Browsers usually indent blockquote elements.</p>
+
+<blockquote cite="http://www.worldwildlife.org/who/index.html">
+For 50 years, WWF has been protecting the future of nature.
+The world's leading conservation organization,
+WWF works in 100 countries and is supported by
+1.2 million members in the United States and
+close to 5 million globally.
+</blockquote>
+
+</body>
+</html>

+ 14 - 0
tests/TestCase/Utility/XmlTest.php

@@ -248,6 +248,20 @@ class XmlTest extends TestCase
     }
 
     /**
+     * testLoadHtml method
+     *
+     * @return void
+     */
+    public function testLoadHtml()
+    {
+        $html = CORE_TESTS . 'Fixture/sample.html';
+        $html = file_get_contents($html);
+        $xml = Xml::loadHtml($html);
+        $xml = html_entity_decode($xml->asXML(), ENT_NOQUOTES, 'UTF-8');
+        $this->assertEquals($html, $xml);
+    }
+
+    /**
      * testFromArray method
      *
      * @return void