Skip to content

Commit 23dba2f

Browse files
feat: add support for Guzzle 8
1 parent 495a2cf commit 23dba2f

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"ext-json": "*",
2323
"codeception/codeception": "*@dev",
2424
"codeception/lib-innerbrowser": "*@dev",
25-
"guzzlehttp/guzzle": "^7.4",
25+
"guzzlehttp/guzzle": "^7.8.2 | ^8.0",
26+
"guzzlehttp/psr7": "^2.6.3 | ^3.0",
2627
"symfony/browser-kit": "^5.4 | ^6.0 | ^7.0 | ^8.0"
2728
},
2829
"require-dev": {

src/Codeception/Lib/Connector/Guzzle.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,13 @@ protected function doRequest(object $request): object
209209
$response = $this->client->send($guzzleRequest, $options);
210210
}
211211
} catch (RequestException $exception) {
212-
if (!$exception->hasResponse()) {
212+
// Guzzle 7 exposes the response on RequestException itself,
213+
// Guzzle 8 only on its ResponseException subclass.
214+
$response = method_exists($exception, 'getResponse') ? $exception->getResponse() : null;
215+
216+
if ($response === null) {
213217
throw $exception;
214218
}
215-
216-
$response = $exception->getResponse();
217219
}
218220

219221
// @phpstan-ignore-next-line

src/Codeception/Module/PhpBrowser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* url: 'http://localhost' # Internationalized domain names (IDN) need to be passed in punycode
4545
* auth: ['admin', '123345']
4646
* curl:
47-
* CURLOPT_RETURNTRANSFER: true
47+
* CURLOPT_TCP_KEEPALIVE: true
4848
* cookies:
4949
* cookie-1:
5050
* Name: userName

tests/unit/Codeception/Module/PhpBrowserTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ public function testCurlSslOptions(): void
397397
$this->module->_setConfig([
398398
'url' => 'https://github.com',
399399
'curl' => [
400-
'CURLOPT_NOBODY' => true,
401400
'CURLOPT_SSL_CIPHER_LIST' => 'TLSv1',
402401
]]);
403402
$this->module->_initialize();
@@ -407,7 +406,7 @@ public function testCurlSslOptions(): void
407406
$this->assertArrayHasKey('curl', $config);
408407
$this->assertArrayHasKey(CURLOPT_SSL_CIPHER_LIST, $config['curl']);
409408
$this->module->amOnPage('/');
410-
$this->assertSame('', $this->module->_getResponseContent(), 'CURLOPT_NOBODY setting is not respected');
409+
$this->module->seeResponseCodeIsSuccessful();
411410
}
412411

413412
public function testHttpAuth(): void

0 commit comments

Comments
 (0)