Skip to content

Commit c196265

Browse files
authored
Merge pull request #6 from Codeception/maintenance
Maintenance
2 parents 2f03dd3 + d878972 commit c196265

File tree

4 files changed

+24
-32
lines changed

4 files changed

+24
-32
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ jobs:
2424
run: composer validate
2525

2626
- name: Install dependencies
27-
run: |
28-
composer require phpunit/phpunit "<=8.5.2" --no-update --ignore-platform-reqs
29-
composer install --prefer-dist --no-progress --no-interaction --no-suggest
27+
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
3028

3129
- name: Run test suite
3230
run: |

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"require": {
1818
"php": ">=5.6.0 <8.0",
1919
"guzzlehttp/guzzle": "^6.3.0|^7.0.0",
20-
"codeception/lib-innerbrowser": "^1.0",
21-
"codeception/codeception": "^4.0"
20+
"codeception/lib-innerbrowser": "^1.3.2",
21+
"codeception/codeception": "*@dev"
2222
},
2323
"require-dev": {
2424
"codeception/util-robohelpers": "dev-master",

src/Codeception/Lib/Connector/Guzzle.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use GuzzleHttp\Psr7\Response as Psr7Response;
1616
use GuzzleHttp\Psr7\Uri as Psr7Uri;
1717
use Symfony\Component\BrowserKit\AbstractBrowser as Client;
18-
use Symfony\Component\BrowserKit\Cookie;
1918
use Symfony\Component\BrowserKit\Request as BrowserKitRequest;
2019
use Symfony\Component\BrowserKit\Response as BrowserKitResponse;
2120

@@ -27,10 +26,10 @@ class Guzzle extends Client
2726
];
2827
protected $refreshMaxInterval = 0;
2928

30-
protected $awsCredentials = null;
31-
protected $awsSignature = null;
29+
protected $awsCredentials;
30+
protected $awsSignature;
3231

33-
/** @var \GuzzleHttp\Client */
32+
/** @var GuzzleClient */
3433
protected $client;
3534

