From f9901245f19b190c658e064492db00bb4fa5134d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 22 Jul 2025 23:51:32 +0100 Subject: [PATCH] updates dependencies and snapshots --- composer.json | 6 ++--- .../Runner/ResultCache/DefaultResultCache.php | 25 ++++++++----------- src/Mixins/Expectation.php | 2 +- src/Pest.php | 2 +- src/Repositories/SnapshotRepository.php | 4 +-- src/Support/Str.php | 3 ++- ...isual_snapshot_of_help_command_output.snap | 2 +- ...isual_snapshot_of_help_command_output.snap | 2 +- tests/.snapshots/success.txt | 9 ++++++- tests/Visual/Parallel.php | 2 +- 10 files changed, 31 insertions(+), 26 deletions(-) diff --git a/composer.json b/composer.json index 55bd94ee..9144724e 100644 --- a/composer.json +++ b/composer.json @@ -18,19 +18,19 @@ ], "require": { "php": "^8.3.0", - "brianium/paratest": "^7.10.3", + "brianium/paratest": "^7.11.0", "nunomaduro/collision": "^8.8.2", "nunomaduro/termwind": "^2.3.1", "pestphp/pest-plugin": "^4.0.0", "pestphp/pest-plugin-arch": "^4.0.0", "pestphp/pest-plugin-mutate": "^4.0.0", "pestphp/pest-plugin-profanity": "^4.0.0", - "phpunit/phpunit": "^12.2.6", + "phpunit/phpunit": "^12.2.7", "symfony/process": "^7.3.0" }, "conflict": { "filp/whoops": "<2.18.3", - "phpunit/phpunit": ">12.2.6", + "phpunit/phpunit": ">12.2.7", "sebastian/exporter": "<7.0.0", "webmozart/assert": "<1.11.0" }, diff --git a/overrides/Runner/ResultCache/DefaultResultCache.php b/overrides/Runner/ResultCache/DefaultResultCache.php index fde6bad9..7e7f359c 100644 --- a/overrides/Runner/ResultCache/DefaultResultCache.php +++ b/overrides/Runner/ResultCache/DefaultResultCache.php @@ -49,7 +49,7 @@ use const DIRECTORY_SEPARATOR; use const LOCK_EX; use PHPUnit\Framework\TestStatus\TestStatus; -use PHPUnit\Runner\DirectoryCannotBeCreatedException; +use PHPUnit\Runner\DirectoryDoesNotExistException; use PHPUnit\Runner\Exception; use PHPUnit\Util\Filesystem; @@ -72,10 +72,7 @@ use function Pest\version; */ final class DefaultResultCache implements ResultCache { - /** - * @var string - */ - private const DEFAULT_RESULT_CACHE_FILENAME = '.phpunit.result.cache'; + private const string DEFAULT_RESULT_CACHE_FILENAME = '.phpunit.result.cache'; private readonly string $cacheFilename; @@ -98,28 +95,28 @@ final class DefaultResultCache implements ResultCache $this->cacheFilename = $filepath ?? $_ENV['PHPUNIT_RESULT_CACHE'] ?? self::DEFAULT_RESULT_CACHE_FILENAME; } - public function setStatus(string $id, TestStatus $status): void + public function setStatus(ResultCacheId $id, TestStatus $status): void { if ($status->isSuccess()) { return; } - $this->defects[$id] = $status; + $this->defects[$id->asString()] = $status; } - public function status(string $id): TestStatus + public function status(ResultCacheId $id): TestStatus { - return $this->defects[$id] ?? TestStatus::unknown(); + return $this->defects[$id->asString()] ?? TestStatus::unknown(); } - public function setTime(string $id, float $time): void + public function setTime(ResultCacheId $id, float $time): void { - $this->times[$id] = $time; + $this->times[$id->asString()] = $time; } - public function time(string $id): float + public function time(ResultCacheId $id): float { - return $this->times[$id] ?? 0.0; + return $this->times[$id->asString()] ?? 0.0; } public function mergeWith(self $other): void @@ -179,7 +176,7 @@ final class DefaultResultCache implements ResultCache public function persist(): void { if (! Filesystem::createDirectory(dirname($this->cacheFilename))) { - throw new DirectoryCannotBeCreatedException($this->cacheFilename); + throw new DirectoryDoesNotExistException(dirname($this->cacheFilename)); } $data = [ diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 8f806e0e..6ebcb546 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -660,7 +660,7 @@ final class Expectation { foreach ($keys as $k => $key) { if (is_array($key)) { - $this->toHaveKeys(array_keys(Arr::dot($key, $k . '.')), $message); + $this->toHaveKeys(array_keys(Arr::dot($key, $k.'.')), $message); } else { $this->toHaveKey($key, message: $message); } diff --git a/src/Pest.php b/src/Pest.php index 7ddec711..52de2a13 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '4.0.0-alpha.5'; + return '4.0.0-alpha.6'; } function testDirectory(string $file = ''): string diff --git a/src/Repositories/SnapshotRepository.php b/src/Repositories/SnapshotRepository.php index 171fd88f..7f7a9573 100644 --- a/src/Repositories/SnapshotRepository.php +++ b/src/Repositories/SnapshotRepository.php @@ -19,8 +19,8 @@ final class SnapshotRepository * Creates a snapshot repository instance. */ public function __construct( - readonly private string $testsPath, - readonly private string $snapshotsPath, + private readonly string $testsPath, + private readonly string $snapshotsPath, ) {} /** diff --git a/src/Support/Str.php b/src/Support/Str.php index effebabf..e5b78b6d 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -58,7 +58,7 @@ final class Str { $code = str_replace('_', '__', $code); - $code = self::PREFIX . str_replace(' ', '_', $code); + $code = self::PREFIX.str_replace(' ', '_', $code); // sticks to PHP8.2 function naming rules https://www.php.net/manual/en/functions.user-defined.php return (string) preg_replace('/[^a-zA-Z0-9_\x80-\xff]/', '_', $code); @@ -124,6 +124,7 @@ final class Str public static function slugify(string $target): string { $target = preg_replace('/[^a-zA-Z0-9]+/', '-', $target); + return strtolower(trim($target, '-')); } } diff --git a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap index 8a174927..5adc938a 100644 --- a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap @@ -1,5 +1,5 @@ - Pest Testing Framework 4.0.0-alpha.5. + Pest Testing Framework 4.0.0-alpha.6. USAGE: pest [options] diff --git a/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap index f54244da..6c48a1b3 100644 --- a/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Version/visual_snapshot_of_help_command_output.snap @@ -1,3 +1,3 @@ - Pest Testing Framework 4.0.0-alpha.5. + Pest Testing Framework 4.0.0-alpha.6. diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 62bc88b5..ace3b04f 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -628,6 +628,13 @@ ✓ pass ✓ failures ✓ failures with custom message + ✓ not failures + + PASS Tests\Features\Expect\toBeSlug + ✓ pass + ✓ failures + ✓ failures with custom message + ✓ failures with default message ✓ not failures PASS Tests\Features\Expect\toBeSnakeCase @@ -1719,4 +1726,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1149 passed (2742 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1154 passed (2754 assertions) \ No newline at end of file diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 18e9b696..d9cdfbdd 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -16,7 +16,7 @@ $run = function () { test('parallel', function () use ($run) { expect($run('--exclude-group=integration')) - ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 24 skipped, 1139 passed (2718 assertions)') + ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 24 skipped, 1144 passed (2730 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();