mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
fix: overrides being used on regular phpunit
This commit is contained in:
@ -27,15 +27,7 @@
|
||||
"psr-4": {
|
||||
"Pest\\": "src/"
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"../phpunit/phpunit/src/Runner/Filter/NameFilterIterator.php",
|
||||
"vendor/phpunit/phpunit/src/Runner/Filter/NameFilterIterator.php",
|
||||
"../phpunit/src/Runner/TestSuiteLoader.php",
|
||||
"vendor/phpunit/phpunit/src/Runner/TestSuiteLoader.php"
|
||||
],
|
||||
"files": [
|
||||
"overrides/Runner/Filter/NameFilterIterator.php",
|
||||
"overrides/Runner/TestSuiteLoader.php",
|
||||
"src/Functions.php",
|
||||
"src/Pest.php"
|
||||
]
|
||||
|
||||
40
src/Bootstrappers/BootOverrides.php
Normal file
40
src/Bootstrappers/BootOverrides.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Bootstrappers;
|
||||
|
||||
use Pest\Contracts\Bootstrapper;
|
||||
use Pest\Exceptions\ShouldNotHappen;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class BootOverrides implements Bootstrapper
|
||||
{
|
||||
/**
|
||||
* The list of files to be overridden.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private const FILES = [
|
||||
'Runner/Filter/NameFilterIterator.php',
|
||||
'Runner/TestSuiteLoader.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* Boots the Subscribers.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
foreach (self::FILES as $file) {
|
||||
$file = __DIR__."/../../overrides/$file";
|
||||
|
||||
if (! file_exists($file)) {
|
||||
throw ShouldNotHappen::fromMessage(sprintf('File [%s] does not exist.', $file));
|
||||
}
|
||||
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,7 @@ final class Kernel
|
||||
* @var array<int, class-string>
|
||||
*/
|
||||
private const BOOTSTRAPPERS = [
|
||||
Bootstrappers\BootOverrides::class,
|
||||
Bootstrappers\BootExceptionHandler::class,
|
||||
Bootstrappers\BootSubscribers::class,
|
||||
Bootstrappers\BootFiles::class,
|
||||
|
||||
@ -12,6 +12,7 @@ use ReflectionException;
|
||||
use ReflectionFunction;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionParameter;
|
||||
use ReflectionProperty;
|
||||
use ReflectionUnionType;
|
||||
|
||||
/**
|
||||
@ -95,7 +96,7 @@ final class Reflection
|
||||
|
||||
$reflectionProperty = null;
|
||||
|
||||
while ($reflectionProperty === null) {
|
||||
while (! $reflectionProperty instanceof ReflectionProperty) {
|
||||
try {
|
||||
/* @var ReflectionProperty $reflectionProperty */
|
||||
$reflectionProperty = $reflectionClass->getProperty($property);
|
||||
@ -127,7 +128,7 @@ final class Reflection
|
||||
|
||||
$reflectionProperty = null;
|
||||
|
||||
while ($reflectionProperty === null) {
|
||||
while (! $reflectionProperty instanceof ReflectionProperty) {
|
||||
try {
|
||||
/* @var ReflectionProperty $reflectionProperty */
|
||||
$reflectionProperty = $reflectionClass->getProperty($property);
|
||||
|
||||
@ -95,7 +95,7 @@ final class TestSuite
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
if (self::$instance === null) {
|
||||
if (! self::$instance instanceof self) {
|
||||
throw new InvalidPestCommand();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user