function assertEltByIdHasAttrOfValue($eltId, $attrName, $attrValueExpected = true)
{
$matches = array();
$haystack = $this->getBrowser()->getContent();
// preg_match('/(\<[^\>]\s+id\s*=\s*"'.$eltId.'"\s+[^\>]*\>)/',$this->getBrowser()->getContent(),$matches);
preg_match('/(\\<[^\\>]*\\s+id\\s*=\\s*"' . $eltId . '"\\s*[^\\>]*\\>)/', $haystack, $matches);
// echo $matches[1];
if (!$this->assertTrue(isset($matches[1]), "Element with id [{$eltId}] should exist")) {
return false;
}
$haystack = $matches[1];
$matches = array();
preg_match('/\\s+(' . $attrName . ')\\s*=\\s*"([^"]*)"/', $haystack, $matches);
if (!$this->assertTrue(isset($matches[1]) && isset($matches[2]), "Element with id [{$eltId}] should have attribute of [{$attrName}]")) {
return false;
}
if ($attrValueExpected === true) {
return true;
}
if (!SimpleExpectation::isExpectation($attrValueExpected)) {
$attrValueExpected = new IdenticalExpectation($attrValueExpected);
}
$haystack = $matches[2];
if ($attrValueExpected->test($haystack)) {
return true;
}
return $this->assert($attrValueExpected, $haystack, "Element with id [{$eltId}] attribute [{$attrName}] value does not match- " . $attrValueExpected->testMessage($haystack));
}