-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the collision printer with PHPUnit 10 (#539)
- Loading branch information
mantle-ci
committed
Apr 23, 2024
1 parent
0cd499a
commit 0aa5218
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Testkit autoload file | ||
* | ||
* @package Mantle | ||
*/ | ||
|
||
use NunoMaduro\Collision\Adapters\Phpunit\Subscribers\EnsurePrinterIsRegisteredSubscriber; | ||
use PHPUnit\Event\Facade as PHPUnitFacade; | ||
use PHPUnit\Runner\Version; | ||
|
||
/** | ||
* Register the collision printer for PHPUnit 10. | ||
* | ||
* Due to a change in the collision package, the printer must be registered | ||
* manually unless the test suite is manually invoked by the code base (which | ||
* most projects do not use). | ||
* | ||
* The printer code is largely private and not intended to be used by external | ||
* code, so we need to carefully check for the existence of the classes and | ||
* methods we need to use. | ||
*/ | ||
if ( | ||
class_exists( Version::class ) | ||
&& version_compare( Version::id(), '10.0.0', '>=' ) | ||
&& empty( getenv( 'COLLISION_DISABLE' ) ) // A kill switch for disabling the printer. | ||
&& class_exists( PHPUnitFacade::class ) | ||
&& class_exists( EnsurePrinterIsRegisteredSubscriber::class ) | ||
&& method_exists( PHPUnitFacade::class, 'registerSubscriber' ) | ||
) { | ||
PHPUnitFacade::instance()->registerSubscriber( new EnsurePrinterIsRegisteredSubscriber() ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,11 @@ | |
} | ||
} | ||
}, | ||
"autoload": { | ||
"files": [ | ||
"autoload.php" | ||
] | ||
}, | ||
"license": "GPL-2.0-or-later", | ||
"authors": [ | ||
{ | ||
|