Skip to content

Commit

Permalink
Merge pull request #339 from alexpott/move-to-github-actions
Browse files Browse the repository at this point in the history
Move to GitHub actions
  • Loading branch information
stof authored Oct 6, 2021
2 parents ce71134 + 11b9cf6 commit 60fb967
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 70 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI

on:
push:
pull_request:

env:
DRIVER_URL: "http://localhost:4444/wd/hub"

defaults:
run:
shell: bash

jobs:

tests:
name: Tests
runs-on: ubuntu-20.04
strategy:
matrix:
php: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
fail-fast: false
env:
MATRIX_PHP: ${{ matrix.php }}

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "${{ matrix.php }}"
tools: composer

- name: Configure for PHP >= 7.1
if: "${{ matrix.php >= '7.1' }}"
run: |
composer require --no-update --dev symfony/error-handler "^4.4 || ^5.0"
- name: Install dependencies
run: |
composer update --no-interaction --prefer-dist
- name: Setup Mink test server
run: |
mkdir ./logs
./vendor/bin/mink-test-server &> ./logs/mink-test-server.log &
- name: Start Selenium
run: |
docker run --net host --name selenium --volume /dev/shm:/dev/shm --shm-size 2g selenium/standalone-firefox:2.53.1 &> ./logs/selenium.log &
- name: Wait for browser & PHP to start
run: |
while ! nc -z localhost 4444 </dev/null; do echo Waiting for remote driver to start...; sleep 1; done
while ! nc -z localhost 8002 </dev/null; do echo Waiting for PHP server to start...; sleep 1; done
- name: Run tests
run: |
vendor/bin/phpunit -v
- name: Archive logs artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: logs_php-${{ matrix.php }}
path: |
logs
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
logs
vendor
composer.phar
composer.lock
phpunit.xml
.phpunit.result.cache
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

13 changes: 8 additions & 5 deletions tests/Custom/DesiredCapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Tests\Driver\TestCase;
use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;

class DesiredCapabilitiesTest extends TestCase
{
use AssertIsType;
use ExpectException;

public function testGetDesiredCapabilities()
{
$caps = array(
Expand All @@ -23,16 +28,14 @@ public function testGetDesiredCapabilities()

$driver = new Selenium2Driver('firefox', $caps);
$this->assertNotEmpty($driver->getDesiredCapabilities(), 'desiredCapabilities empty');
$this->assertInternalType('array', $driver->getDesiredCapabilities());
$this->assertIsArray($driver->getDesiredCapabilities());
$this->assertEquals($caps, $driver->getDesiredCapabilities());
}

/**
* @expectedException \Behat\Mink\Exception\DriverException
* @expectedExceptionMessage Unable to set desiredCapabilities, the session has already started
*/
public function testSetDesiredCapabilities()
{
$this->expectException('\Behat\Mink\Exception\DriverException');
$this->expectExceptionMessage('Unable to set desiredCapabilities, the session has already started');
$caps = array(
'browserName' => 'firefox',
'version' => '30',
Expand Down
7 changes: 4 additions & 3 deletions tests/Custom/TimeoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
namespace Behat\Mink\Tests\Driver\Custom;

use Behat\Mink\Tests\Driver\TestCase;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;

class TimeoutTest extends TestCase
{
/**
* @expectedException \Behat\Mink\Exception\DriverException
*/
use ExpectException;

public function testInvalidTimeoutSettingThrowsException()
{
$this->expectException('\Behat\Mink\Exception\DriverException');
$this->getSession()->start();

$this->getSession()->getDriver()->setTimeouts(array('invalid' => 0));
Expand Down
5 changes: 4 additions & 1 deletion tests/Custom/WindowNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
namespace Behat\Mink\Tests\Driver\Custom;

use Behat\Mink\Tests\Driver\TestCase;
use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType;

class WindowNameTest extends TestCase
{
use AssertIsType;

public function testWindowNames()
{
$session = $this->getSession();
Expand All @@ -16,7 +19,7 @@ public function testWindowNames()

$windowName = $session->getWindowName();

$this->assertInternalType('string', $windowName);
$this->assertIsString($windowName);
$this->assertContains($windowName, $windowNames, 'The current window name is one of the available window names.');
}
}
11 changes: 10 additions & 1 deletion tests/Selenium2Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,20 @@ public function skipMessage($testCase, $test)
if (
'Behat\Mink\Tests\Driver\Js\WindowTest' === $testCase
&& (0 === strpos($test, 'testWindowMaximize'))
&& 'true' === getenv('TRAVIS')
&& 'true' === getenv('GITHUB_ACTIONS')
) {
return 'Maximizing the window does not work when running the browser in Xvfb.';
}

if (
'Behat\Mink\Tests\Driver\Basic\NavigationTest' === $testCase
&& (0 === strpos($test, 'testLinks'))
&& 'true' === getenv('GITHUB_ACTIONS')
&& '7.1' === getenv('MATRIX_PHP')
) {
return 'Skipping basic NavigationTest::testLinks on PHP 7.1';
}

return parent::skipMessage($testCase, $test);
}

Expand Down

0 comments on commit 60fb967

Please sign in to comment.