Compare commits

...

4 Commits

Author SHA1 Message Date
nuno maduro 2c7cc1dc87 fix: static callable datasets 2026-08-13 18:38:27 +01:00
Lazizbek Ergashev 9b36f44b3e fix(tia): include the PHP minor version in the fingerprint (#1860) 2026-08-13 16:16:15 +01:00
Lazizbek Ergashev 2e58918201 fix(tia): treat a test skipped from a hook as finished (#1863) 2026-08-13 16:15:45 +01:00
nuno maduro a8d4770c0b chore: fix version 2026-08-12 15:37:18 +01:00
10 changed files with 62 additions and 9 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ namespace Pest;
function version(): string function version(): string
{ {
return '5.0.5'; return '5.1.1';
} }
function testDirectory(string $file = ''): string function testDirectory(string $file = ''): string
+1 -1
View File
@@ -40,7 +40,7 @@ final readonly class Fingerprint
'js_config' => self::jsConfigHash($projectRoot), 'js_config' => self::jsConfigHash($projectRoot),
], ],
'environmental' => [ 'environmental' => [
'php_minor' => PHP_MAJOR_VERSION, 'php_minor' => PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION,
], ],
]; ];
+1 -1
View File
@@ -117,7 +117,7 @@ final class ResultCollector
public function hasUnfinishedTest(): bool public function hasUnfinishedTest(): bool
{ {
return $this->currentTestId !== null; return $this->currentTestId !== null && ! isset($this->results[$this->currentTestId]);
} }
public function recordAssertions(string $testId, int $assertions): void public function recordAssertions(string $testId, int $assertions): void
+1 -1
View File
@@ -141,7 +141,7 @@ final class DatasetsRepository
$datasets[$index] = self::getScopedDataset($data, $currentTestFile); $datasets[$index] = self::getScopedDataset($data, $currentTestFile);
} }
if (is_callable($datasets[$index])) { if (! is_array($datasets[$index]) && is_callable($datasets[$index])) {
$datasets[$index] = call_user_func($datasets[$index]); $datasets[$index] = call_user_func($datasets[$index]);
} }
@@ -1,5 +1,5 @@
Pest Testing Framework 5.0.5. Pest Testing Framework 5.1.1.
USAGE: pest <file> [options] USAGE: pest <file> [options]
@@ -1,3 +1,3 @@
Pest Testing Framework 5.0.5. Pest Testing Framework 5.1.1.
+2 -1
View File
@@ -1764,6 +1764,7 @@
✓ it shows the correct description for long texts with newlines ✓ it shows the correct description for long texts with newlines
✓ it shows the correct description for arrays with many elements ✓ it shows the correct description for arrays with many elements
✓ it shows the correct description of datasets with html ✓ it shows the correct description of datasets with html
✓ it does not treat a two element dataset of class names as a callable
PASS Tests\Unit\Expectations\OppositeExpectation PASS Tests\Unit\Expectations\OppositeExpectation
✓ it throw expectation failed exception with string argument ✓ it throw expectation failed exception with string argument
@@ -2225,4 +2226,4 @@
✓ pass with dataset with ('my-datas-set-value') ✓ pass with dataset with ('my-datas-set-value')
✓ within describe → pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value')
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1572 passed (3413 assertions) Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1573 passed (3414 assertions)
@@ -33,6 +33,34 @@ test('a complete run prunes a deleted test', function (array $arguments): void {
->and($delta->structureMoved())->toBeFalse($delta->summary()); ->and($delta->structureMoved())->toBeFalse($delta->summary());
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows(); })->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
test('a complete run stays complete when the last test is skipped from a hook', function (array $arguments): void {
$project = Project::make('master');
$project->seed('master');
$project->write('tests/Unit/GreeterTest.php', <<<'PHP'
<?php
declare(strict_types=1);
use Fixture\App\Greeter;
beforeEach(function (): void {
test()->markTestSkipped('not today');
});
test('greets a person', function (): void {
expect((new Greeter)->greet('Nuno'))->toBe('Hello, Nuno!');
});
PHP);
$result = $project->pest(...$arguments);
$delta = $project->delta();
expect($result->tally())->toContain('1 skipped')
->and($delta->removed())->toBe(1, $delta->summary())
->and($delta->added())->toBe(0, $delta->summary());
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
test('a complete run records nothing for a test file the graph does not know', function (): void { test('a complete run records nothing for a test file the graph does not know', function (): void {
$project = Project::make('master'); $project = Project::make('master');
$project->seed('master'); $project->seed('master');
+24
View File
@@ -109,3 +109,27 @@ it('shows the correct description of datasets with html', function (): void {
expect($descriptions[0])->toBe('(\'<div class="flex items-center"></div>\')'); expect($descriptions[0])->toBe('(\'<div class="flex items-center"></div>\')');
}); });
it('does not treat a two element dataset of class names as a callable', function (): void {
$datasets = DatasetsRepository::resolve([
[
MagicCallDataset::class,
AnotherMagicCallDataset::class,
],
], __FILE__);
expect(array_values($datasets))->toBe([
[MagicCallDataset::class],
[AnotherMagicCallDataset::class],
]);
});
class MagicCallDataset
{
public static function __callStatic(string $name, array $arguments): void
{
throw new RuntimeException('This dataset should not be called.');
}
}
class AnotherMagicCallDataset {}
+2 -2
View File
@@ -26,13 +26,13 @@ test('parallel', function () use ($run): void {
$file = file_get_contents(__FILE__); $file = file_get_contents(__FILE__);
$file = preg_replace( $file = preg_replace(
'/\$expected = \'.*?\';/', '/\$expected = \'.*?\';/',
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1554 passed (3358 assertions)';", "\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1555 passed (3359 assertions)';",
$file, $file,
); );
file_put_contents(__FILE__, $file); file_put_contents(__FILE__, $file);
} }
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1554 passed (3358 assertions)'; $expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1555 passed (3359 assertions)';
expect($output) expect($output)
->toContain("Tests: {$expected}") ->toContain("Tests: {$expected}")