3635
/**
@@ -49,7 +48,7 @@ public function setRefreshMaxInterval($seconds)
4948
$this->refreshMaxInterval = $seconds;
5049
}
5150

52-
public function setClient(GuzzleClient &$client)
51+
public function setClient(GuzzleClient $client)
5352
{
5453
$this->client = $client;
5554
}
@@ -66,7 +65,7 @@ public function setClient(GuzzleClient &$client)
6665
*/
6766
public function setHeader($name, $value)
6867
{
69-
if (strval($value) === '') {
68+
if ((string)$value === '') {
7069
$this->deleteHeader($name);
7170
} else {
7271
$this->requestOptions['headers'][$name] = $value;
@@ -101,9 +100,9 @@ public function setAuth($username, $password, $type = 'basic')
101100
/**
102101
* Taken from Mink\BrowserKitDriver
103102
*
104-
* @param Response $response
103+
* @param Psr7Response $response
105104
*
106-
* @return \Symfony\Component\BrowserKit\Response
105+
* @return BrowserKitResponse
107106
*/
108107
protected function createResponse(Psr7Response $response)
109108
{
@@ -120,7 +119,7 @@ protected function createResponse(Psr7Response $response)
120119
}
121120

122121
if (strpos($contentType, 'charset=') === false) {
123-
if (preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $body, $matches)) {
122+
if (preg_match('/<meta[^>]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $body, $matches)) {
124123
$contentType .= ';charset=' . $matches[1];
125124
}
126125
$headers['Content-Type'] = [$contentType];
@@ -131,7 +130,7 @@ protected function createResponse(Psr7Response $response)
131130
$matches = [];
132131

133132
$matchesMeta = preg_match(
134-
'/\<meta[^\>]+http-equiv="refresh" content="\s*(\d*)\s*;\s*url=(.*?)"/i',
133+
'/<meta[^>]+http-equiv="refresh" content="\s*(\d*)\s*;\s*url=(.*?)"/i',
135134
$body,
136135
$matches
137136
);
@@ -149,7 +148,7 @@ protected function createResponse(Psr7Response $response)
149148
$uri = new Psr7Uri($this->getAbsoluteUri($matches[2]));
150149
$currentUri = new Psr7Uri($this->getHistory()->current()->getUri());
151150

152-
if ($uri->withFragment('') != $currentUri->withFragment('')) {
151+
if ($uri->withFragment('') !== $currentUri->withFragment('')) {
153152
$status = 302;
154153
$headers['Location'] = $matchesMeta ? htmlspecialchars_decode($uri) : (string)$uri;
155154
}
@@ -196,7 +195,7 @@ protected function doRequest($request)
196195
}
197196

198197
$formData = $this->extractFormData($request);
199-
if (empty($multipartData) and $formData) {
198+
if (empty($multipartData) && $formData) {
200199
$options['form_params'] = $formData;
201200
}
202201

@@ -292,7 +291,7 @@ protected function mapFiles($requestFiles, $arrayName = '')
292291
if (is_array($info)) {
293292
if (isset($info['tmp_name'])) {
294293
if ($info['tmp_name']) {
295-
$handle = fopen($info['tmp_name'], 'r');
294+
$handle = fopen($info['tmp_name'], 'rb');
296295
$filename = isset($info['name']) ? $info['name'] : null;
297296
$file = [
298297
'name' => $name,
@@ -312,7 +311,7 @@ protected function mapFiles($requestFiles, $arrayName = '')
312311
} else {
313312
$files[] = [
314313
'name' => $name,
315-
'contents' => fopen($info, 'r')
314+
'contents' => fopen($info, 'rb')
316315
];
317316
}
318317
}
@@ -325,7 +324,6 @@ protected function extractCookies($host)
325324
$jar = [];
326325
$cookies = $this->getCookieJar()->all();
327326
foreach ($cookies as $cookie) {
328-
/** @var $cookie Cookie **/
329327
$setCookie = SetCookie::fromString((string)$cookie);
330328
if (!$setCookie->getDomain()) {
331329
$setCookie->setDomain($host);

src/Codeception/Module/PhpBrowser.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
namespace Codeception\Module;
33

4+
use Closure;
45
use Codeception\Lib\Connector\Guzzle;
56
use Codeception\Lib\InnerBrowser;
67
use Codeception\Lib\Interfaces\MultiSession;
78
use Codeception\Lib\Interfaces\Remote;
8-
use Codeception\Lib\Interfaces\RequiresPackage;
99
use Codeception\TestInterface;
1010
use Codeception\Util\Uri;
1111
use GuzzleHttp\Client as GuzzleClient;
@@ -74,7 +74,7 @@
7474
* * `client` - Symfony BrowserKit instance.
7575
*
7676
*/
77-
class PhpBrowser extends InnerBrowser implements Remote, MultiSession, RequiresPackage
77+
class PhpBrowser extends InnerBrowser implements Remote, MultiSession
7878
{
7979

8080
protected $requiredFields = ['url'];
@@ -110,7 +110,7 @@ class PhpBrowser extends InnerBrowser implements Remote, MultiSession, RequiresP
110110
];
111111

112112
/**
113-
* @var \Codeception\Lib\Connector\Guzzle
113+
* @var Guzzle
114114
*/
115115
public $client;
116116

@@ -119,11 +119,6 @@ class PhpBrowser extends InnerBrowser implements Remote, MultiSession, RequiresP
119119
*/
120120
public $guzzle;
121121

122-
public function _requires()
123-
{
124-
return ['GuzzleHttp\Client' => '"guzzlehttp/guzzle": ">=6.3.0 <7.0"'];
125-
}
126-
127122
public function _initialize()
128123
{
129124
$this->_initializeSession();
@@ -175,8 +170,8 @@ public function amOnUrl($url)
175170
public function amOnSubdomain($subdomain)
176171
{
177172
$url = $this->config['url'];
178-
$url = preg_replace('~(https?:\/\/)(.*\.)(.*\.)~', "$1$3", $url); // removing current subdomain
179-
$url = preg_replace('~(https?:\/\/)(.*)~', "$1$subdomain.$2", $url); // inserting new
173+
$url = preg_replace('~(https?://)(.*\.)(.*\.)~', "$1$3", $url); // removing current subdomain
174+
$url = preg_replace('~(https?://)(.*)~', "$1$subdomain.$2", $url); // inserting new
180175
$config = $this->config;
181176
$config['url'] = $url;
182177
$this->_reconfigure($config);
@@ -204,9 +199,10 @@ protected function onReconfigure()
204199
* It is not recommended to use this command on a regular basis.
205200
* If Codeception lacks important Guzzle Client methods, implement them and submit patches.
206201
*
207-
* @param callable $function
202+
* @param Closure $function
203+
* @return mixed
208204
*/
209-
public function executeInGuzzle(\Closure $function)
205+
public function executeInGuzzle(Closure $function)
210206
{
211207
return $function($this->guzzle);
212208
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy