Skip to content

Commit 8798d66

Browse files
authored
Merge pull request #158 from alexpott/move-to-github-actions
Move to GitHub Actions and bump minimum PHP to 5.4
2 parents 8a5ca61 + d6bc5a6 commit 8798d66

6 files changed

Lines changed: 102 additions & 72 deletions

File tree

.github/workflows/tests.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
defaults:
8+
run:
9+
shell: bash
10+
11+
jobs:
12+
13+
tests:
14+
name: Tests (PHP ${{ matrix.php }} ${{ matrix.minimum_stability }}, Symfony LTS ${{ matrix.symfony_lts }})
15+
runs-on: ubuntu-20.04
16+
strategy:
17+
matrix:
18+
php: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
19+
minimum_stability: [ 'stable' ]
20+
symfony_lts: [ false ]
21+
include:
22+
- php: '8.0'
23+
minimum_stability: dev
24+
- php: '7.4'
25+
minimum_stability: dev
26+
- php: '7.2'
27+
symfony_lts: '^2'
28+
- php: '7.2'
29+
symfony_lts: '^3'
30+
fail-fast: false
31+
32+
env:
33+
MATRIX_PHP: ${{ matrix.php }}
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 2
40+
41+
- name: Setup PHP
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
coverage: "xdebug"
45+
php-version: "${{ matrix.php }}"
46+
tools: composer
47+
48+
- name: Configure for minimum stability
49+
if: "${{ matrix.minimum_stability == 'dev' }}"
50+
run: |
51+
composer config minimum-stability dev
52+
53+
- name: Configure for Symfony LTS version
54+
if: "${{ matrix.symfony_lts != false }}"
55+
run: |
56+
composer require -n --no-update symfony/lts=${{ matrix.symfony_lts }}
57+
58+
- name: Configure for PHP >= 7.1
59+
if: "${{ matrix.php >= '7.1' && matrix.symfony_lts == false }}"
60+
run: |
61+
composer require --no-update --dev symfony/error-handler "^4.4 || ^5.0"
62+
63+
- name: Install dependencies
64+
run: |
65+
composer update --no-interaction --prefer-dist
66+
67+
- name: Run tests
68+
run: |
69+
vendor/bin/phpunit -v --coverage-clover=coverage.clover
70+
71+
- name: Upload code coverage
72+
if: "${{ matrix.php > '5.4' && matrix.symfony_lts == false }}"
73+
run: |
74+
composer require scrutinizer/ocular
75+
vendor/bin/ocular code-coverage:upload --repository=g/minkphp/MinkBrowserKitDriver --format=php-clover coverage.clover

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor
22
composer.lock
33
/phpunit.xml
4+
.phpunit.result.cache

.travis.yml

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

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616

1717
"require": {
18-
"php": ">=5.3.6",
18+
"php": ">=5.4",
1919
"behat/mink": "^1.7.1@dev",
2020
"symfony/browser-kit": "~2.3|~3.0|~4.0",
2121
"symfony/dom-crawler": "~2.3|~3.0|~4.0"
@@ -24,7 +24,9 @@
2424
"require-dev": {
2525
"mink/driver-testsuite": "dev-master",
2626
"symfony/debug": "^2.7|^3.0|^4.0",
27-
"symfony/http-kernel": "~2.3|~3.0|~4.0"
27+
"symfony/http-kernel": "~2.3|~3.0|~4.0",
28+
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.18 || ^8.5 || ^9.5",
29+
"yoast/phpunit-polyfills": "^1.0"
2830
},
2931

3032
"autoload": {

tests/BrowserKitConfig.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ public function skipMessage($testCase, $test)
4444
'testHtml5FormAction',
4545
'testHtml5FormMethod',
4646
))
47-
&& !method_exists('Symfony\Component\DomCrawler\Tests\FormTest', 'testGetMethodWithOverride')
48-
// Symfony 4.4 removed tests from dist archives, making the previous detection return a false-positive
49-
&& !method_exists('Symfony\Component\DomCrawler\Form', 'getName')
47+
&& !class_exists('\Symfony\Component\DomCrawler\AbstractUriElement')
5048
) {
5149
return 'Mink BrowserKit doesn\'t support HTML5 form attributes before Symfony 3.3';
5250
}

tests/Custom/ErrorHandlingTest.php

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@
66
use PHPUnit\Framework\TestCase;
77
use Symfony\Component\BrowserKit\Client;
88
use Symfony\Component\BrowserKit\Response;
9+
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
910

1011
class ErrorHandlingTest extends TestCase
1112
{
13+
use ExpectException;
14+
1215
/**
1316
* @var TestClient
1417
*/
1518
private $client;
1619

17-
protected function setUp()
20+
/**
21+
* @before
22+
*/
23+
protected function prepareClient()
1824
{
1925
$this->client = new TestClient();
2026
}
@@ -25,50 +31,45 @@ public function testGetClient()
2531
}
2632

