mirror of
https://github.com/pestphp/pest.git
synced 2026-03-05 23:37:22 +01:00
TestSuiteLoader will always consider classes from the current file
This commit is contained in:
@ -60,6 +60,11 @@ final class TestSuiteLoader
|
||||
*/
|
||||
private static array $loadedClasses = [];
|
||||
|
||||
/**
|
||||
* @psalm-var array<string, array<class-string>>
|
||||
*/
|
||||
private static array $loadedClassesByFilename = [];
|
||||
|
||||
/**
|
||||
* @psalm-var list<class-string>
|
||||
*/
|
||||
@ -97,6 +102,17 @@ final class TestSuiteLoader
|
||||
|
||||
self::$loadedClasses = array_merge($loadedClasses, self::$loadedClasses);
|
||||
|
||||
foreach ($loadedClasses as $loadedClass) {
|
||||
$reflection = new ReflectionClass($loadedClass);
|
||||
$filename = $reflection->getFileName();
|
||||
self::$loadedClassesByFilename[$filename] = [
|
||||
$loadedClass,
|
||||
...self::$loadedClassesByFilename[$filename] ?? [],
|
||||
];
|
||||
}
|
||||
|
||||
$loadedClasses = array_merge(self::$loadedClassesByFilename[$suiteClassFile] ?? [], $loadedClasses);
|
||||
|
||||
if (empty($loadedClasses)) {
|
||||
return $this->exceptionFor($suiteClassName, $suiteClassFile);
|
||||
}
|
||||
|
||||
@ -1015,9 +1015,15 @@
|
||||
PASS Tests\PHPUnit\CustomAffixes\snakecasespec
|
||||
✓ it runs file names like snake_case_spec.php
|
||||
|
||||
PASS Tests\CustomTestCase\ChildTest
|
||||
✓ override method
|
||||
|
||||
PASS Tests\CustomTestCase\ExecutedTest
|
||||
✓ that gets executed
|
||||
|
||||
PASS Tests\CustomTestCase\ParentTest
|
||||
✓ override method
|
||||
|
||||
PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory
|
||||
✓ closure was bound to CustomTestCase
|
||||
|
||||
@ -1210,4 +1216,4 @@
|
||||
WARN Tests\Visual\Version
|
||||
- visual snapshot of help command output
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 860 passed (1975 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 862 passed (1977 assertions)
|
||||
|
||||
@ -19,7 +19,13 @@
|
||||
↓ something todo later chained
|
||||
↓ something todo later chained and with function body
|
||||
|
||||
PASS Tests\CustomTestCase\ChildTest
|
||||
✓ override method
|
||||
|
||||
PASS Tests\CustomTestCase\ExecutedTest
|
||||
✓ that gets executed
|
||||
|
||||
Tests: 13 todos, 1 passed (1 assertions)
|
||||
PASS Tests\CustomTestCase\ParentTest
|
||||
✓ override method
|
||||
|
||||
Tests: 13 todos, 3 passed (3 assertions)
|
||||
|
||||
13
tests/PHPUnit/CustomTestCase/ChildTest.php
Normal file
13
tests/PHPUnit/CustomTestCase/ChildTest.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\CustomTestCase;
|
||||
|
||||
class ChildTest extends ParentTest
|
||||
{
|
||||
private function getEntity(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
22
tests/PHPUnit/CustomTestCase/ParentTest.php
Normal file
22
tests/PHPUnit/CustomTestCase/ParentTest.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\CustomTestCase;
|
||||
|
||||
use function PHPUnit\Framework\assertTrue;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParentTest extends TestCase
|
||||
{
|
||||
private function getEntity(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function testOverrideMethod(): void
|
||||
{
|
||||
assertTrue($this->getEntity() || true);
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,7 @@ $run = function () {
|
||||
|
||||
test('parallel', function () use ($run) {
|
||||
expect($run('--exclude-group=integration'))
|
||||
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 849 passed (1960 assertions)')
|
||||
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 851 passed (1962 assertions)')
|
||||
->toContain('Parallel: 3 processes');
|
||||
})->skipOnWindows();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user