Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Commit 5de51bb

Browse files
authored
Merge branch 'main' into jd-feat-jsonDx
2 parents 1f986cd + 63aca61 commit 5de51bb

File tree

10 files changed

+74
-29
lines changed

10 files changed

+74
-29
lines changed

.travis.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
language: php
22

3+
dist: trusty
4+
35
addons:
46
chrome: stable
57

@@ -10,8 +12,7 @@ cache:
1012
env:
1113
global:
1214
- DISPLAY=:99.0
13-
- CHROME_DRIVER_VERSION=2.36
14-
- SELENIUM_VERSION=3.6.0
15+
- SELENIUM_VERSION=3.9.1
1516
matrix:
1617
- DEPS=high PROFILE=default
1718
- DEPS=low PROFILE=default
@@ -21,31 +22,41 @@ env:
2122
php:
2223
- 5.5
2324
- 5.6
24-
- 7.0
25-
- 7.1
2625
- 7.2
26+
- 7.3
27+
- 7.4
2728
- nightly
2829

2930
matrix:
31+
exclude:
32+
- php: 7.4
33+
env: DEPS=low PROFILE=default
34+
- php: 7.4
35+
env: DEPS=low PROFILE=symfony2
36+
- php: nightly
37+
env: DEPS=low PROFILE=default
38+
- php: nightly
39+
env: DEPS=low PROFILE=symfony2
3040
allow_failures:
3141
- php: nightly
32-
- php: hhvm
33-
- php: hhvm-nightly
3442
fast_finish: true
3543

3644
before_script:
3745
- Xvfb $DISPLAY -extension RANDR &> /dev/null &
3846

39-
- wget "https://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip"
40-
- unzip chromedriver_linux64.zip
47+
- LATEST_CHROMEDRIVER_VERSION=`curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE`
48+
- wget --no-verbose https://chromedriver.storage.googleapis.com/$LATEST_CHROMEDRIVER_VERSION/chromedriver_linux64.zip
49+
- unzip chromedriver_linux64.zip -d ~/bin
50+
4151
- wget "https://selenium-release.storage.googleapis.com/${SELENIUM_VERSION%%.[[:digit:]]}/selenium-server-standalone-${SELENIUM_VERSION}.jar" -O selenium.jar
42-
- java -jar -Dwebdriver.chrome.driver=./chromedriver selenium.jar &> /dev/null &
52+
- java -jar selenium.jar &> /dev/null &
4353

4454
- php -S localhost:8080 -t tests/fixtures/www &> /dev/null &
4555
- cp behat.yml{.dist,}
46-
- composer install
56+
- COMPOSER_PATH="/home/travis/.phpenv/versions/$TRAVIS_PHP_VERSION/bin/composer"
57+
- php -d memory_limit=-1 $COMPOSER_PATH install
4758

48-
- test "$DEPS" == "low" || composer update --prefer-lowest
59+
- test "$DEPS" == "high" || php -d memory_limit=-1 $COMPOSER_PATH update --prefer-lowest
4960
- test ${TRAVIS_PHP_VERSION:0:1} -lt 7 || composer update atoum/atoum
5061

5162
script:

behat.yml.dist

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ default:
2020
base_url: 'http://localhost:8080'
2121
files_path: 'tests/fixtures/files'
2222
goutte: ~
23-
selenium2: ~
23+
selenium2:
24+
capabilities:
25+
chrome:
26+
switches:
27+
- "--headless"
28+
- "--disable-gpu"
29+
- "--no-sandbox"
30+
extra_capabilities:
31+
"goog:chromeOptions":
32+
w3c: false
2433
browser_name: 'chrome'
2534
sessions:
2635
default:

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "behatch/contexts",
2+
"name": "soyuka/contexts",
33
"description": "Behatch contexts",
44
"keywords": ["BDD", "Behat", "Symfony2", "Context"],
55
"type": "library",
@@ -8,17 +8,17 @@
88
"require": {
99
"php": ">=5.5",
1010
"behat/behat": "^3.0.13",
11-
"behat/mink-extension": "^2.3.1",
11+
"friends-of-behat/mink-extension": "^2.3.1",
1212
"justinrainbow/json-schema": "^5.0",
13-
"symfony/property-access": "^2.3|^3.0|^4.0",
14-
"symfony/http-foundation": "^2.3|^3.0|^4.0",
15-
"symfony/dom-crawler": "^2.4|^3.0|^4.0"
13+
"symfony/property-access": "^2.3|^3.0|^4.0|^5.0|^6.0",
14+
"symfony/http-foundation": "^2.3|^3.0|^4.0|^5.0|^6.0",
15+
"symfony/dom-crawler": "^2.4|^3.0|^4.0|^5.0|^6.0"
1616
},
1717

1818
"require-dev": {
1919
"behat/mink-goutte-driver": "^1.1",
2020
"guzzlehttp/guzzle": "^6.3",
21-
"behat/mink-selenium2-driver": "^1.3",
21+
"behat/mink-selenium2-driver": "^1.4@dev",
2222
"atoum/atoum": "^2.8|^3.0",
2323
"fabpot/goutte": "^3.2"
2424
},

