Compare commits

..

6 Commits

Author SHA1 Message Date
e3a21384e6 release: v2.12.2 2023-08-07 10:29:25 +01:00
331381eed5 release: v2.12.1 2023-08-07 10:26:55 +01:00
75a7d77a80 Updates snapshots 2023-08-07 10:22:58 +01:00
cc242a50d1 chore: bump dependencies 2023-08-07 09:39:13 +01:00
704acbf6de Merge pull request #898 from dylanbr/allow_tests_to_be_extended
TestSuiteLoader will always consider classes from the current file
2023-08-06 22:59:52 +00:00
7baa48e068 TestSuiteLoader will always consider classes from the current file 2023-08-05 13:06:00 +02:00
11 changed files with 76 additions and 7 deletions

View File

@ -2,6 +2,12 @@
## Unreleased ## Unreleased
## [v2.12.2 (2023-08-07)](https://github.com/pestphp/pest/compare/v2.12.0...v2.12.2)
### Fixed
- Running tests from `uses` parent class ([#898](https://github.com/pestphp/pest/pull/898))
## [v2.12.0 (2023-08-02)](https://github.com/pestphp/pest/compare/v2.11.0...v2.12.0) ## [v2.12.0 (2023-08-02)](https://github.com/pestphp/pest/compare/v2.11.0...v2.12.0)
### Added ### Added

View File

@ -19,7 +19,7 @@
"require": { "require": {
"php": "^8.1.0", "php": "^8.1.0",
"brianium/paratest": "^7.2.4", "brianium/paratest": "^7.2.4",
"nunomaduro/collision": "^7.8.0", "nunomaduro/collision": "^7.8.1",
"nunomaduro/termwind": "^1.15.1", "nunomaduro/termwind": "^1.15.1",
"pestphp/pest-plugin": "^2.0.1", "pestphp/pest-plugin": "^2.0.1",
"pestphp/pest-plugin-arch": "^2.2.3", "pestphp/pest-plugin-arch": "^2.2.3",

View File

@ -60,6 +60,11 @@ final class TestSuiteLoader
*/ */
private static array $loadedClasses = []; private static array $loadedClasses = [];
/**
* @psalm-var array<string, array<class-string>>
*/
private static array $loadedClassesByFilename = [];
/** /**
* @psalm-var list<class-string> * @psalm-var list<class-string>
*/ */
@ -97,6 +102,17 @@ final class TestSuiteLoader
self::$loadedClasses = array_merge($loadedClasses, self::$loadedClasses); 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)) { if (empty($loadedClasses)) {
return $this->exceptionFor($suiteClassName, $suiteClassFile); return $this->exceptionFor($suiteClassName, $suiteClassFile);
} }

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string function version(): string
{ {
return '2.12.0'; return '2.12.2';
} }
function testDirectory(string $file = ''): string function testDirectory(string $file = ''): string

View File

@ -1,5 +1,5 @@
Pest Testing Framework 2.12.0. Pest Testing Framework 2.12.2.
USAGE: pest <file> [options] USAGE: pest <file> [options]

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.12.0. Pest Testing Framework 2.12.2.

View File

@ -1015,9 +1015,15 @@
PASS Tests\PHPUnit\CustomAffixes\snakecasespec PASS Tests\PHPUnit\CustomAffixes\snakecasespec
✓ it runs file names like snake_case_spec.php ✓ it runs file names like snake_case_spec.php
PASS Tests\CustomTestCase\ChildTest
✓ override method
PASS Tests\CustomTestCase\ExecutedTest PASS Tests\CustomTestCase\ExecutedTest
✓ that gets executed ✓ that gets executed
PASS Tests\CustomTestCase\ParentTest
✓ override method
PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory PASS Tests\PHPUnit\CustomTestCase\UsesPerDirectory
✓ closure was bound to CustomTestCase ✓ closure was bound to CustomTestCase
@ -1210,4 +1216,4 @@
WARN Tests\Visual\Version WARN Tests\Visual\Version
- visual snapshot of help command output - 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)

View File

@ -19,7 +19,13 @@
↓ something todo later chained ↓ something todo later chained
↓ something todo later chained and with function body ↓ something todo later chained and with function body
PASS Tests\CustomTestCase\ChildTest
✓ override method
PASS Tests\CustomTestCase\ExecutedTest PASS Tests\CustomTestCase\ExecutedTest
✓ that gets executed ✓ that gets executed
Tests: 13 todos, 1 passed (1 assertions) PASS Tests\CustomTestCase\ParentTest
✓ override method
Tests: 13 todos, 3 passed (3 assertions)

View File

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Tests\CustomTestCase;
class ChildTest extends ParentTest
{
private function getEntity(): bool
{
return true;
}
}

View 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);
}
}

View File

@ -16,7 +16,7 @@ $run = function () {
test('parallel', function () use ($run) { test('parallel', function () use ($run) {
expect($run('--exclude-group=integration')) 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'); ->toContain('Parallel: 3 processes');
})->skipOnWindows(); })->skipOnWindows();