Skip to content

Commit 3ae7663

Browse files
authored
Merge pull request #43 from Codeception/fix-tests-httpstat.us
fix: use local server in tests httpstat.us is down
2 parents 81c4616 + 2e2b186 commit 3ae7663

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
name: CI
22

3-
on: [push, pull_request]
4-
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
58
jobs:
69
tests:
710
runs-on: ubuntu-latest
811

912
strategy:
1013
matrix:
11-
php: [8.1, 8.2, 8.3]
14+
php: [8.1, 8.2, 8.3, 8.4]
1215

1316
steps:
1417
- name: Checkout code

tests/data/app/status.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
$statusCode = filter_var($_GET['status'] ?? 200, FILTER_VALIDATE_INT);
5+
6+
http_response_code($statusCode);
7+
header("Content-Type: text/plain");
8+
echo "Status code: $statusCode\n";

tests/unit/Codeception/Module/PhpBrowserTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -708,37 +708,37 @@ public function testSetUserAgentUsingConfig(): void
708708

709709
public function testIfStatusCodeIsWithin2xxRange(): void
710710
{
711-
$this->module->amOnPage('https://httpstat.us/200');
711+
$this->module->amOnPage('http://localhost:8000/status.php?status=200');
712712
$this->module->seeResponseCodeIsSuccessful();
713713

714-
$this->module->amOnPage('https://httpstat.us/299');
714+
$this->module->amOnPage('http://localhost:8000/status.php?status=299');
715715
$this->module->seeResponseCodeIsSuccessful();
716716
}
717717

718718
public function testIfStatusCodeIsWithin3xxRange(): void
719719
{
720-
$this->module->amOnPage('https://httpstat.us/300');
720+
$this->module->amOnPage('http://localhost:8000/status.php?status=300');
721721
$this->module->seeResponseCodeIsRedirection();
722722

723-
$this->module->amOnPage('https://httpstat.us/399');
723+
$this->module->amOnPage('http://localhost:8000/status.php?status=399');
724724
$this->module->seeResponseCodeIsRedirection();
725725
}
726726

727727
public function testIfStatusCodeIsWithin4xxRange(): void
728728
{
729-
$this->module->amOnPage('https://httpstat.us/400');
729+
$this->module->amOnPage('http://localhost:8000/status.php?status=400');
730730
$this->module->seeResponseCodeIsClientError();
731731

732-
$this->module->amOnPage('https://httpstat.us/499');
732+
$this->module->amOnPage('http://localhost:8000/status.php?status=499');
733733
$this->module->seeResponseCodeIsClientError();
734734
}
735735

736736
public function testIfStatusCodeIsWithin5xxRange(): void
737737
{
738-
$this->module->amOnPage('https://httpstat.us/500');
738+
$this->module->amOnPage('http://localhost:8000/status.php?status=500');
739739
$this->module->seeResponseCodeIsServerError();
740740

741-
$this->module->amOnPage('https://httpstat.us/599');
741+
$this->module->amOnPage('http://localhost:8000/status.php?status=599');
742742
$this->module->seeResponseCodeIsServerError();
743743
}
744744

0 commit comments

Comments
 (0)