Skip to content

Commit

Permalink
Adds PHPUnit 10 support (#1023)
Browse files Browse the repository at this point in the history
* PHPUnit 10 Supports

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

* Re-use GHA job

* wip

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: Dries Vints <[email protected]>
  • Loading branch information
crynobone and driesvints authored Feb 6, 2023
1 parent 74615cf commit 4ac4cae
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
.styleci.yml export-ignore
CHANGELOG.md export-ignore
phpunit.xml.dist export-ignore
phpunit9.xml.dist export-ignore
UPGRADE.md export-ignore
13 changes: 11 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
exclude:
- php: '8.0'
laravel: 10
- php: '8.0'
phpunit: 10
- laravel: 9
phpunit: 10

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - PHPUnit ${{ matrix.phpunit }}

Expand All @@ -44,7 +48,12 @@ jobs:
composer update --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: vendor/bin/phpunit --verbose
if: matrix.phpunit == '9'
run: vendor/bin/phpunit -c phpunit9.xml.dist --verbose

- name: Execute tests
if: matrix.phpunit != '9'
run: vendor/bin/phpunit -c phpunit.xml.dist

stub-tests:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -82,7 +91,7 @@ jobs:
run: |
composer update "laravel/dusk" --prefer-dist --no-interaction --no-progress -W
php artisan dusk:install
- name: Update Chrome Driver
run: php artisan dusk:chrome-driver --detect

Expand Down
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
chromedriver-*
LICENSE.chromedriver
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"require-dev": {
"mockery/mockery": "^1.4.2",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^9.5.10|^10.0.1",
"orchestra/testbench": "^7.0|^8.0"
},
"suggest": {
Expand Down
13 changes: 6 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="vendor/autoload.php"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Laravel Dusk Test Suite">
Expand Down
23 changes: 23 additions & 0 deletions phpunit9.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="vendor/autoload.php"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="Laravel Dusk Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
</phpunit>
7 changes: 6 additions & 1 deletion src/Concerns/ProvidesBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Exception;
use Illuminate\Support\Collection;
use Laravel\Dusk\Browser;
use PHPUnit\Runner\Version;
use ReflectionFunction;
use Throwable;

Expand Down Expand Up @@ -227,7 +228,11 @@ protected function createWebDriver()
*/
protected function getCallerName()
{
return str_replace('\\', '_', get_class($this)).'_'.$this->getName(false);
$name = version_compare(Version::id(), '10', '>=')
? $this->name()
: $this->getName(false);

return str_replace('\\', '_', get_class($this)).'_'.$name;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Concerns/InteractsWithElementsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InteractsWithElementsTest extends TestCase
/** @var RemoteWebDriver|MockObject */
protected $driver;

public function dataProviderValueWithValue()
public static function dataProviderValueWithValue()
{
return [
['#nuff', 'narf', 'document.querySelector("#nuff").value = "narf";'],
Expand Down
2 changes: 1 addition & 1 deletion tests/ProvidesBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function test_store_console_logs_for()
$this->storeConsoleLogsFor($browsers);
}

public function testData()
public static function testData()
{
return [
['foo'],
Expand Down

0 comments on commit 4ac4cae

Please sign in to comment.