Skip to content

Commit 60fb967

Browse files
authored
Merge pull request #339 from alexpott/move-to-github-actions
Move to GitHub actions
2 parents ce71134 + 11b9cf6 commit 60fb967

File tree

7 files changed

+100
-70
lines changed

7 files changed

+100
-70
lines changed

.github/workflows/tests.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
env:
8+
DRIVER_URL: "http://localhost:4444/wd/hub"
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
16+
tests:
17+
name: Tests
18+
runs-on: ubuntu-20.04
19+
strategy:
20+
matrix:
21+
php: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
22+
fail-fast: false
23+
env:
24+
MATRIX_PHP: ${{ matrix.php }}
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v2
29+
with:
30+
fetch-depth: 1
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
coverage: "none"
36+
php-version: "${{ matrix.php }}"
37+
tools: composer
38+
39+
- name: Configure for PHP >= 7.1
40+
if: "${{ matrix.php >= '7.1' }}"
41+
run: |
42+
composer require --no-update --dev symfony/error-handler "^4.4 || ^5.0"
43+
44+
- name: Install dependencies
45+
run: |
46+
composer update --no-interaction --prefer-dist
47+
48+
- name: Setup Mink test server
49+
run: |
50+
mkdir ./logs
51+
./vendor/bin/mink-test-server &> ./logs/mink-test-server.log &
52+
53+
- name: Start Selenium
54+
run: |
55+
docker run --net host --name selenium --volume /dev/shm:/dev/shm --shm-size 2g selenium/standalone-firefox:2.53.1 &> ./logs/selenium.log &
56+
57+
- name: Wait for browser & PHP to start
58+
run: |
59+
while ! nc -z localhost 4444 </dev/null; do echo Waiting for remote driver to start...; sleep 1; done
60+
while ! nc -z localhost 8002 </dev/null; do echo Waiting for PHP server to start...; sleep 1; done
61+
62+
- name: Run tests
63+
run: |
64+
vendor/bin/phpunit -v
65+
66+
- name: Archive logs artifacts
67+
if: ${{ failure() }}
68+
uses: actions/upload-artifact@v2
69+
with:
70+
name: logs_php-${{ matrix.php }}
71+
path: |
72+
logs

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
logs
12
vendor
23
composer.phar
34
composer.lock
45
phpunit.xml
6+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

tests/Custom/DesiredCapabilitiesTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44

55
use Behat\Mink\Driver\Selenium2Driver;
66
use Behat\Mink\Tests\Driver\TestCase;
7+
use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType;
8+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
79

810
class DesiredCapabilitiesTest extends TestCase
911
{
12+
use AssertIsType;
13+
use ExpectException;
14+
1015
public function testGetDesiredCapabilities()
1116
{
1217
$caps = array(
@@ -23,16 +28,14 @@ public function testGetDesiredCapabilities()
2328

2429
$driver = new Selenium2Driver('firefox', $caps);
2530
$this->assertNotEmpty($driver->getDesiredCapabilities(), 'desiredCapabilities empty');
26-
$this->assertInternalType('array', $driver->getDesiredCapabilities());
31+
$this->assertIsArray($driver->getDesiredCapabilities());
2732
$this->assertEquals($caps, $driver->getDesiredCapabilities());
2833
}
2934

30-
/**
31-
* @expectedException \Behat\Mink\Exception\DriverException
32-
* @expectedExceptionMessage Unable to set desiredCapabilities, the session has already started
33-
*/
3435
public function testSetDesiredCapabilities()
3536
{
37+
$this->expectException('\Behat\Mink\Exception\DriverException');
38+
$this->expectExceptionMessage('Unable to set desiredCapabilities, the session has already started');
3639
$caps = array(
3740
'browserName' => 'firefox',
3841
'version' => '30',

tests/Custom/TimeoutTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
namespace Behat\Mink\Tests\Driver\Custom;
44

55
use Behat\Mink\Tests\Driver\TestCase;
6+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
67

78
class TimeoutTest extends TestCase
89
{
9-
/**
10-
* @expectedException \Behat\Mink\Exception\DriverException
11-
*/
10+
use ExpectException;
11+
1212
public function testInvalidTimeoutSettingThrowsException()
1313
{
14+
$this->expectException('\Behat\Mink\Exception\DriverException');
1415
$this->getSession()->start();
1516

1617
$this->getSession()->getDriver()->setTimeouts(array('invalid' => 0));

tests/Custom/WindowNameTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Behat\Mink\Tests\Driver\Custom;
44

55
use Behat\Mink\Tests\Driver\TestCase;
6+
use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType;
67

78
class WindowNameTest extends TestCase
89
{
10+
use AssertIsType;
11+
912
public function testWindowNames()
1013
{
1114
$session = $this->getSession();
@@ -16,7 +19,7 @@ public function testWindowNames()
1619

1720
$windowName = $session->getWindowName();
1821

19-
$this->assertInternalType('string', $windowName);
22+
$this->assertIsString($windowName);
2023
$this->assertContains($windowName, $windowNames, 'The current window name is one of the available window names.');
2124
}
2225
}

tests/Selenium2Config.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,20 @@ public function skipMessage($testCase, $test)
3737
if (
3838
'Behat\Mink\Tests\Driver\Js\WindowTest' === $testCase
3939
&& (0 === strpos($test, 'testWindowMaximize'))
40-
&& 'true' === getenv('TRAVIS')
40+
&& 'true' === getenv('GITHUB_ACTIONS')
4141
) {
4242
return 'Maximizing the window does not work when running the browser in Xvfb.';
4343
}
4444

45+
if (
46+
'Behat\Mink\Tests\Driver\Basic\NavigationTest' === $testCase
47+
&& (0 === strpos($test, 'testLinks'))
48+
&& 'true' === getenv('GITHUB_ACTIONS')
49+
&& '7.1' === getenv('MATRIX_PHP')
50+
) {
51+
return 'Skipping basic NavigationTest::testLinks on PHP 7.1';
52+
}
53+
4554
return parent::skipMessage($testCase, $test);
4655
}
4756

0 commit comments

Comments
 (0)