]> git.mjollnir.org Git - moodle.git/commitdiff
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 30408e7e45698a0338990e2f936c908393cc7574..50791bccb865f81d59398b1ae520b87ad424e3bb 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 0f36dd7dc4280c321160d3cdfa6202d347c715de..400b22ad99dc6181e8cd9b03f9e33ef7f6affaa2 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);