Skip to content

Commit baa3672

Browse files
authored
Add PHPUnit 12 compatibility while maintaining backwards compatibility (#1576)
* Add PHPUnit 12 compatibility while maintaining backwards compatibility - Add PHPUnit 12 to version constraints in composer.json - Update phpstan to support version 2.0 - Update predis to support version 3.0 - Add cacheDirectory attribute for PHPUnit 10+ (ignored by PHPUnit 9) - Keep all existing attributes for backwards compatibility - Update .gitignore to exclude PHPUnit cache directory - No schema reference to avoid validation conflicts between versions This allows the package to work with PHPUnit 9, 10, 11, and 12. * Remove deprecated PHPUnit attributes to fix warnings in PHPUnit 12 Removed the following deprecated attributes that cause warnings in PHPUnit 12: - backupStaticAttributes - convertDeprecationsToExceptions - convertErrorsToExceptions - convertNoticesToExceptions - convertWarningsToExceptions - verbose These attributes are no longer needed and their removal maintains compatibility with PHPUnit 9-12 while eliminating warnings in PHPUnit 12. * Add PHPUnit command-line flags to replace removed XML attributes Add command-line flags to maintain the same test behavior after removing deprecated XML attributes: - --fail-on-risky (replaces failOnRisky attribute) - --fail-on-warning (replaces failOnWarning attribute) - --stop-on-error (replaces stopOnError attribute) - --stop-on-failure (replaces stopOnFailure attribute) - --display-warnings/errors/notices/deprecations (replaces convert* attributes) This ensures tests maintain the same strictness level across all PHPUnit versions. * Fix PHPUnit command-line flags for compatibility Remove non-existent --display-* flags. The convert* XML attributes that were removed actually control PHP error handling, which is handled by PHPUnit's default behavior. Keep only the flags that exist and maintain test strictness.
1 parent 12a018e commit baa3672

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ jobs:
6060
composer update --prefer-dist --no-interaction --no-progress --with="illuminate/contracts:^${{ matrix.laravel }}"
6161
6262
- name: Execute tests
63-
run: vendor/bin/phpunit ${{ matrix.laravel >= 10 && '--display-deprecations --fail-on-deprecation' || '' }}
63+
run: vendor/bin/phpunit --fail-on-risky --fail-on-warning --stop-on-error --stop-on-failure ${{ matrix.laravel >= 10 && '--fail-on-deprecation' || '' }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/phpunit.xml
55
composer.lock
66
.phpunit.result.cache
7+
.phpunit.cache/

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
"require-dev": {
2828
"mockery/mockery": "^1.0",
2929
"orchestra/testbench": "^7.0|^8.0|^9.0|^10.0",
30-
"phpstan/phpstan": "^1.10",
31-
"phpunit/phpunit": "^9.0|^10.4|^11.5",
32-
"predis/predis": "^1.1|^2.0"
30+
"phpstan/phpstan": "^1.10|^2.0",
31+
"phpunit/phpunit": "^9.0|^10.4|^11.5|^12.0",
32+
"predis/predis": "^1.1|^2.0|^3.0"
3333
},
3434
"suggest": {
3535
"ext-redis": "Required to use the Redis PHP driver.",
36-
"predis/predis": "Required when not using the Redis PHP driver (^1.1|^2.0)."
36+
"predis/predis": "Required when not using the Redis PHP driver (^1.1|^2.0|^3.0)."
3737
},
3838
"autoload": {
3939
"psr-4": {

phpunit.xml.dist

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
43
beStrictAboutTestsThatDoNotTestAnything="false"
54
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
66
colors="true"
7-
convertDeprecationsToExceptions="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
117
failOnRisky="true"
128
failOnWarning="true"
139
processIsolation="false"
1410
stopOnError="false"
1511
stopOnFailure="false"
16-
verbose="true"
1712
>
1813
<testsuites>
1914
<testsuite name="Unit">

0 commit comments

Comments
 (0)