Skip to content

Commit 28fb70a

Browse files
committed
Specify branch explicitly; fix Selenium2Driver workflow
1 parent d868dd1 commit 28fb70a

22 files changed

Lines changed: 161 additions & 107 deletions

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
with:
4040
name: ${{ matrix.name }}
4141
driverRepoUrl: ${{ matrix.driverRepoUrl }}
42+
driverRepoBranch: ${{ matrix.driverRepoBranch }}
4243
php: ${{ matrix.php }}
4344
setUpCmd: ${{ matrix.setUpCmd }}
4445
testCmd: ${{ matrix.testCmd }}
@@ -49,18 +50,21 @@ jobs:
4950
include:
5051
- name: "BrowserKit (http client)"
5152
driverRepoUrl: "https://github.com/minkphp/MinkBrowserKitDriver.git"
53+
driverRepoBranch: "master"
5254
php: "7.2"
5355
# language=bash
5456
testCmd: ./vendor/bin/phpunit --colors=always --testdox --configuration ./phpunit.http_client.xml
5557

5658
- name: "BrowserKit (http kernel)"
5759
driverRepoUrl: "https://github.com/minkphp/MinkBrowserKitDriver.git"
60+
driverRepoBranch: "master"
5861
php: "7.2"
5962
# language=bash
6063
testCmd: ./vendor/bin/phpunit --colors=always --testdox
6164

6265
- name: "Selenium2"
6366
driverRepoUrl: "https://github.com/minkphp/MinkSelenium2Driver.git"
67+
driverRepoBranch: "master"
6468
php: "7.2"
6569
# language=bash
6670
setUpCmd: |
@@ -70,6 +74,7 @@ jobs:
7074
# language=bash
7175
testCmd: |
7276
export WEB_FIXTURES_BROWSER=firefox
77+
export SELENIUM_VERSION=2.53.1
7378
export DRIVER_MACHINE_BASE_PATH=/fixtures/
7479
export WEB_FIXTURES_HOST=http://host.docker.internal:8002
7580
./vendor/bin/phpunit --colors=always --testdox
@@ -79,6 +84,7 @@ jobs:
7984
8085
- name: "WebDriver-Classic"
8186
driverRepoUrl: "https://github.com/minkphp/webdriver-classic-driver.git"
87+
driverRepoBranch: "main"
8288
php: "7.4"
8389
# language=bash
8490
setUpCmd: |
@@ -102,6 +108,7 @@ jobs:
102108
with:
103109
name: ${{ matrix.name }}
104110
driverRepoUrl: ${{ matrix.driverRepoUrl }}
111+
driverRepoBranch: ${{ matrix.driverRepoBranch }}
105112
php: ${{ matrix.php }}
106113
setUpCmd: ${{ matrix.setUpCmd }}
107114
testCmd: ${{ matrix.testCmd }}
@@ -112,6 +119,7 @@ jobs:
112119
include:
113120
- name: "Chrome"
114121
driverRepoUrl: "https://gitlab.com/behat-chrome/chrome-mink-driver.git"
122+
driverRepoBranch: "main"
115123
php: "7.4"
116124
# language=bash
117125
setUpCmd: |

.github/workflows/test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
description: Git URL of the driver repository
1010
required: true
1111
type: string
12+
driverRepoBranch:
13+
description: Driver repository branch to check out
14+
required: true
15+
type: string
1216
php:
1317
description: PHP version for running tests
1418
required: true
@@ -32,7 +36,7 @@ jobs:
3236
steps:
3337
- name: Set up workspace for driver repo
3438
# language=bash
35-
run: git clone ${{ inputs.driverRepoUrl }} .
39+
run: git clone --single-branch --branch "${{ inputs.driverRepoBranch }}" "${{ inputs.driverRepoUrl }}" .
3640

3741
- uses: shivammathur/setup-php@v2
3842
with:

http-kernel-fixtures/cookie_page2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<body>
1010
Previous cookie: <?php
1111
/** @var \Symfony\Component\HttpFoundation\Request $request */
12-
echo $request->cookies->has('srvr_cookie') ? html_escape_value($request->cookies->get('srvr_cookie')) : 'NO';
12+
echo $request->cookies->has('srvr_cookie') ? html_escape_value($request->cookies->get('srvr_cookie') ?? '') : 'NO';
1313
?>
1414
</body>
1515
</html>

http-kernel-fixtures/sub-folder/cookie_page1.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
/** @var \Symfony\Component\HttpFoundation\Request $request */
33
$requestUri = $request->server->get('REQUEST_URI');
4+
assert(is_string($requestUri));
45
$resp = new Symfony\Component\HttpFoundation\Response();
56
$cook = Symfony\Component\HttpFoundation\Cookie::create('srvr_cookie', 'srv_var_is_set_sub_folder', 0, dirname($requestUri));
67
$resp->headers->setCookie($cook);

http-kernel-fixtures/sub-folder/cookie_page4.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
/** @var \Symfony\Component\HttpFoundation\Request $request */
33
$resp = new Symfony\Component\HttpFoundation\Response();
4-
$cookiePath = dirname($request->server->get('REQUEST_URI')) . '/';
4+
$requestUri = $request->server->get('REQUEST_URI');
5+
assert(is_string($requestUri));
6+
$cookiePath = dirname($requestUri) . '/';
57
$cookie = Symfony\Component\HttpFoundation\Cookie::create('srvr_cookie', 'srv_var_is_set', 0, $cookiePath);
68
$resp->headers->setCookie($cookie);
79
?>

