Skip to content

Commit 6e8c9f3

Browse files
SlamdunkDavertMik
authored andcommitted
seeLink: fix partial href matching (#5187)
* seeLink: fix partial href matching * Add bad path case for seeLink * Emulate ends-with
1 parent f775652 commit 6e8c9f3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/unit/Codeception/Module/TestsForWeb.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public function testSeeLink()
116116
$this->module->amOnPage('/external_url');
117117
$this->module->seeLink('Next');
118118
$this->module->seeLink('Next', 'http://codeception.com/');
119+
// Without TLD and trailing slash
120+
$this->module->dontSeeLink('Next', 'http://codeception');
119121
}
120122

121123
public function testDontSeeLink()
@@ -145,6 +147,16 @@ public function testSeeLinkFailsIfHrefDoesNotMatch()
145147
$this->module->seeLink('Next', '/fsdfsdf/');
146148
}
147149

150+
public function testSeeLinkFailsIfHrefDoesNotMatchExactly()
151+
{
152+
$this->setExpectedException(
153+
'PHPUnit\Framework\AssertionFailedError',
154+
"No links containing text 'Next' and URL 'http://codeception' were found in page /external_url"
155+
);
156+
$this->module->amOnPage('/external_url');
157+
$this->module->seeLink('Next', 'http://codeception');
158+
}
159+
148160
public function testDontSeeLinkFailsIfTextMatches()
149161
{
150162
$this->setExpectedException(
@@ -169,6 +181,7 @@ public function testSeeLinkMatchesRelativeLink()
169181
{
170182
$this->module->amOnPage('/info');
171183
$this->module->seeLink('Sign in!', '/login');
184+
$this->module->dontSeeLink('Sign in!', '/log');
172185
}
173186

174187
public function testDontSeeLinkMatchesRelativeLink()

0 commit comments

Comments
 (0)