$expectation = new ContainsTagWithAttribute('span', 'class', 'error');
$this->assertFalse($expectation->test('<span class="mismatch">message</span>'));
}
+
+ function test_link() {
+ $expectation = new ContainsTagWithAttribute('a', 'href', 'http://www.test.com');
+ $this->assertTrue($expectation->test('<a href="http://www.test.com">Click Here</a>'));
+ }
}
/**
}
function test($html) {
- $regex = '/<' . preg_quote($this->tag) . self::ATTRSREGEX .
- '(?:\s+' . preg_quote($this->attribute) . '\s*=\s*["\']' . preg_quote($this->value) . '["\'])' .
+ $regex = '/<' . preg_quote($this->tag, '/') . self::ATTRSREGEX .
+ '(?:\s+' . preg_quote($this->attribute, '/') . '\s*=\s*["\']' . preg_quote($this->value, '/') . '["\'])' .
self::ATTRSREGEX . '\s*>/';
return preg_match($regex, $html);
}
}
function test($html) {
- $regex = '/<' . preg_quote($this->tag) . self::ATTRSREGEX . '\s*>' . preg_quote($this->content) .
- '<\/' . preg_quote($this->tag) . '>/';
+ $regex = '/<' . preg_quote($this->tag, '/') . self::ATTRSREGEX . '\s*>' . preg_quote($this->content, '/') .
+ '<\/' . preg_quote($this->tag, '/') . '>/';
return preg_match($regex, $html);
}