mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
fix: test suite loader
This commit is contained in:
@ -41,6 +41,7 @@ use function array_values;
|
|||||||
use function basename;
|
use function basename;
|
||||||
use function class_exists;
|
use function class_exists;
|
||||||
use function get_declared_classes;
|
use function get_declared_classes;
|
||||||
|
use Exception;
|
||||||
use Pest\Contracts\HasPrintableTestCaseName;
|
use Pest\Contracts\HasPrintableTestCaseName;
|
||||||
use Pest\TestCases\IgnorableTestCase;
|
use Pest\TestCases\IgnorableTestCase;
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
@ -101,11 +102,27 @@ final class TestSuiteLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
$testCaseFound = false;
|
$testCaseFound = false;
|
||||||
|
$class = false;
|
||||||
|
|
||||||
foreach (array_reverse($loadedClasses) as $loadedClass) {
|
foreach (array_reverse($loadedClasses) as $loadedClass) {
|
||||||
if (is_subclass_of($loadedClass, HasPrintableTestCaseName::class) || is_subclass_of($loadedClass, TestCase::class)) {
|
if (
|
||||||
$suiteClassName = $loadedClass;
|
is_subclass_of($loadedClass, HasPrintableTestCaseName::class)
|
||||||
|
|| is_subclass_of($loadedClass, TestCase::class)) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$class = new ReflectionClass($loadedClass);
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
} catch (ReflectionException) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($class->isAbstract() || ($class->getFileName() !== $suiteClassFile)) {
|
||||||
|
if (! str_contains($class->getFileName(), 'TestCaseFactory.php')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$suiteClassName = $loadedClass;
|
||||||
$testCaseFound = true;
|
$testCaseFound = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -120,12 +137,6 @@ final class TestSuiteLoader
|
|||||||
return $this->exceptionFor($suiteClassName, $suiteClassFile);
|
return $this->exceptionFor($suiteClassName, $suiteClassFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
$class = new ReflectionClass($suiteClassName);
|
|
||||||
// @codeCoverageIgnoreStart
|
|
||||||
} catch (ReflectionException $e) {
|
|
||||||
throw new Exception($e->getMessage(), (int) $e->getCode(), $e);
|
|
||||||
}
|
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
if ($class->isSubclassOf(TestCase::class) && ! $class->isAbstract()) {
|
if ($class->isSubclassOf(TestCase::class) && ! $class->isAbstract()) {
|
||||||
|
|||||||
@ -884,9 +884,9 @@
|
|||||||
✓ it gets property values
|
✓ it gets property values
|
||||||
|
|
||||||
PASS Tests\Unit\Support\Str
|
PASS Tests\Unit\Support\Str
|
||||||
✓ it evaluates the code with ('version()', 'version__')
|
✓ it evaluates the code with ('version()', '__pest_evaluable_version__')
|
||||||
✓ it evaluates the code with ('version__ ', 'version___')
|
✓ it evaluates the code with ('version__ ', '__pest_evaluable_version___')
|
||||||
✓ it evaluates the code with ('version\', 'version_')
|
✓ it evaluates the code with ('version\', '__pest_evaluable_version_')
|
||||||
|
|
||||||
PASS Tests\Unit\TestSuite
|
PASS Tests\Unit\TestSuite
|
||||||
✓ it does not allow to add the same test description twice
|
✓ it does not allow to add the same test description twice
|
||||||
|
|||||||
@ -8,7 +8,7 @@ trait MyCustomTrait
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyCustomClass extends PHPUnit\Framework\TestCase
|
abstract class MyCustomClass extends PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
public function assertTrueIsTrue()
|
public function assertTrueIsTrue()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,5 +14,5 @@ $run = function () {
|
|||||||
|
|
||||||
test('parallel', function () use ($run) {
|
test('parallel', function () use ($run) {
|
||||||
expect($run())->toContain('Running 650 tests using 3 processes')
|
expect($run())->toContain('Running 650 tests using 3 processes')
|
||||||
->toContain('Tests: 4 incomplete, 4 todos, 15 skipped, 627 passed (1546 assertions)');
|
->toContain('Tests: 4 incomplete, 4 todos, 15 skipped, 626 passed (1545 assertions)');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user