phpstan.dist.neon

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
parameters:
2-
level: 8
2+
level: 9
33
paths:
44
- src
55
- tests
66
- http-kernel-fixtures
77
- web-fixtures
8-
checkMissingIterableValueType: false
98

109
includes:
1110
- vendor/phpstan/phpstan-phpunit/extension.neon

src/FixturesKernel.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Behat\Mink\Tests\Driver\Util;
44

5+
use Behat\Mink\Tests\Driver\TestCase;
56
use Symfony\Component\HttpFoundation\Cookie;
67
use Symfony\Component\HttpFoundation\Request;
78
use Symfony\Component\HttpFoundation\Response;
@@ -25,8 +26,8 @@ public function handle(Request $request, $type = 1 /* self::MAIN_REQUEST */ , $c
2526

2627
private function handleFixtureRequest(Request $request): Response
2728
{
28-
$fixturesDir = realpath(__DIR__ . '/../web-fixtures');
29-
$overwriteDir = realpath(__DIR__ . '/../http-kernel-fixtures');
29+
$fixturesDir = realpath(TestCase::WEB_FIXTURES_DIR);
30+
$overwriteDir = realpath(TestCase::KERNEL_FIXTURES_DIR);
3031

3132
require_once $fixturesDir . '/utils.php';
3233

@@ -61,7 +62,7 @@ private function prepareSession(Request $request): void
6162
$cookies = $request->cookies;
6263

6364
if ($cookies->has($session->getName())) {
64-
$session->setId($cookies->get($session->getName()));
65+
$session->setId((string) $cookies->get($session->getName()));
6566
} else {
6667
$session->migrate(false);
6768
}

tests/AbstractConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract public function createDriver();
2222
*/
2323
public function mapRemoteFilePath($file)
2424
{
25-
if (!isset($_SERVER['TEST_MACHINE_BASE_PATH']) || !isset($_SERVER['DRIVER_MACHINE_BASE_PATH'])) {
25+
if (!isset($_SERVER['TEST_MACHINE_BASE_PATH'], $_SERVER['DRIVER_MACHINE_BASE_PATH'])) {
2626
return $file;
2727
}
2828

tests/Basic/BasicAuthTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ public function testSetBasicAuth(string $user, string $pass, string $pageText):
2020
$this->assertStringContainsString($pageText, $session->getPage()->getContent());
2121
}
2222

23+
/**
24+
* @return iterable<string, array{string, string, string}>
25+
*/
2326
public static function setBasicAuthDataProvider(): iterable
2427
{
25-
return [
26-
['mink-user', 'mink-password', 'is authenticated'],
27-
['', '', 'is not authenticated'],
28-
];
28+
yield 'valid credentials' => ['mink-user', 'mink-password', 'is authenticated'];
29+
yield 'no credentials' => ['', '', 'is not authenticated'];
2930
}
3031

3132
public function testBasicAuthInUrl(): void

tests/Basic/BestPracticesTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public function testImplementFindXpath(): void
2424
{
2525
$driver = $this->createDriver();
2626

27-
$this->assertNotImplementMethod('find', $driver, 'The driver should overwrite `findElementXpaths` rather than `find` for forward compatibility with Mink 2.');
28-
$this->assertImplementMethod('findElementXpaths', $driver, 'The driver must be able to find elements.');
29-
$this->assertNotImplementMethod('setSession', $driver, 'The driver should not deal with the Session directly for forward compatibility with Mink 2.');
27+
$this->assertMethodIsNotImplemented('find', $driver, 'The driver should overwrite `findElementXpaths` rather than `find` for forward compatibility with Mink 2.');
28+
$this->assertMethodIsImplemented('findElementXpaths', $driver, 'The driver must be able to find elements.');
29+
$this->assertMethodIsNotImplemented('setSession', $driver, 'The driver should not deal with the Session directly for forward compatibility with Mink 2.');
3030
}
3131

3232
/**
@@ -36,9 +36,12 @@ public function testImplementBasicApi(string $method): void
3636
{
3737
$driver = $this->createDriver();
3838

39-
$this->assertImplementMethod($method, $driver, 'The driver is unusable when this method is not implemented.');
39+
$this->assertMethodIsImplemented($method, $driver, 'The driver is unusable when this method is not implemented.');
4040
}
4141

42+
/**
43+
* @return iterable<array{string}>
44+
*/
4245
public static function provideRequiredMethods(): iterable
4346
{
4447
return [
@@ -53,7 +56,7 @@ public static function provideRequiredMethods(): iterable
5356
];
5457
}
5558

56-
private function assertImplementMethod(string $method, object $object, string $reason = ''): void
59+
private function assertMethodIsImplemented(string $method, object $object, string $reason = ''): void
5760
{
5861
$ref = new \ReflectionClass(get_class($object));
5962
$refMethod = $ref->getMethod($method);
@@ -67,7 +70,7 @@ private function assertImplementMethod(string $method, object $object, string $r
6770
$this->assertNotSame(CoreDriver::class, $refMethod->getDeclaringClass()->name, $message);
6871
}
6972

70-
private function assertNotImplementMethod(string $method, object $object, string $reason = ''): void
73+
private function assertMethodIsNotImplemented(string $method, object $object, string $reason = ''): void
7174
{
7275
$ref = new \ReflectionClass(get_class($object));
7376
$refMethod = $ref->getMethod($method);

0 commit comments

Comments
 (0)