src/Context/JsonContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function theJsonShouldBeValidAccordingToTheSchema($filename)
343343
$this->getJson(),
344344
new JsonSchema(
345345
file_get_contents($filename),
346-
'file://' . realpath($filename)
346+
'file://' . str_replace(DIRECTORY_SEPARATOR, '/', realpath($filename))
347347
)
348348
);
349349
}

src/HttpCall/HttpCallResultPoolResolver.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Behatch\HttpCall;
44

55
use Behat\Behat\Context\Argument\ArgumentResolver;
6+
use ReflectionClass;
67

78
class HttpCallResultPoolResolver implements ArgumentResolver
89
{
@@ -23,11 +24,12 @@ public function resolveArguments(\ReflectionClass $classReflection, array $argum
2324
if ($constructor !== null) {
2425
$parameters = $constructor->getParameters();
2526
foreach ($parameters as $parameter) {
26-
if (
27-
null !== $parameter->getType()
28-
&& isset($this->dependencies[$parameter->getType()->getName()])
29-
) {
30-
$arguments[$parameter->name] = $this->dependencies[$parameter->getType()->getName()];
27+
$class = PHP_VERSION_ID < 80000 ? $parameter->getClass() : ($parameter->getType() && !$parameter->getType()->isBuiltin()
28+
? new ReflectionClass($parameter->getType()->getName())
29+
: null
30+
);
31+
if (null !== $class && isset($this->dependencies[$class->name])) {
32+
$arguments[$parameter->name] = $this->dependencies[$class->name];
3133
}
3234
}
3335
}

src/HttpCall/Request/BrowserKit.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public function send($method, $url, $parameters = [], $files = [], $content = nu
6868
$client = $this->mink->getSession()->getDriver()->getClient();
6969

7070
$client->followRedirects(false);
71+
72+
// Workaround for https://github.com/symfony/symfony/issues/33393: prevent a default Accept header to be set
73+
if (!isset($headers['HTTP_ACCEPT']) && '' === $client->getServerParameter('HTTP_ACCEPT')) {
74+
$headers['HTTP_ACCEPT'] = null;
75+
}
76+
7177
$client->request($method, $url, $parameters, $files, $headers, $content);
7278
$client->followRedirects(true);
7379
$this->resetHttpHeaders();
@@ -78,11 +84,15 @@ public function send($method, $url, $parameters = [], $files = [], $content = nu
7884
public function setHttpHeader($name, $value)
7985
{
8086
$client = $this->mink->getSession()->getDriver()->getClient();
81-
// Goutte\Client
8287
if (method_exists($client, 'setHeader')) {
88+
/**
89+
* @var \Goutte\Client $client
90+
*/
8391
$client->setHeader($name, $value);
8492
} else {
85-
// Symfony\Component\BrowserKit\Client
93+
/**
94+
* @var \Symfony\Component\BrowserKit\HttpBrowser $client
95+
*/
8696

8797
/* taken from Behat\Mink\Driver\BrowserKitDriver::setRequestHeader */
8898
$contentHeaders = ['CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true];

src/Json/JsonInspector.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ class JsonInspector
1313

1414
public function __construct($evaluationMode)
1515
{
16+
$magicMethods = defined(PropertyAccessor::class.'::DISALLOW_MAGIC_METHODS')
17+
? PropertyAccessor::MAGIC_GET | PropertyAccessor::MAGIC_SET
18+
: false
19+
;
20+
$throwException = defined(PropertyAccessor::class.'::DO_NOT_THROW')
21+
? PropertyAccessor::THROW_ON_INVALID_INDEX | PropertyAccessor::THROW_ON_INVALID_PROPERTY_PATH
22+
: true
23+
;
24+
1625
$this->evaluationMode = $evaluationMode;
17-
$this->accessor = new PropertyAccessor(false, true);
26+
$this->accessor = new PropertyAccessor($magicMethods, $throwException);
1827
}
1928

2029
public function evaluate(Json $json, $expression)

tests/features/rest.feature

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ Feature: Testing RESTContext
9797
Congratulations, you've correctly set up your apache environment.
9898
"""
9999

100-
@>php5.5
100+
Scenario: Accept header should not be set by dfault
101+
When I send a GET request to "/rest/index.php"
102+
Then I should not see "HTTP_ACCEPT"
103+
104+
@>php5.5
101105
Scenario: Set content headers in POST request
102106
When I add "Content-Type" header equal to "xxx"
103107
When I send a "POST" request to "rest/index.php" with body:
File renamed without changes.

tests/fixtures/www/rest/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
You have sent a <?php print $_SERVER['REQUEST_METHOD']; ?> request.
1919

2020
<?php print sizeof($_SERVER); ?> header(s) received.
21-
<?php foreach($_SERVER as $key => $value): ?>
21+
<?php foreach(array_filter($_SERVER) as $key => $value): ?>
2222
<br /><?php print $key ?> : <?php print $value; ?>
2323
<?php endforeach; ?>
2424

0 commit comments

Comments
 (0)