Skip to content

Commit

Permalink
Upgrade PHPUnit
Browse files Browse the repository at this point in the history
PHPUnit 9.5 reports deprecations when running on PHP 8.4
  • Loading branch information
martijngastkemper committed Jan 23, 2025
1 parent e95d4f0 commit e0d1d66
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 29 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ jobs:
matrix:
php: [7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, nightly]
stability: [--prefer-lowest, --prefer-stable]
include:
- phpunit: ^10.5
phpunit-config: phpunit.xml
- php: 7.2
phpunit: ^8
phpunit-config: phpunit-8.xml
- php: 7.3
phpunit: ^9
- php: 7.4
phpunit: ^9
- php: 8.0
phpunit: ^9

steps:
- uses: actions/checkout@v4
Expand All @@ -33,15 +45,9 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install PHPUnit 7
id: phpunit-7
if: ${{ matrix.php == '7.2' }}
run: composer require phpunit/phpunit:^7 --no-interaction --no-update
- name: Install PHPUnit ${{ matrix.phpunit }} and the other dependencies
run: |
composer require --dev phpunit/phpunit:${{ matrix.phpunit }} --no-interaction --no-update
composer update ${{ matrix.stability }} --prefer-dist --no-interaction
- name: Install PHPUnit 9
if: ${{ steps.phpunit-7.outcome == 'skipped' }}
run: composer require phpunit/phpunit:^9.5 --no-interaction --no-update

- run: composer update ${{ matrix.stability }} --prefer-dist --no-interaction

- run: ./vendor/bin/phpunit
- run: ./vendor/bin/phpunit --configuration ${{ matrix.phpunit-config }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/vendor/
.DS_Store
.phpunit.result.cache
.phpunit.cache
composer.lock
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"description": "Utility library embracing functional programming paradigms.",
"type": "library",
"require-dev": {
"phpunit/phpunit": "^7.0 | ^9.5",
"squizlabs/php_codesniffer": "^3.5",
"phpstan/phpstan": "^1.10"
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.5"
},
"license": "BSD-3-Clause",
"authors": [
Expand Down
10 changes: 5 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -526,27 +526,27 @@ parameters:
path: tests/PropTest.php

-
message: "#^Method class@anonymous/tests/PropTest\\.php\\:79\\:\\:__get\\(\\) has no return type specified\\.$#"
message: "#^Method class@anonymous/tests/PropTest\\.php\\:78\\:\\:__get\\(\\) has no return type specified\\.$#"
count: 1
path: tests/PropTest.php

-
message: "#^Method class@anonymous/tests/PropTest\\.php\\:79\\:\\:__get\\(\\) has parameter \\$prop with no type specified\\.$#"
message: "#^Method class@anonymous/tests/PropTest\\.php\\:78\\:\\:__get\\(\\) has parameter \\$prop with no type specified\\.$#"
count: 1
path: tests/PropTest.php

-
message: "#^Method class@anonymous/tests/PropTest\\.php\\:79\\:\\:__isset\\(\\) has parameter \\$prop with no type specified\\.$#"
message: "#^Method class@anonymous/tests/PropTest\\.php\\:78\\:\\:__isset\\(\\) has parameter \\$prop with no type specified\\.$#"
count: 1
path: tests/PropTest.php

-
message: "#^Property class@anonymous/tests/PropTest\\.php\\:79\\:\\:\\$_data has no type specified\\.$#"
message: "#^Property class@anonymous/tests/PropTest\\.php\\:78\\:\\:\\$_data has no type specified\\.$#"
count: 1
path: tests/PropTest.php

-
message: "#^Property class@anonymous/tests/PropTest\\.php\\:91\\:\\:\\$_data has no type specified\\.$#"
message: "#^Property class@anonymous/tests/PropTest\\.php\\:90\\:\\:\\$_data has no type specified\\.$#"
count: 1
path: tests/PropTest.php

Expand Down
18 changes: 18 additions & 0 deletions phpunit-8.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" convertWarningsToExceptions="true" convertNoticesToExceptions="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" verbose="true" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">library/Garp/Functional</directory>
</include>
</coverage>
<testsuites>
<testsuite name="unit-tests">
<directory>tests/</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="date.timezone" value="UTC"/>
<ini name="display_errors" value="on"/>
</php>
</phpunit>
12 changes: 6 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" convertWarningsToExceptions="true" convertNoticesToExceptions="true" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" verbose="true" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">library/Garp/Functional</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="unit-tests">
<directory>tests/</directory>
Expand All @@ -15,4 +10,9 @@
<ini name="date.timezone" value="UTC"/>
<ini name="display_errors" value="on"/>
</php>
<source>
<include>
<directory suffix=".php">library/Garp/Functional</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion tests/ContainsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function test_should_be_curried(): void {
$this->assertTrue($containsHello(array('hello', 'world')));
}

public function invalidCollections(): array {
public static function invalidCollections(): array {
return array(
array(100),
array(new stdClass()),
Expand Down
2 changes: 1 addition & 1 deletion tests/IsAssocTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test_should_recognize_associative_arrays($input, bool $result) {
$this->assertSame($result, f\is_assoc($input));
}

public function arrayProvider(): array {
public static function arrayProvider(): array {
return [
[
[1, 2, 3],
Expand Down
3 changes: 1 addition & 2 deletions tests/PropTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use Garp\Functional\Tests\Helpers\MockSpiceTraverser;
use PHPUnit\Framework\TestCase;
use Garp\Functional as f;
use Carbon\Carbon;

/**
* @package Garp\Functional
Expand Down Expand Up @@ -75,7 +74,7 @@ public function test_should_read_magic_prop($result, $prop, $obj) {
);
}

public function magicDataProvider(): array {
public static function magicDataProvider(): array {
$obj = new class {
protected $_data = [
'bar' => '12345'
Expand Down
2 changes: 1 addition & 1 deletion tests/RenameKeysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function test_should_throw_on_invalid_arguments($arg): void {
f\rename_keys($arg, []);
}

public function invalidArgumentProvider(): array {
public static function invalidArgumentProvider(): array {
return array(
array(new stdClass),
array(true),
Expand Down

0 comments on commit e0d1d66

Please sign in to comment.