Skip to content

Commit b55b32b

Browse files
johannesschobelDavertMik
authored andcommitted
new REST / InnerBrowser Asserts (#5030)
* new assertions to assert "ranges" of status-codes (e.g., if it is a client-error --> 4xx) * add missing test
1 parent f95f94b commit b55b32b

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/unit/Codeception/Module/PhpBrowserTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,4 +691,40 @@ public function testSetUserAgentUsingConfig()
691691
$response = $this->module->grabPageSource();
692692
$this->assertEquals('Codeception User Agent Test 1.0', $response, 'Incorrect user agent');
693693
}
694+
695+
public function testIfStatusCodeIsWithin2xxRange()
696+
{
697+
$this->module->amOnPage('https://httpstat.us/200');
698+
$this->module->seeResponseCodeIsSuccessful();
699+
700+
$this->module->amOnPage('https://httpstat.us/299');
701+
$this->module->seeResponseCodeIsSuccessful();
702+
}
703+
704+
public function testIfStatusCodeIsWithin3xxRange()
705+
{
706+
$this->module->amOnPage('https://httpstat.us/300');
707+
$this->module->seeResponseCodeIsRedirection();
708+
709+
$this->module->amOnPage('https://httpstat.us/399');
710+
$this->module->seeResponseCodeIsRedirection();
711+
}
712+
713+
public function testIfStatusCodeIsWithin4xxRange()
714+
{
715+
$this->module->amOnPage('https://httpstat.us/400');
716+
$this->module->seeResponseCodeIsClientError();
717+
718+
$this->module->amOnPage('https://httpstat.us/499');
719+
$this->module->seeResponseCodeIsClientError();
720+
}
721+
722+
public function testIfStatusCodeIsWithin5xxRange()
723+
{
724+
$this->module->amOnPage('https://httpstat.us/500');
725+
$this->module->seeResponseCodeIsServerError();
726+
727+
$this->module->amOnPage('https://httpstat.us/599');
728+
$this->module->seeResponseCodeIsServerError();
729+
}
694730
}

0 commit comments

Comments
 (0)