From 4a55ebeec62499f9ac7c79a70ece2f6573030e68 Mon Sep 17 00:00:00 2001 From: Tavo Nieves J Date: Sun, 6 Jun 2021 21:16:38 -0500 Subject: [PATCH] Support for Codeception 5 --- .github/workflows/main.yml | 2 +- composer.json | 13 +++++++------ readme.md | 2 +- src/Codeception/Lib/Connector/Guzzle.php | 2 +- src/Codeception/Module/PhpBrowser.php | 8 ++++---- .../unit/Codeception/Module/PhpBrowserRestTest.php | 4 ++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0a77212..3e53396 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [7.1, 7.2, 7.3, 7.4, 8.0] + php: [7.3, 7.4, 8.0] steps: - name: Checkout code diff --git a/composer.json b/composer.json index b4d69e0..0e20ed2 100644 --- a/composer.json +++ b/composer.json @@ -15,16 +15,17 @@ ], "minimum-stability": "RC", "require": { - "php": "^7.1 || ^8.0", - "guzzlehttp/guzzle": "^6.3|^7.0", - "codeception/lib-innerbrowser": "^1.3", - "codeception/codeception": "*@dev" + "php": "^7.3 || ^8.0", + "ext-json": "*", + "guzzlehttp/guzzle": "^7.3", + "codeception/lib-innerbrowser": "^1.5 || *@dev", + "codeception/codeception": "^5.0 || *@dev" }, "require-dev": { - "codeception/module-rest": "^1.0" + "codeception/module-rest": "^1.3 || *@dev" }, "conflict": { - "codeception/codeception": "<4.0" + "codeception/codeception": "<5.0" }, "suggest": { "codeception/phpbuiltinserver": "Start and stop PHP built-in web server for your tests" diff --git a/readme.md b/readme.md index c5de470..ea338c4 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ A Codeception module for testing web application over HTTP. ## Requirements -* `PHP 7.1` or higher. +* `PHP 7.3` or higher. ## Installation diff --git a/src/Codeception/Lib/Connector/Guzzle.php b/src/Codeception/Lib/Connector/Guzzle.php index d8b0064..80792c2 100644 --- a/src/Codeception/Lib/Connector/Guzzle.php +++ b/src/Codeception/Lib/Connector/Guzzle.php @@ -176,7 +176,7 @@ protected function getAbsoluteUri($uri) if (strpos($uri, '://') === false && strpos($uri, '//') !== 0) { if (strpos($uri, '/') === 0) { $baseUriPath = $baseUri->getPath(); - if (!empty($baseUriPath) && strpos($uri, $baseUriPath) === 0) { + if (!empty($baseUriPath) && strpos($uri, (string) $baseUriPath) === 0) { $uri = substr($uri, strlen($baseUriPath)); } diff --git a/src/Codeception/Module/PhpBrowser.php b/src/Codeception/Module/PhpBrowser.php index abcd394..4755dce 100644 --- a/src/Codeception/Module/PhpBrowser.php +++ b/src/Codeception/Module/PhpBrowser.php @@ -219,7 +219,7 @@ public function _getResponseCode() return $this->getResponseStatusCode(); } - public function _initializeSession() + public function _initializeSession(): void { // independent sessions need independent cookies $this->client = new Guzzle(); @@ -255,7 +255,7 @@ public function _prepareSession() $this->client->setClient($this->guzzle); } - public function _backupSession() + public function _backupSession(): array { return [ 'client' => $this->client, @@ -265,14 +265,14 @@ public function _backupSession() ]; } - public function _loadSession($session) + public function _loadSession($session): void { foreach ($session as $key => $val) { $this->$key = $val; } } - public function _closeSession($session = null) + public function _closeSession($session = null): void { unset($session); } diff --git a/tests/unit/Codeception/Module/PhpBrowserRestTest.php b/tests/unit/Codeception/Module/PhpBrowserRestTest.php index a86a6eb..49f037a 100644 --- a/tests/unit/Codeception/Module/PhpBrowserRestTest.php +++ b/tests/unit/Codeception/Module/PhpBrowserRestTest.php @@ -133,13 +133,13 @@ public function testArrayJson() public function testSeeResponseContainsJsonFailsGracefullyWhenJsonResultIsNotArray() { $this->shouldFail(); - $this->setStubResponse(json_encode('no_status')); + $this->setStubResponse(json_encode('no_status', JSON_THROW_ON_ERROR)); $this->module->seeResponseContainsJson(array('id' => 1)); } public function testDontSeeResponseJsonMatchesJsonPathPassesWhenJsonResultIsNotArray() { - $this->setStubResponse(json_encode('no_status')); + $this->setStubResponse(json_encode('no_status', JSON_THROW_ON_ERROR)); $this->module->dontSeeResponseJsonMatchesJsonPath('$.error'); }