Skip to content

Commit ec8dfc2

Browse files
committed
merged with 2.1
2 parents 111af53 + 1100a2e commit ec8dfc2

File tree

4 files changed

+56
-5
lines changed

4 files changed

+56
-5
lines changed

tests/data/app/controllers.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ function GET() {
9191
}
9292
}
9393

94+
class location_201 {
95+
function GET() {
96+
header('Location: /info', true, 201);
97+
}
98+
}
99+
94100
class external_url {
95101
function GET() {
96102
include __DIR__ . '/view/external_url.php';

tests/data/app/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'/redirect_interval' => 'redirect_interval',
2828
'/redirect_header_interval' => 'redirect_header_interval',
2929
'/redirect_meta_refresh' => 'redirect_meta_refresh',
30+
'/location_201' => 'location_201',
3031
'/relative_redirect' => 'redirect_relative',
3132
'/relative/redirect' => 'redirect_relative',
3233
'/redirect_twice' => 'redirect_twice',

tests/unit/Codeception/Module/PhpBrowserTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ public function testRedirectLimitNotReached()
242242
$this->module->seeCurrentUrlEquals('/info');
243243
}
244244

245+
public function testLocationHeaderDoesNotRedirectWhenStatusCodeIs201()
246+
{
247+
$this->module->amOnPage('/location_201');
248+
$this->module->seeResponseCodeIs(201);
249+
$this->module->seeCurrentUrlEquals('/location_201');
250+
}
251+
245252
public function testSetCookieByHeader()
246253
{
247254
$this->module->amOnPage('/cookies2');

tests/unit/Codeception/Module/TestsForWeb.php

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,48 @@ public function testSeeInCurrentUrl()
9393

9494
public function testSeeLink()
9595
{
96-
$this->module->amOnPage('/');
97-
$this->module->seeLink('More info');
98-
$this->module->dontSeeLink('/info');
99-
$this->module->dontSeeLink('#info');
100-
$this->module->seeLink('More', '/info');
96+
$this->module->amOnPage('/external_url');
97+
$this->module->seeLink('Next');
98+
$this->module->seeLink('Next', 'http://codeception.com/');
99+
}
100+
101+
public function testDontSeeLink()
102+
{
103+
$this->module->amOnPage('/external_url');
104+
$this->module->dontSeeLink('Back');
105+
$this->module->dontSeeLink('Next', '/fsdfsdf/');
106+
}
107+
108+
public function testSeeLinkFailsIfTextDoesNotMatch()
109+
{
110+
$this->setExpectedException('PHPUnit_Framework_AssertionFailedError',
111+
"No links containing text 'Codeception' were found in page /external_url");
112+
$this->module->amOnPage('/external_url');
113+
$this->module->seeLink('Codeception');
114+
}
115+
116+
public function testSeeLinkFailsIfHrefDoesNotMatch()
117+
{
118+
$this->setExpectedException('PHPUnit_Framework_AssertionFailedError',
119+
"No links containing text 'Next' and URL '/fsdfsdf/' were found in page /external_url");
120+
$this->module->amOnPage('/external_url');
121+
$this->module->seeLink('Next', '/fsdfsdf/');
122+
}
123+
124+
public function testDontSeeLinkFailsIfTextMatches()
125+
{
126+
$this->setExpectedException('PHPUnit_Framework_AssertionFailedError',
127+
"Link containing text 'Next' was found in page /external_url");
128+
$this->module->amOnPage('/external_url');
129+
$this->module->dontSeeLink('Next');
130+
}
131+
132+
public function testDontSeeLinkFailsIfTextAndUrlMatches()
133+
{
134+
$this->setExpectedException('PHPUnit_Framework_AssertionFailedError',
135+
"Link containing text 'Next' and URL 'http://codeception.com/' was found in page /external_url");
136+
$this->module->amOnPage('/external_url');
137+
$this->module->dontSeeLink('Next', 'http://codeception.com/');
101138
}
102139

103140
public function testClick()

0 commit comments

Comments
 (0)