Skip to content

Support for Codeception 5 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Lib/Connector/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
8 changes: 4 additions & 4 deletions src/Codeception/Module/PhpBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -255,7 +255,7 @@ public function _prepareSession()
$this->client->setClient($this->guzzle);
}

public function _backupSession()
public function _backupSession(): array
{
return [
'client' => $this->client,
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Codeception/Module/PhpBrowserRestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down