unittests: NOBUG further fix to HTML expectations.
authortjhunt <tjhunt>
Wed, 30 Sep 2009 16:54:49 +0000 (16:54 +0000)
committertjhunt <tjhunt>
Wed, 30 Sep 2009 16:54:49 +0000 (16:54 +0000)
lib/simpletest/testsimpletestlib.php
lib/simpletestlib.php

index 30408e7..50791bc 100644 (file)
@@ -70,6 +70,12 @@ class ContainsTagWithAttribute_test extends UnitTestCase {
         $html = '<a title="Popup window" href="http://otheraddress.com" class="link" onclick="this.target=\'my_popup\';">Click here</a>';
         $this->assert(new ContainsTagWithAttribute('a', 'href', 'http://otheraddress.com'), $html);
     }
+
+    function test_real_regression1() {
+       $expectation = new ContainsTagWithAttribute('label', 'for', 'html_select4ac387224bf9d');
+        $html = '<label for="html_select4ac387224bf9d">Cool menu</label><select name="mymenu" id="html_select4ac387224bf9d" class="menumymenu select"> <option value="0">Choose...</option><option value="10">ten</option><option value="c2">two</option></select>';
+        $this->assert($expectation, $html);
+    }
 }
 
 /**
index 0f36dd7..400b22a 100644 (file)
@@ -196,7 +196,7 @@ abstract class XMLStructureExpectation extends SimpleExpectation {
     protected function load_xml($html) {
        $prevsetting = libxml_use_internal_errors(true);
        $parser = new DOMDocument();
-       if (!$parser->loadXML($html)) {
+       if (!$parser->loadXML('<html>' . $html . '</html>')) {
                $parser = new DOMDocument();
        }
         libxml_use_internal_errors($prevsetting);