assertLink check only one (first) link, selected by label. If page have 2,3,4,... links with indentical text, but witdth different "href", we can`t check all this links.
my variant WebTestCase::assertLink() method:
public function assertLink($label, $expected = true, $message = '%s')
{
if( !$expected )
{
$url = $this->browser->getLink($label);
return $this->assertTrue($url !== false,
sprintf($message, "Link [$label] should exist"));
}
//??? separate method?
$urls = $this->browser->getLinks($label);
$expectation = new IdenticalExpectation($expected);
foreach( $urls as $url )
{
//copypaste form SimpleTestCase::assert()
$compare = $url->asString();
if( $expectation->test( $compare ) )
{
$msg = $expectation->overlayMessage( $compare,
$this->reporter->getDumper() );
return $this->pass(sprintf( $message, $msg ));
}
}
return $this->fail( sprintf($message, "Link [$label] should exist") );
}
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
- if( !$expected )
+ if( true === $expected )