2733
/**
28-
* @expectedException \Behat\Mink\Exception\DriverException
29-
* @expectedExceptionMessage Unable to access the response before visiting a page
30-
*
3134
* Looks like we have to mark these tests as "legacy", otherwise we get deprecation errors.
3235
* Although the deprecations are handled, there's no way to avoid the deprecation message here.
3336
* @group legacy
3437
*/
3538
public function testGetResponseHeaderWithoutVisit()
3639
{
40+
$this->expectException('\Behat\Mink\Exception\DriverException');
41+
$this->expectExceptionMessage('Unable to access the response before visiting a page');
3742
$this->getDriver()->getResponseHeaders();
3843
}
3944

4045
/**
41-
* @expectedException \Behat\Mink\Exception\DriverException
42-
* @expectedExceptionMessage Unable to access the response content before visiting a page
43-
*
4446
* Looks like we have to mark these tests as "legacy", otherwise we get deprecation errors.
4547
* Although the deprecations are handled, there's no way to avoid the deprecation message here.
4648
* @group legacy
4749
*/
4850
public function testFindWithoutVisit()
4951
{
52+
$this->expectException('\Behat\Mink\Exception\DriverException');
53+
$this->expectExceptionMessage('Unable to access the response content before visiting a page');
5054
$this->getDriver()->find('//html');
5155
}
5256

5357
/**
54-
* @expectedException \Behat\Mink\Exception\DriverException
55-
* @expectedExceptionMessage Unable to access the request before visiting a page
56-
*
5758
* Looks like we have to mark these tests as "legacy", otherwise we get deprecation errors.
5859
* Although the deprecations are handled, there's no way to avoid the deprecation message here.
5960
* @group legacy
6061
*/
6162
public function testGetCurrentUrlWithoutVisit()
6263
{
64+
$this->expectException('\Behat\Mink\Exception\DriverException');
65+
$this->expectExceptionMessage('Unable to access the request before visiting a page');
6366
$this->getDriver()->getCurrentUrl();
6467
}
6568

66-
/**
67-
* @expectedException \Behat\Mink\Exception\DriverException
68-
* @expectedExceptionMessage The selected node has an invalid form attribute (foo)
69-
*/
7069
public function testNotMatchingHtml5FormId()
7170
{
71+
$this->expectException('\Behat\Mink\Exception\DriverException');
72+
$this->expectExceptionMessage('The selected node has an invalid form attribute (foo)');
7273
$html = <<<'HTML'
7374
<html>
7475
<body>
@@ -87,12 +88,10 @@ public function testNotMatchingHtml5FormId()
8788
$driver->setValue('//input[./@name="test"]', 'bar');
8889
}
8990

90-
/**
91-
* @expectedException \Behat\Mink\Exception\DriverException
92-
* @expectedExceptionMessage The selected node has an invalid form attribute (foo)
93-
*/
9491
public function testInvalidHtml5FormId()
9592
{
93+
$this->expectException('\Behat\Mink\Exception\DriverException');
94+
$this->expectExceptionMessage('The selected node has an invalid form attribute (foo)');
9695
$html = <<<'HTML'
9796
<html>
9897
<body>
@@ -112,12 +111,10 @@ public function testInvalidHtml5FormId()
112111
$driver->setValue('//input[./@name="test"]', 'bar');
113112
}
114113

115-
/**
116-
* @expectedException \Behat\Mink\Exception\DriverException
117-
* @expectedExceptionMessage The selected node does not have a form ancestor.
118-
*/
119114
public function testManipulateInputWithoutForm()
120115
{
116+
$this->expectException('\Behat\Mink\Exception\DriverException');
117+
$this->expectExceptionMessage('The selected node does not have a form ancestor.');
121118
$html = <<<'HTML'
122119
<html>
123120
<body>
@@ -138,12 +135,10 @@ public function testManipulateInputWithoutForm()
138135
$driver->setValue('//input[./@name="test"]', 'bar');
139136
}
140137

141-
/**
142-
* @expectedException \Behat\Mink\Exception\DriverException
143-
* @expectedExceptionMessage Behat\Mink\Driver\BrowserKitDriver supports clicking on links and submit or reset buttons only. But "div" provided
144-
*/
145138
public function testClickOnUnsupportedElement()
146139
{
140+
$this->expectException('\Behat\Mink\Exception\DriverException');
141+
$this->expectExceptionMessage('Behat\Mink\Driver\BrowserKitDriver supports clicking on links and submit or reset buttons only. But "div" provided');
147142
$html = <<<'HTML'
148143
<html>
149144
<body>

0 commit comments

Comments
 (0)