simpletestlib MDL-24637 ContainsTagWithAttribute(s) does not work reliabily with attribute values "0" and ""

This commit is contained in:
Tim Hunt
2010-10-12 15:01:54 +00:00
parent d9ba4bd6ad
commit d5bbc449e9
2 changed files with 63 additions and 4 deletions
+4 -4
View File
@@ -229,7 +229,7 @@ class ContainsTagWithAttribute extends XMLStructureExpectation {
$list = $parser->getElementsByTagName($this->tag);
foreach ($list as $node) {
if ($node->attributes->getNamedItem($this->attribute)->nodeValue == $this->value) {
if ($node->attributes->getNamedItem($this->attribute)->nodeValue === (string) $this->value) {
return true;
}
}
@@ -291,11 +291,11 @@ class ContainsTagWithAttributes extends XMLStructureExpectation {
$allattributesmatch = true;
foreach ($this->expectedvalues as $expectedattribute => $expectedvalue) {
if (!$node->getAttribute($expectedattribute) && $expectedvalue != '') {
if ($node->getAttribute($expectedattribute) === '' && $expectedvalue !== '') {
$this->failurereason = 'nomatch';
continue 2; // Skip this tag, it doesn't have all the expected attributes
}
if ($node->getAttribute($expectedattribute) != $expectedvalue) {
if ($node->getAttribute($expectedattribute) !== (string) $expectedvalue) {
$allattributesmatch = false;
$this->failurereason = 'nomatch';
}
@@ -308,7 +308,7 @@ class ContainsTagWithAttributes extends XMLStructureExpectation {
$nodeattrlist = $node->attributes;
foreach ($nodeattrlist as $domattrname => $domattr) {
if (array_key_exists($domattrname, $this->forbiddenvalues) && $node->getAttribute($domattrname) == $this->forbiddenvalues[$domattrname]) {
if (array_key_exists($domattrname, $this->forbiddenvalues) && $node->getAttribute($domattrname) === (string) $this->forbiddenvalues[$domattrname]) {
$this->failurereason = "forbiddenmatch:$domattrname:" . $node->getAttribute($domattrname);
$foundamatch = false;
}