From 840364891ce1ceeadc6ce15ea8b065903cfc188b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sat, 18 Mar 2023 23:19:20 +0000 Subject: [PATCH 01/53] fix: prepares for nightly phpunit release --- src/Bootstrappers/BootSubscribers.php | 8 +++++--- src/Logging/TeamCity/TeamCityLogger.php | 10 ++++++++-- src/Plugins/Parallel/Paratest/WrapperRunner.php | 7 ++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Bootstrappers/BootSubscribers.php b/src/Bootstrappers/BootSubscribers.php index 1a5a6c74..387ee958 100644 --- a/src/Bootstrappers/BootSubscribers.php +++ b/src/Bootstrappers/BootSubscribers.php @@ -46,9 +46,11 @@ final class BootSubscribers implements Bootstrapper assert($instance instanceof Subscriber); - Event\Facade::registerSubscriber( - $instance - ); + if (method_exists(Event\Facade::class, 'instance')) { // @phpstan-ignore-line + Event\Facade::instance()->registerSubscriber($instance); + } else { + Event\Facade::registerSubscriber($instance); // @phpstan-ignore-line + } } } } diff --git a/src/Logging/TeamCity/TeamCityLogger.php b/src/Logging/TeamCity/TeamCityLogger.php index 85994a84..d89fcd9e 100644 --- a/src/Logging/TeamCity/TeamCityLogger.php +++ b/src/Logging/TeamCity/TeamCityLogger.php @@ -224,7 +224,7 @@ final class TeamCityLogger */ private function registerSubscribers(): void { - Facade::registerSubscribers( + $subscribers = [ new TestSuiteStartedSubscriber($this), new TestSuiteFinishedSubscriber($this), new TestPreparedSubscriber($this), @@ -235,7 +235,13 @@ final class TeamCityLogger new TestSkippedSubscriber($this), new TestConsideredRiskySubscriber($this), new TestExecutionFinishedSubscriber($this), - ); + ]; + + if (method_exists(Facade::class, 'instance')) { // @phpstan-ignore-line + Facade::instance()->registerSubscribers(...$subscribers); + } else { + Facade::registerSubscribers(...$subscribers); // @phpstan-ignore-line + } } private function setFlowId(): void diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 5c3bf2e4..7647c87e 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -114,7 +114,12 @@ final class WrapperRunner implements RunnerInterface ExcludeList::addDirectory($directory); TestResultFacade::init(); - EventFacade::seal(); + + if (method_exists(EventFacade::class, 'instance')) { // @phpstan-ignore-line + EventFacade::instance()->seal(); + } else { + EventFacade::seal(); // @phpstan-ignore-line + } $suiteLoader = new SuiteLoader($this->options, $this->output, $this->codeCoverageFilterRegistry); $this->pending = $this->getTestFiles($suiteLoader); From d4c66d73a03587cef645cecd7839a3fa89e2a27e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sat, 18 Mar 2023 23:35:05 +0000 Subject: [PATCH 02/53] chore: static checks --- rector.php | 5 +++++ src/Bootstrappers/BootSubscribers.php | 6 +----- src/Logging/TeamCity/TeamCityLogger.php | 7 ++----- src/Plugins/Parallel/Paratest/WrapperRunner.php | 10 ++++------ 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/rector.php b/rector.php index 589b8cd0..04ea7e2c 100644 --- a/rector.php +++ b/rector.php @@ -4,6 +4,7 @@ declare(strict_types=1); use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; +use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; @@ -16,6 +17,10 @@ return static function (RectorConfig $rectorConfig): void { InlineConstructorDefaultToPropertyRector::class, ]); + $rectorConfig->skip([ + RemoveExtraParametersRector::class, + ]); + $rectorConfig->sets([ LevelSetList::UP_TO_PHP_81, SetList::CODE_QUALITY, diff --git a/src/Bootstrappers/BootSubscribers.php b/src/Bootstrappers/BootSubscribers.php index 387ee958..c38b873b 100644 --- a/src/Bootstrappers/BootSubscribers.php +++ b/src/Bootstrappers/BootSubscribers.php @@ -46,11 +46,7 @@ final class BootSubscribers implements Bootstrapper assert($instance instanceof Subscriber); - if (method_exists(Event\Facade::class, 'instance')) { // @phpstan-ignore-line - Event\Facade::instance()->registerSubscriber($instance); - } else { - Event\Facade::registerSubscriber($instance); // @phpstan-ignore-line - } + method_exists(Event\Facade::class, 'instance') ? Event\Facade::instance()->registerSubscriber($instance) : Event\Facade::registerSubscriber($instance); // @phpstan-ignore-line } } } diff --git a/src/Logging/TeamCity/TeamCityLogger.php b/src/Logging/TeamCity/TeamCityLogger.php index d89fcd9e..0394d058 100644 --- a/src/Logging/TeamCity/TeamCityLogger.php +++ b/src/Logging/TeamCity/TeamCityLogger.php @@ -237,11 +237,8 @@ final class TeamCityLogger new TestExecutionFinishedSubscriber($this), ]; - if (method_exists(Facade::class, 'instance')) { // @phpstan-ignore-line - Facade::instance()->registerSubscribers(...$subscribers); - } else { - Facade::registerSubscribers(...$subscribers); // @phpstan-ignore-line - } + // @phpstan-ignore-next-line + method_exists(Facade::class, 'instance') ? Facade::instance()->registerSubscribers(...$subscribers) : Facade::registerSubscribers(...$subscribers); } private function setFlowId(): void diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 7647c87e..37eb7634 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -115,11 +115,8 @@ final class WrapperRunner implements RunnerInterface TestResultFacade::init(); - if (method_exists(EventFacade::class, 'instance')) { // @phpstan-ignore-line - EventFacade::instance()->seal(); - } else { - EventFacade::seal(); // @phpstan-ignore-line - } + // @phpstan-ignore-next-line + method_exists(EventFacade::class, 'instance') ? EventFacade::instance()->seal() : EventFacade::seal(); $suiteLoader = new SuiteLoader($this->options, $this->output, $this->codeCoverageFilterRegistry); $this->pending = $this->getTestFiles($suiteLoader); @@ -359,7 +356,8 @@ final class WrapperRunner implements RunnerInterface } $coverageManager = new CodeCoverage(); - $coverageManager->init($this->options->configuration, $this->codeCoverageFilterRegistry); + + $coverageManager->init($this->options->configuration, $this->codeCoverageFilterRegistry, true); $coverageMerger = new CoverageMerger($coverageManager->codeCoverage()); foreach ($this->coverageFiles as $coverageFile) { $coverageMerger->addCoverageFromFile($coverageFile); From aafdf6f39c5122a6c3488304376b15b23c4e17a2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sat, 18 Mar 2023 23:48:01 +0000 Subject: [PATCH 03/53] chore: improves static checking --- rector.php | 3 +-- src/Plugins/Parallel/Paratest/WrapperRunner.php | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rector.php b/rector.php index 04ea7e2c..1a2f4483 100644 --- a/rector.php +++ b/rector.php @@ -4,7 +4,6 @@ declare(strict_types=1); use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; -use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; @@ -18,7 +17,7 @@ return static function (RectorConfig $rectorConfig): void { ]); $rectorConfig->skip([ - RemoveExtraParametersRector::class, + __DIR__.'/src/Plugins/Parallel/Paratest/WrapperRunner.php', ]); $rectorConfig->sets([ diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 37eb7634..78764ce9 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -357,7 +357,9 @@ final class WrapperRunner implements RunnerInterface $coverageManager = new CodeCoverage(); - $coverageManager->init($this->options->configuration, $this->codeCoverageFilterRegistry, true); + // @phpstan-ignore-next-line + is_bool(true) && $coverageManager->init($this->options->configuration, $this->codeCoverageFilterRegistry, true); + $coverageMerger = new CoverageMerger($coverageManager->codeCoverage()); foreach ($this->coverageFiles as $coverageFile) { $coverageMerger->addCoverageFromFile($coverageFile); From 084f7c596f597885b47577f45ad9891391256cb0 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 00:41:41 +0000 Subject: [PATCH 04/53] feat: improves `--bail` --- src/Plugins/Bail.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Plugins/Bail.php b/src/Plugins/Bail.php index 2920a97a..d82bd2f6 100644 --- a/src/Plugins/Bail.php +++ b/src/Plugins/Bail.php @@ -22,7 +22,8 @@ final class Bail implements HandlesArguments if ($this->hasArgument('--bail', $arguments)) { $arguments = $this->popArgument('--bail', $arguments); - $arguments = $this->pushArgument('--stop-on-defect', $arguments); + $arguments = $this->pushArgument('--stop-on-failure', $arguments); + $arguments = $this->pushArgument('--stop-on-error', $arguments); } return $arguments; From 48ea48981b3bfd727936fcc7da266daca0f86255 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 00:49:06 +0000 Subject: [PATCH 05/53] fix: todos flag --- bin/pest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pest b/bin/pest index 43663978..d169f852 100755 --- a/bin/pest +++ b/bin/pest @@ -38,7 +38,7 @@ use Symfony\Component\Console\Output\ConsoleOutput; unset($args[$key]); } - if ($value === '--todo') { + if ($value === '--todos') { $todo = true; unset($args[$key]); } From 2da899a2b15bf69c87f8db45ba66a09b38343212 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 02:01:08 +0000 Subject: [PATCH 06/53] fix: `--todos` in parallel and feedback on process isolation --- bin/pest | 11 ++++++++--- composer.json | 1 + src/Plugins/Parallel.php | 2 +- src/Plugins/ProcessIsolation.php | 28 ++++++++++++++++++++++++++++ tests/Visual/Todo.php | 4 ++-- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 src/Plugins/ProcessIsolation.php diff --git a/bin/pest b/bin/pest index d169f852..8de2b9de 100755 --- a/bin/pest +++ b/bin/pest @@ -3,6 +3,7 @@ use Pest\ConfigLoader; use Pest\Kernel; +use Pest\Panic; use Pest\TestCaseFilters\GitDirtyTestCaseFilter; use Pest\TestCaseMethodFilters\TodoTestCaseFilter; use Pest\TestSuite; @@ -85,11 +86,15 @@ use Symfony\Component\Console\Output\ConsoleOutput; $output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, $isDecorated); - $kernel = Kernel::boot($testSuite, $input, $output); + try { + $kernel = Kernel::boot($testSuite, $input, $output); - $result = $kernel->handle($args); + $result = $kernel->handle($args); - $kernel->shutdown(); + $kernel->shutdown(); + } catch (Throwable|Error $e) { + Panic::with($e); + } exit($result); })(); diff --git a/composer.json b/composer.json index ceebf09c..d531b48c 100644 --- a/composer.json +++ b/composer.json @@ -94,6 +94,7 @@ "Pest\\Plugins\\Help", "Pest\\Plugins\\Memory", "Pest\\Plugins\\Printer", + "Pest\\Plugins\\ProcessIsolation", "Pest\\Plugins\\Retry", "Pest\\Plugins\\Version", "Pest\\Plugins\\Parallel" diff --git a/src/Plugins/Parallel.php b/src/Plugins/Parallel.php index b85227d1..8f53801a 100644 --- a/src/Plugins/Parallel.php +++ b/src/Plugins/Parallel.php @@ -32,7 +32,7 @@ final class Parallel implements HandlesArguments /** * @var string[] */ - private const UNSUPPORTED_ARGUMENTS = ['--todo', '--retry']; + private const UNSUPPORTED_ARGUMENTS = ['--todos', '--retry']; /** * Whether the given command line arguments indicate that the test suite should be run in parallel. diff --git a/src/Plugins/ProcessIsolation.php b/src/Plugins/ProcessIsolation.php new file mode 100644 index 00000000..bf454b65 --- /dev/null +++ b/src/Plugins/ProcessIsolation.php @@ -0,0 +1,28 @@ +hasArgument('--process-isolation', $arguments)) { + throw new InvalidOption('The [--process-isolation] option is not supported.'); + } + + return $arguments; + } +} diff --git a/tests/Visual/Todo.php b/tests/Visual/Todo.php index 3a396a21..edf1bb4e 100644 --- a/tests/Visual/Todo.php +++ b/tests/Visual/Todo.php @@ -25,9 +25,9 @@ $snapshot = function ($name) { }; test('todo', function () use ($run, $snapshot) { - expect($run('--todo', false))->toContain($snapshot('todo')); + expect($run('--todos', false))->toContain($snapshot('todo')); })->skip(PHP_OS_FAMILY === 'Windows'); test('todo in parallel', function () use ($run, $snapshot) { - expect($run('--todo', true))->toContain($snapshot('todo')); + expect($run('--todos', true))->toContain($snapshot('todo')); })->skip(PHP_OS_FAMILY === 'Windows'); From 085d3436c851d522140bd13abb8c1044d4f69080 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 03:38:20 +0000 Subject: [PATCH 07/53] fix: detection of dirty files --- src/TestCaseFilters/GitDirtyTestCaseFilter.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TestCaseFilters/GitDirtyTestCaseFilter.php b/src/TestCaseFilters/GitDirtyTestCaseFilter.php index c38e49c7..4164694d 100644 --- a/src/TestCaseFilters/GitDirtyTestCaseFilter.php +++ b/src/TestCaseFilters/GitDirtyTestCaseFilter.php @@ -62,7 +62,10 @@ final class GitDirtyTestCaseFilter implements TestCaseFilter $dirtyFiles = array_map(fn ($file, $status): string => in_array($status, ['R', 'RM'], true) ? explode(' -> ', $file)[1] : $file, array_keys($dirtyFiles), $dirtyFiles); - $dirtyFiles = array_filter($dirtyFiles, fn ($file): bool => str_starts_with('.'.DIRECTORY_SEPARATOR.$file, TestSuite::getInstance()->testPath)); + $dirtyFiles = array_filter( + $dirtyFiles, + fn ($file): bool => str_starts_with('.'.DIRECTORY_SEPARATOR.$file, TestSuite::getInstance()->testPath) || str_starts_with($file, TestSuite::getInstance()->testPath) + ); $dirtyFiles = array_values($dirtyFiles); From d96ddaeaac597afa6a9b2ade4cd4740d62d518a6 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 03:51:27 +0000 Subject: [PATCH 08/53] feat: clarifies that profile is not supported in parallel --- composer.json | 1 + src/Plugins/Profile.php | 28 ++++++++++++++++++++++++++++ src/Plugins/Retry.php | 1 - 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/Plugins/Profile.php diff --git a/composer.json b/composer.json index d531b48c..6515d1f7 100644 --- a/composer.json +++ b/composer.json @@ -95,6 +95,7 @@ "Pest\\Plugins\\Memory", "Pest\\Plugins\\Printer", "Pest\\Plugins\\ProcessIsolation", + "Pest\\Plugins\\Profile", "Pest\\Plugins\\Retry", "Pest\\Plugins\\Version", "Pest\\Plugins\\Parallel" diff --git a/src/Plugins/Profile.php b/src/Plugins/Profile.php new file mode 100644 index 00000000..e29a7fc1 --- /dev/null +++ b/src/Plugins/Profile.php @@ -0,0 +1,28 @@ +hasArgument('--parallel', $arguments)) { + throw new InvalidOption('The [--profile] option is not supported when running in parallel.'); + } + + return $arguments; + } +} diff --git a/src/Plugins/Retry.php b/src/Plugins/Retry.php index 94b703e1..f5199381 100644 --- a/src/Plugins/Retry.php +++ b/src/Plugins/Retry.php @@ -23,7 +23,6 @@ final class Retry implements HandlesArguments return $arguments; } - // If running in parallel, we need to disable the retry plugin if ($this->hasArgument('--parallel', $arguments)) { throw new InvalidOption('The [--retry] option is not supported when running in parallel.'); } From 7287d658650a44de97090c8d54726388743b8203 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 03:58:04 +0000 Subject: [PATCH 09/53] chore: runs nightly builds against `10.0.x-dev` --- .github/workflows/nightly-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml index a55aa47d..506316fd 100644 --- a/.github/workflows/nightly-tests.yml +++ b/.github/workflows/nightly-tests.yml @@ -13,7 +13,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] php: ['8.1'] - phpunit-branch: [main] + phpunit-branch: [10.0.x-dev] name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.phpunit-branch }} @@ -33,8 +33,8 @@ jobs: echo "::add-matcher::${{ runner.tool_cache }}/php.json" echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Install PHP dependencies with phpunit/phpunit:dev-${{ matrix.phpunit-branch }} - run: composer require phpunit/phpunit:dev-${{ matrix.phpunit-branch }} --ansi --no-interaction --no-progress + - name: Install PHP dependencies with phpunit/phpunit:${{ matrix.phpunit-branch }} + run: composer require phpunit/phpunit:${{ matrix.phpunit-branch }} --ansi --no-interaction --no-progress - name: Unit Tests run: composer test:unit From ccfcd336fe067a02a203ec86fec5a056c27905be Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 04:00:10 +0000 Subject: [PATCH 10/53] fix: profile plugin --- src/Plugins/Profile.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Plugins/Profile.php b/src/Plugins/Profile.php index e29a7fc1..0f723a2c 100644 --- a/src/Plugins/Profile.php +++ b/src/Plugins/Profile.php @@ -19,6 +19,10 @@ final class Profile implements HandlesArguments */ public function handleArguments(array $arguments): array { + if (! $this->hasArgument('--profile', $arguments)) { + return $arguments; + } + if ($this->hasArgument('--parallel', $arguments)) { throw new InvalidOption('The [--profile] option is not supported when running in parallel.'); } From 961e0aec6630ffc5244442aa7f0dd9d784ca8900 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 15:40:53 +0000 Subject: [PATCH 11/53] feat: removes non used subscriber --- src/Bootstrappers/BootSubscribers.php | 1 - src/Exceptions/AttributeNotSupportedYet.php | 24 ----------------- .../EnsureConfigurationIsValid.php | 27 ------------------- 3 files changed, 52 deletions(-) delete mode 100644 src/Exceptions/AttributeNotSupportedYet.php delete mode 100644 src/Subscribers/EnsureConfigurationIsValid.php diff --git a/src/Bootstrappers/BootSubscribers.php b/src/Bootstrappers/BootSubscribers.php index c38b873b..8a2df311 100644 --- a/src/Bootstrappers/BootSubscribers.php +++ b/src/Bootstrappers/BootSubscribers.php @@ -21,7 +21,6 @@ final class BootSubscribers implements Bootstrapper * @var array> */ private const SUBSCRIBERS = [ - Subscribers\EnsureConfigurationIsValid::class, Subscribers\EnsureConfigurationIsAvailable::class, Subscribers\EnsureIgnorableTestCasesAreIgnored::class, Subscribers\EnsureKernelDumpIsFlushed::class, diff --git a/src/Exceptions/AttributeNotSupportedYet.php b/src/Exceptions/AttributeNotSupportedYet.php deleted file mode 100644 index d34262f6..00000000 --- a/src/Exceptions/AttributeNotSupportedYet.php +++ /dev/null @@ -1,24 +0,0 @@ -configuration(); - - if ($configuration->processIsolation()) { - throw new AttributeNotSupportedYet('processIsolation', 'true'); - } - } -} From 7a57f9f9b8403b27aef1ad23d3ec4ff609c94137 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 16:45:43 +0000 Subject: [PATCH 12/53] chore: incrementally supports PHPUnit patch versions --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6515d1f7..603fc045 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "phpunit/phpunit": "^10.0.16" }, "conflict": { - "webmozart/assert": "<1.11.0" + "webmozart/assert": "<1.11.0", + "phpunit/phpunit": ">10.0.16" }, "version": "2.x-dev", "autoload": { From 7e1c769d1c880322a20d5c5d90a11cd65b63fdbd Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 16:45:49 +0000 Subject: [PATCH 13/53] Delete nightly-tests.yml --- .github/workflows/nightly-tests.yml | 47 ----------------------------- 1 file changed, 47 deletions(-) delete mode 100644 .github/workflows/nightly-tests.yml diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml deleted file mode 100644 index 506316fd..00000000 --- a/.github/workflows/nightly-tests.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Nightly Tests - -on: - push: - pull_request: - schedule: - - cron: '0 */12 * * *' - -jobs: - ci: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - php: ['8.1'] - phpunit-branch: [10.0.x-dev] - - name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.phpunit-branch }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: composer:v2 - coverage: none - - - name: Setup Problem Matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Install PHP dependencies with phpunit/phpunit:${{ matrix.phpunit-branch }} - run: composer require phpunit/phpunit:${{ matrix.phpunit-branch }} --ansi --no-interaction --no-progress - - - name: Unit Tests - run: composer test:unit - - - name: Unit Tests in Parallel - run: composer test:parallel - if: startsWith(matrix.os, 'windows') != true - - - name: Integration Tests - run: composer test:integration From 4db2318a66213520b86d32bbd2b6b757d3afc257 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 17:09:49 +0000 Subject: [PATCH 14/53] chore: specifies stable version of Collision --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 603fc045..6184f729 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": "^8.1.0", "brianium/paratest": "^7.1.1", - "nunomaduro/collision": "v7.x-dev", + "nunomaduro/collision": "^7.2.0", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.0", "pestphp/pest-plugin-arch": "^2.0.0", From 54fd1882997e17fb46a38a2666642d5c476ef63b Mon Sep 17 00:00:00 2001 From: faissaloux Date: Sun, 19 Mar 2023 17:46:49 +0000 Subject: [PATCH 15/53] fix test Case Name starts with a P --- src/Concerns/Testable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index e6e44488..170d2e6e 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -277,7 +277,7 @@ trait Testable */ public static function getPrintableTestCaseName(): string { - return ltrim(self::class, 'P\\'); + return preg_replace('/P\\\/', '', self::class, 1); } /** From 88e047bd279add63b92d0fa19345087ae6d631f2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 18:34:20 +0000 Subject: [PATCH 16/53] tests: for test names starting with P --- tests/.snapshots/success.txt | 9 ++++++++- tests/Unit/TestName.php | 13 +++++++++++++ tests/Visual/Parallel.php | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/Unit/TestName.php diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 7dbe9326..82345dd7 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -910,6 +910,13 @@ ✓ it evaluates the code with ('version__ ', '__pest_evaluable_version___') ✓ it evaluates the code with ('version\', '__pest_evaluable_version_') + PASS Tests\Unit\TestName + ✓ it may start with P with ('P\Tests\BarTest', 'Tests\BarTest') + ✓ it may start with P with ('P\Packages\Foo', 'Packages\Foo') + ✓ it may start with P with ('P\PPPackages\Foo', 'PPPackages\Foo') + ✓ it may start with P with ('PPPackages\Foo', 'PPPackages\Foo') #1 + ✓ it may start with P with ('PPPackages\Foo', 'PPPackages\Foo') #2 + PASS Tests\Unit\TestSuite ✓ it does not allow to add the same test description twice ✓ it alerts users about tests with arguments but no input @@ -943,4 +950,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 18 skipped, 644 passed (1586 assertions) \ No newline at end of file + Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 18 skipped, 649 passed (1591 assertions) \ No newline at end of file diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php new file mode 100644 index 00000000..3f52e700 --- /dev/null +++ b/tests/Unit/TestName.php @@ -0,0 +1,13 @@ +toBe($toBePrinted); +})->with([ + ['P\Tests\BarTest', 'Tests\BarTest'], + ['P\Packages\Foo', 'Packages\Foo'], + ['P\PPPackages\Foo', 'PPPackages\Foo'], + ['PPPackages\Foo', 'PPPackages\Foo'], + ['PPPackages\Foo', 'PPPackages\Foo'], +]); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index a5a9d844..237345d7 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -15,6 +15,6 @@ $run = function () { }; test('parallel', function () use ($run) { - expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 15 skipped, 635 passed (1573 assertions)') + expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 15 skipped, 640 passed (1578 assertions)') ->toContain('Parallel: 3 processes'); })->skip(PHP_OS_FAMILY === 'Windows'); From 2fb86903201a6d080671b93416b7897c06aff95a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 19 Mar 2023 23:15:14 +0000 Subject: [PATCH 17/53] docs: updates changelog --- CHANGELOG.md | 342 +-------------------------------------------------- 1 file changed, 3 insertions(+), 339 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aad205b0..bdccbd93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,343 +1,7 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). +# Release Notes for 2.x ## Unreleased -### Added -- Custom failure messages on expectations ([https://github.com/pestphp/pest/pull/583](https://github.com/pestphp/pest/pull/583)) +## [v2.0.0 (2023-03-20)](https://github.com/pestphp/pest/compare/v1.22.6...v2.0.0) -## [v1.20.0 (2021-09-25)](https://github.com/pestphp/pest/compare/v1.19.0...v1.20.0) -### Added -- `throwsIf` test call ([#371](https://github.com/pestphp/pest/pull/371)) -- `--ci` CLI option to ignore development options like `->local()` ([#405](https://github.com/pestphp/pest/pull/405)) -- `when` conditional expectation ([#406](https://github.com/pestphp/pest/pull/406)) -- `unless` conditional expectation ([b43a598](https://github.com/pestphp/pest/commit/b43a59868d5b790a28cbb29c6110c9f068b0b812)) -- `match` conditional expectation ([#407](https://github.com/pestphp/pest/pull/407)) - -### Fixed -- `sequence` with more expectations than iterable elements ([#399](https://github.com/pestphp/pest/pull/399)) - -## [v1.19.0 (2021-09-20)](https://github.com/pestphp/pest/compare/v1.18.0...v1.19.0) -### Added -- PHP 8.1 support ([e6c7d68](https://github.com/pestphp/pest/commit/e6c7d68defaec8efe01e71e15dd8d8c45b0cf60f)) -- `toHaveProperties` expectation ([#391](https://github.com/pestphp/pest/pull/391)) - -## [v1.18.0 (2021-08-30)](https://github.com/pestphp/pest/compare/v1.17.0...v1.18.0) -### Added -- `toHaveLength` expectation ([#386](https://github.com/pestphp/pest/pull/386)) -- `nunomaduro/collision:^6.0` support ([4ae482c](https://github.com/pestphp/pest/commit/4ae482c7073fb77782b8a4b5738ef1fcea0f82ab)) - -## [v1.17.0 (2021-08-26)](https://github.com/pestphp/pest/compare/v1.16.0...v1.17.0) -### Added -- `toThrow` expectation ([#361](https://github.com/pestphp/pest/pull/361)) - -## [v1.16.0 (2021-08-19)](https://github.com/pestphp/pest/compare/v1.15.0...v1.16.0) -### Added -- Support for new parallel options ([#369](https://github.com/pestphp/pest/pull/369)) - -## [v1.15.0 (2021-08-04)](https://github.com/pestphp/pest/compare/v1.14.0...v1.15.0) -### Added -- `toBeTruthy` and `toBeFalsy` ([#367](https://github.com/pestphp/pest/pull/367)) - -## [v1.14.0 (2021-08-03)](https://github.com/pestphp/pest/compare/v1.13.0...v1.14.0) -### Added -- A new bound closure that allows you to access the test case in Datasets ([#364](https://github.com/pestphp/pest/pull/364)) - -## [v1.13.0 (2021-08-02)](https://github.com/pestphp/pest/compare/v1.12.0...v1.13.0) -### Added -- A cleaner output when running the Pest runner in PhpStorm ([#350](https://github.com/pestphp/pest/pull/350)) -- `toBeIn` expectation ([#363](https://github.com/pestphp/pest/pull/363)) - -### Fixed -- `skip` with false condition marking test as skipped ([22b822c](https://github.com/pestphp/pest/commit/22b822ce87a3d19d84960fa5c93eb286820b525d)) - -## [v1.12.0 (2021-07-26)](https://github.com/pestphp/pest/compare/v1.11.0...v1.12.0) -### Added -- `--force` option to override tests in `pest:test` artisan command ([#353](https://github.com/pestphp/pest/pull/353)) -- Support for PHPUnit `^9.3.7` ([ca9d783](https://github.com/pestphp/pest/commit/ca9d783cf942a2caabc85ff7a728c7f28350c67a)) - -### Fixed -- `beforeAll` and `afterAll` behind called multiple times per test ([#357](https://github.com/pestphp/pest/pull/357)) - -## [v1.11.0 (2021-07-21)](https://github.com/pestphp/pest/compare/v1.10.0...v1.11.0) -### Added -- Support for interacting with datasets in higher order tests ([#352](https://github.com/pestphp/pest/pull/352)) - -### Changed -- The unit test stub now uses the expectation API ([#348](https://github.com/pestphp/pest/pull/348)) - -### Fixed -- PhpStorm will no longer show 0 assertions in the output ([#349](https://github.com/pestphp/pest/pull/349)) - -## [v1.10.0 (2021-07-12)](https://github.com/pestphp/pest/compare/v1.9.1...v1.10.0) -### Added -- The ability to use higher order expectations inside higher order tests ([#341](https://github.com/pestphp/pest/pull/341)) - -## [v1.9.1 (2021-07-11)](https://github.com/pestphp/pest/compare/v1.9.0...v1.9.1) -### Fixed -- Callable `expect` values in higher order tests failing if the value was an existing method name ([#334](https://github.com/pestphp/pest/pull/344)) - -## [v1.9.0 (2021-07-09)](https://github.com/pestphp/pest/compare/v1.8.0...v1.9.0) -### Changed -- You may now pass just an exception message when using the `throws` method ([#339](https://github.com/pestphp/pest/pull/339)) - -## [v1.8.0 (2021-07-08)](https://github.com/pestphp/pest/compare/v1.7.1...v1.8.0) -### Added -- A new `tap` and test case aware `expect` methods for higher order tests ([#331](https://github.com/pestphp/pest/pull/331)) -- Access to test case methods and properties when using `skip` ([#338](https://github.com/pestphp/pest/pull/338)) - -## [v1.7.1 (2021-06-24)](https://github.com/pestphp/pest/compare/v1.7.0...v1.7.1) -### Fixed -- The `and` method not being usable in Higher Order expectations ([#330](https://github.com/pestphp/pest/pull/330)) - -## [v1.7.0 (2021-06-19)](https://github.com/pestphp/pest/compare/v1.6.0...v1.7.0) -### Added -- Support for non-callable values in the sequence method, which will be passed as `toEqual` ([#323](https://github.com/pestphp/pest/pull/323)) -- Support for nested Higher Order Expectations ([#324](https://github.com/pestphp/pest/pull/324)) - -## [v1.6.0 (2021-06-18)](https://github.com/pestphp/pest/compare/v1.5.0...v1.6.0) -### Added -- Adds a new `json` expectation method to improve testing with JSON strings ([#325](https://github.com/pestphp/pest/pull/325)) -- Adds dot notation support to the `toHaveKey` and `toHaveKeys` expectations ([#322](https://github.com/pestphp/pest/pull/322)) - -## [v1.5.0 (2021-06-15)](https://github.com/pestphp/pest/compare/v1.4.0...v1.5.0) -### Changed -- Moves plugins from the `require` section to the core itself ([#317](https://github.com/pestphp/pest/pull/317)), ([#318](https://github.com/pestphp/pest/pull/318)), ([#320](https://github.com/pestphp/pest/pull/320)) - -## [v1.4.0 (2021-06-10)](https://github.com/pestphp/pest/compare/v1.3.2...v1.4.0) -### Added -- Support for multiple datasets (Matrix) on the `with` method ([#303](https://github.com/pestphp/pest/pull/303)) -- Support for incompleted tests ([49de462](https://github.com/pestphp/pest/commit/49de462250cf9f65f09e13eaf6dcc0e06865b930)) - -## [v1.3.2 (2021-06-07)](https://github.com/pestphp/pest/compare/v1.3.1...v1.3.2) -### Fixed -- Test cases with the @ symbol in the directory fail ([#308](https://github.com/pestphp/pest/pull/308)) - -## [v1.3.1 (2021-06-06)](https://github.com/pestphp/pest/compare/v1.3.0...v1.3.1) -### Added -- Added for PHPUnit 9.5.5 ([#310](https://github.com/pestphp/pest/pull/310)) - -### Changed -- Lock minimum Pest plugin versions ([#306](https://github.com/pestphp/pest/pull/306)) - -## [v1.3.0 (2021-05-23)](https://github.com/pestphp/pest/compare/v1.2.1...v1.3.0) -### Added -- Named datasets no longer show the arguments ([#302](https://github.com/pestphp/pest/pull/302)) - -### Fixed -- Wraps global functions within `function_exists` ([#300](https://github.com/pestphp/pest/pull/300)) - -## [v1.2.1 (2021-05-14)](https://github.com/pestphp/pest/compare/v1.2.0...v1.2.1) -### Fixed -- Laravel commands failing with new `--test-directory` option ([#297](https://github.com/pestphp/pest/pull/297)) - -## [v1.2.0 (2021-05-13)](https://github.com/pestphp/pest/compare/v1.1.0...v1.2.0) -### Added -- Adds JUnit / Infection support ([#291](https://github.com/pestphp/pest/pull/291)) -- `--test-directory` command line option ([#283](https://github.com/pestphp/pest/pull/283)) - -## [v1.1.0 (2021-05-02)](https://github.com/pestphp/pest/compare/v1.0.5...v1.1.0) -### Added -- Possibility of "hooks" being added using the "uses" function ([#282](https://github.com/pestphp/pest/pull/282)) - -## [v1.0.5 (2021-03-31)](https://github.com/pestphp/pest/compare/v1.0.4...v1.0.5) -### Added -- Add `--browse` option to `pest:dusk` command ([#280](https://github.com/pestphp/pest/pull/280)) -- Support for PHPUnit 9.5.4 ([#284](https://github.com/pestphp/pest/pull/284)) - -## [v1.0.4 (2021-03-17)](https://github.com/pestphp/pest/compare/v1.0.3...v1.0.4) -### Added -- Support for PHPUnit 9.5.3 ([#278](https://github.com/pestphp/pest/pull/278)) - -## [v1.0.3 (2021-03-13)](https://github.com/pestphp/pest/compare/v1.0.2...v1.0.3) -### Added -- Support for test extensions ([#269](https://github.com/pestphp/pest/pull/269)) - -## [v1.0.2 (2021-02-04)](https://github.com/pestphp/pest/compare/v1.0.1...v1.0.2) -### Added -- Support for PHPUnit 9.5.2 ([#267](https://github.com/pestphp/pest/pull/267)) - -## [v1.0.1 (2021-01-18)](https://github.com/pestphp/pest/compare/v1.0.0...v1.0.1) -### Added -- Support for PHPUnit 9.5.1 ([#261](https://github.com/pestphp/pest/pull/261)) - -### Fixed -- Fix `TestCase@expect` PHPDoc tag ([#251](https://github.com/pestphp/pest/pull/251)) - -## [v1.0.0 (2021-01-03)](https://github.com/pestphp/pest/compare/v0.3.19...v1.0.0) -### Added -- `pest:test --dusk` option ([#245](https://github.com/pestphp/pest/pull/245)) - -### Changed -- Stable version -- Updates init structure ([#240](https://github.com/pestphp/pest/pull/240)) - -## [v0.3.19 (2020-12-27)](https://github.com/pestphp/pest/compare/v0.3.18...v0.3.19) -### Fixed -- Fix binary path in `pest:dusk` command ([#239](https://github.com/pestphp/pest/pull/239)) - -## [v0.3.18 (2020-12-26)](https://github.com/pestphp/pest/compare/v0.3.17...v0.3.18) -### Added -- `toBeJson()` expectation ([plugin-expectations#2](https://github.com/pestphp/pest-plugin-expectations/pull/2)) - -## [v0.3.17 (2020-12-20)](https://github.com/pestphp/pest/compare/v0.3.16...v0.3.17) -### Fixed -- Class inheritance with `depends()` ([#236](https://github.com/pestphp/pest/pull/236)) - -## [v0.3.16 (2020-12-13)](https://github.com/pestphp/pest/compare/v0.3.15...v0.3.16) -### Changed -- Moves expectation API for external plugin ([5d7f262](https://github.com/pestphp/pest/commit/5d7f262f4ab280a660a85900f402eebb23abfda8)) - -## [v0.3.15 (2020-12-04)](https://github.com/pestphp/pest/compare/v0.3.14...v0.3.15) -### Added -- Support for PHPUnit 9.5.0 ([#234](https://github.com/pestphp/pest/pull/234)) -- Support for extending expectation API ([#232](https://github.com/pestphp/pest/pull/232)) - -### Fixed -- Static analysis while using string as key for datasets ([#233](https://github.com/pestphp/pest/pull/233)) - -## [v0.3.14 (2020-11-28)](https://github.com/pestphp/pest/compare/v0.3.13...v0.3.14) -### Added -- `pest:dusk` command ([#223](https://github.com/pestphp/pest/pull/223)) -- Better feedback on errors in `toMatchArray` and `toMatchObject` ([#231](https://github.com/pestphp/pest/pull/231)) - -## [v0.3.13 (2020-11-23)](https://github.com/pestphp/pest/compare/v0.3.12...v0.3.13) -### Added -- `toMatchArray` expectation ([7bea51f](https://github.com/pestphp/pest/commit/7bea51fe09dd2eca7093e4c34cf2dab2e8d39fa5), [3fd24d9](https://github.com/pestphp/pest/commit/3fd24d96d3145dcebdb0aab40aa8b76faa8b6979)) -- Add Pest options to `--help` output ([#217](https://github.com/pestphp/pest/pull/217)) - -### Fixed -- Resolve issue with name resolution in `depends()` ([#216](https://github.com/pestphp/pest/pull/216)) - -## [v0.3.12 (2020-11-11)](https://github.com/pestphp/pest/compare/v0.3.11...v0.3.12) -### Added -- Add support for PHPUnit 9.4.3 ([#219](https://github.com/pestphp/pest/pull/219)) - -## [v0.3.11 (2020-11-09)](https://github.com/pestphp/pest/compare/v0.3.10...v0.3.11) -### Changed -- Improved the exception output for the TeamCity printer (usage with phpstorm plugin) ([#215](https://github.com/pestphp/pest/pull/215)) - -## [v0.3.10 (2020-11-01)](https://github.com/pestphp/pest/compare/v0.3.9...v0.3.10) -### Added -- Add support for PHPUnit 9.4.2 ([d177ab5](https://github.com/pestphp/pest/commit/d177ab5ec2030c5bb8e418d10834c370c94c433d)) - -## [v0.3.9 (2020-10-13)](https://github.com/pestphp/pest/compare/v0.3.8...v0.3.9) -### Added -- Add support for named datasets in description output ([#134](https://github.com/pestphp/pest/pull/134)) -- Add Pest version to `--help` output ([#203](https://github.com/pestphp/pest/pull/203)) -- Add support for PHPUnit 9.4.1 ([#207](https://github.com/pestphp/pest/pull/207)) - -## [v0.3.8 (2020-10-03)](https://github.com/pestphp/pest/compare/v0.3.7...v0.3.8) -### Added -- Add support for PHPUnit 9.4.0 ([#199](https://github.com/pestphp/pest/pull/199)) - -### Fixed -- Fix chained higher order assertions returning void ([#196](https://github.com/pestphp/pest/pull/196)) - -## [v0.3.7 (2020-09-30)](https://github.com/pestphp/pest/compare/v0.3.6...v0.3.7) -### Added -- Add support for PHPUnit 9.3.11 ([#193](https://github.com/pestphp/pest/pull/193)) - -## [v0.3.6 (2020-09-21)](https://github.com/pestphp/pest/compare/v0.3.5...v0.3.6) -### Added -- `toMatch` expectation ([#191](https://github.com/pestphp/pest/pull/191)) -- `toMatchConstraint` expectation ([#190](https://github.com/pestphp/pest/pull/190)) - -## [v0.3.5 (2020-09-16)](https://github.com/pestphp/pest/compare/v0.3.4...v0.3.5) -### Added -- `toStartWith` and `toEndWith` expectations ([#187](https://github.com/pestphp/pest/pull/187)) - -## [v0.3.4 (2020-09-15)](https://github.com/pestphp/pest/compare/v0.3.3...v0.3.4) -### Added -- `toMatchObject` expectation ([4e184b2](https://github.com/pestphp/pest/commit/4e184b2f906c318a5e9cd38fe693cdab5c48d8a2)) - -## [v0.3.3 (2020-09-13)](https://github.com/pestphp/pest/compare/v0.3.2...v0.3.3) -### Added -- `toHaveKeys` expectation ([204f343](https://github.com/pestphp/pest/commit/204f343831adc17bb3734553c24fac92d02f27c7)) - -## [v0.3.2 (2020-09-12)](https://github.com/pestphp/pest/compare/v0.3.1...v0.3.2) -### Added -- Support to PHPUnit 9.3.9, and 9.3.10 ([1318bf9](https://github.com/pestphp/pest/commit/97f98569bc86e8b87f8cde963fe7b4bf5399623b)) - -## [v0.3.1 (2020-08-29)](https://github.com/pestphp/pest/compare/v0.3.0...v0.3.1) -### Added -- Support to PHPUnit 9.3.8 ([#174](https://github.com/pestphp/pest/pull/174)) - -## [v0.3.0 (2020-08-27)](https://github.com/pestphp/pest/compare/v0.2.3...v0.3.0) -### Added -- Expectation API (TODO) -- PHPUnit 9.3 and PHP 8 support ([#128](https://github.com/pestphp/pest/pull/128)) -- Forwards `$this` calls to globals ([#169](https://github.com/pestphp/pest/pull/169)) - -### Fixed -- don't decorate output if --colors=never is set ([36b879f](https://github.com/pestphp/pest/commit/36b879f97d7b187c87a94eb60af5b7d3b7253d56)) - -## [v0.2.3 (2020-07-01)](https://github.com/pestphp/pest/compare/v0.2.2...v0.2.3) -### Added -- `--init` and `pest:install` artisan command output changes ([#118](https://github.com/pestphp/pest/pull/118), [db7c4b1](https://github.com/pestphp/pest/commit/db7c4b174f0974969450dda71dcd649ef0c073a3)) -- `--version` option to view the current version of Pest ([9ea51ca](https://github.com/pestphp/pest/commit/9ea51caf3f74569debb1e465992e9ea916cb80fe)) - -## [v0.2.2 (2020-06-21)](https://github.com/pestphp/pest/compare/v0.2.1...v0.2.2) -### Added -- `depends` phpunit feature ([#103](https://github.com/pestphp/pest/pull/103)) - -### Fixes -- datasets name conflict ([#101](https://github.com/pestphp/pest/pull/101)) - -## [v0.2.1 (2020-06-17)](https://github.com/pestphp/pest/compare/v0.2.0...v0.2.1) -### Fixes -- Multiple `uses` in the same path override previous `uses` ([#97](https://github.com/pestphp/pest/pull/97)) - -## [v0.2.0 (2020-06-14)](https://github.com/pestphp/pest/compare/v0.1.5...v0.2.0) -### Adds -- `--init` option to install Pest on a new blank project ([70b3c7e](https://github.com/pestphp/pest/commit/70b3c7ea1ddb031f3bbfaabdc28d56270608ebbd)) -- pending higher orders tests aka tests without description ([aa1917c](https://github.com/pestphp/pest/commit/aa1917c28d9b69c2bd1d51f986c4f61318ee7e16)) - -### Fixed -- `--verbose` and `--colors` options not being used by printers ([#51](https://github.com/pestphp/pest/pull/51)) -- missing support on windows ([#61](https://github.com/pestphp/pest/pull/61)) - -### Changed -- `helpers.php` stub provides now namespaced functions -- functions provided by plugins are now namespaced functions: - -```php -use function Pest\Faker\faker; - -it('foo', function () { - $name = faker()->name; -}); -``` - -## [v0.1.5 (2020-05-24)](https://github.com/pestphp/pest/compare/v0.1.4...v0.1.5) -### Fixed -- Missing default decorated output on coverage ([88d2391](https://github.com/pestphp/pest/commit/88d2391d2e6fe9c9416462734b9b523cb418f469)) - -## [v0.1.4 (2020-05-24)](https://github.com/pestphp/pest/compare/v0.1.3...v0.1.4) -### Added -- Support to Lumen on artisan commands ([#18](https://github.com/pestphp/pest/pull/18)) - -### Fixed -- Mockery tests without assertions being considered risky ([415f571](https://github.com/pestphp/pest/commit/415f5719101b30c11d87f74810a71686ef2786c6)) - -## [v0.1.3 (2020-05-21)](https://github.com/pestphp/pest/compare/v0.1.2...v0.1.3) -### Added -- `Plugin::uses()` method for making traits globally available ([6c4be01](https://github.com/pestphp/pest/commit/6c4be0190e9493702a976b996bbbf5150cc6bb53)) - -## [v0.1.2 (2020-05-15)](https://github.com/pestphp/pest/compare/v0.1.1...v0.1.2) -### Added -- Support to custom helpers ([#7](https://github.com/pestphp/pest/pull/7)) - -## [v0.1.1 (2020-05-14)](https://github.com/pestphp/pest/compare/v0.1.0...v0.1.1) -### Added -- `test` function without any arguments returns the current test case ([6fc55be](https://github.com/pestphp/pest/commit/6fc55becc8aecff685a958617015be1a4c118b01)) - -### Fixed -- "No coverage driver error" now returns proper error on Laravel ([28d8822](https://github.com/pestphp/pest/commit/28d8822de01f4fa92c62d8b8e019313f382b97e9)) - -## [v0.1.0 (2020-05-09)](https://github.com/pestphp/pest/commit/de2929077b344a099ef9c2ddc2f48abce14e248f) -### Added -- First version +Please consult the [upgrade guide](https://pestphp.com/docs/upgrade-guide) and [release notes](https://pestphp.com/docs/announcing-pest2) in the official Pest documentation. From 540c2a56bd7dbf8c7932a3b01eef13584a6ed09e Mon Sep 17 00:00:00 2001 From: Dan Ang Date: Mon, 20 Mar 2023 00:29:19 +0100 Subject: [PATCH 18/53] grammar fixes --- src/Exceptions/AfterAllAlreadyExist.php | 2 +- src/Exceptions/AfterEachAlreadyExist.php | 2 +- src/Exceptions/BeforeEachAlreadyExist.php | 2 +- src/Exceptions/DatasetAlreadyExists.php | 2 +- src/Exceptions/FileOrFolderNotFound.php | 2 +- src/Exceptions/TestAlreadyExist.php | 2 +- src/Exceptions/TestDescriptionMissing.php | 2 +- tests/Features/DatasetsTests.php | 2 +- tests/Unit/TestSuite.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Exceptions/AfterAllAlreadyExist.php b/src/Exceptions/AfterAllAlreadyExist.php index f74e8b51..5aea0c55 100644 --- a/src/Exceptions/AfterAllAlreadyExist.php +++ b/src/Exceptions/AfterAllAlreadyExist.php @@ -19,6 +19,6 @@ final class AfterAllAlreadyExist extends InvalidArgumentException implements Exc */ public function __construct(string $filename) { - parent::__construct(sprintf('The afterAll already exist in the filename `%s`.', $filename)); + parent::__construct(sprintf('The afterAll already exists in the filename `%s`.', $filename)); } } diff --git a/src/Exceptions/AfterEachAlreadyExist.php b/src/Exceptions/AfterEachAlreadyExist.php index 43faa817..cbdd4a7c 100644 --- a/src/Exceptions/AfterEachAlreadyExist.php +++ b/src/Exceptions/AfterEachAlreadyExist.php @@ -19,6 +19,6 @@ final class AfterEachAlreadyExist extends InvalidArgumentException implements Ex */ public function __construct(string $filename) { - parent::__construct(sprintf('The afterEach already exist in the filename `%s`.', $filename)); + parent::__construct(sprintf('The afterEach already exists in the filename `%s`.', $filename)); } } diff --git a/src/Exceptions/BeforeEachAlreadyExist.php b/src/Exceptions/BeforeEachAlreadyExist.php index fba76297..2425ce7f 100644 --- a/src/Exceptions/BeforeEachAlreadyExist.php +++ b/src/Exceptions/BeforeEachAlreadyExist.php @@ -19,6 +19,6 @@ final class BeforeEachAlreadyExist extends InvalidArgumentException implements E */ public function __construct(string $filename) { - parent::__construct(sprintf('The beforeEach already exist in the filename `%s`.', $filename)); + parent::__construct(sprintf('The beforeEach already exists in the filename `%s`.', $filename)); } } diff --git a/src/Exceptions/DatasetAlreadyExists.php b/src/Exceptions/DatasetAlreadyExists.php index 4e42397a..bef2753d 100644 --- a/src/Exceptions/DatasetAlreadyExists.php +++ b/src/Exceptions/DatasetAlreadyExists.php @@ -19,6 +19,6 @@ final class DatasetAlreadyExists extends InvalidArgumentException implements Exc */ public function __construct(string $name, string $scope) { - parent::__construct(sprintf('A dataset with the name `%s` already exist in scope [%s].', $name, $scope)); + parent::__construct(sprintf('A dataset with the name `%s` already exists in scope [%s].', $name, $scope)); } } diff --git a/src/Exceptions/FileOrFolderNotFound.php b/src/Exceptions/FileOrFolderNotFound.php index bd59ac2a..8e6a08d6 100644 --- a/src/Exceptions/FileOrFolderNotFound.php +++ b/src/Exceptions/FileOrFolderNotFound.php @@ -19,6 +19,6 @@ final class FileOrFolderNotFound extends InvalidArgumentException implements Exc */ public function __construct(string $filename) { - parent::__construct(sprintf('The file or folder with the name `%s` not found.', $filename)); + parent::__construct(sprintf('The file or folder with the name `%s` could not be found.', $filename)); } } diff --git a/src/Exceptions/TestAlreadyExist.php b/src/Exceptions/TestAlreadyExist.php index 75f4a420..07ff6a72 100644 --- a/src/Exceptions/TestAlreadyExist.php +++ b/src/Exceptions/TestAlreadyExist.php @@ -19,6 +19,6 @@ final class TestAlreadyExist extends InvalidArgumentException implements Excepti */ public function __construct(string $fileName, string $description) { - parent::__construct(sprintf('A test with the description `%s` already exist in the filename `%s`.', $description, $fileName)); + parent::__construct(sprintf('A test with the description `%s` already exists in the filename `%s`.', $description, $fileName)); } } diff --git a/src/Exceptions/TestDescriptionMissing.php b/src/Exceptions/TestDescriptionMissing.php index 67f75930..b9fcc684 100644 --- a/src/Exceptions/TestDescriptionMissing.php +++ b/src/Exceptions/TestDescriptionMissing.php @@ -19,6 +19,6 @@ final class TestDescriptionMissing extends InvalidArgumentException implements E */ public function __construct(string $fileName) { - parent::__construct(sprintf('Test misses description in the filename `%s`.', $fileName)); + parent::__construct(sprintf('Test description is missing in the filename `%s`.', $fileName)); } } diff --git a/tests/Features/DatasetsTests.php b/tests/Features/DatasetsTests.php index 5d1b1ca1..f6030926 100644 --- a/tests/Features/DatasetsTests.php +++ b/tests/Features/DatasetsTests.php @@ -19,7 +19,7 @@ it('throws exception if dataset does not exist', function () { it('throws exception if dataset already exist', function () { DatasetsRepository::set('second', [[]], __DIR__); $this->expectException(DatasetAlreadyExists::class); - $this->expectExceptionMessage('A dataset with the name `second` already exist in scope ['.__DIR__.'].'); + $this->expectExceptionMessage('A dataset with the name `second` already exists in scope ['.__DIR__.'].'); DatasetsRepository::set('second', [[]], __DIR__); }); diff --git a/tests/Unit/TestSuite.php b/tests/Unit/TestSuite.php index 3c4ff2a1..eb033d0c 100644 --- a/tests/Unit/TestSuite.php +++ b/tests/Unit/TestSuite.php @@ -13,7 +13,7 @@ it('does not allow to add the same test description twice', function () { $testSuite->tests->set($method); })->throws( TestAlreadyExist::class, - sprintf('A test with the description `%s` already exist in the filename `%s`.', 'bar', 'foo'), + sprintf('A test with the description `%s` already exists in the filename `%s`.', 'bar', 'foo'), ); it('alerts users about tests with arguments but no input', function () { From 1431a2a89729a33e1b44994aa67bfd0216a23fff Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 00:21:27 +0000 Subject: [PATCH 19/53] chore: bumps development tools --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6184f729..a51e892a 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ ] }, "require-dev": { - "pestphp/pest-dev-tools": "^2.4.0", + "pestphp/pest-dev-tools": "^2.5.0", "symfony/process": "^6.2.7" }, "minimum-stability": "dev", From 8350d740202da5951d4786f5ea004db9bd6a1a4d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 10:28:10 +0000 Subject: [PATCH 20/53] chore: uses `stable` minimum-stability --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a51e892a..bf4b95be 100644 --- a/composer.json +++ b/composer.json @@ -52,8 +52,7 @@ "pestphp/pest-dev-tools": "^2.5.0", "symfony/process": "^6.2.7" }, - "minimum-stability": "dev", - "prefer-stable": true, + "minimum-stability": "stable", "config": { "sort-packages": true, "preferred-install": "dist", From bc1b11054c7ba2bbbbfbfb535edfaeb08306da10 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 10:35:10 +0000 Subject: [PATCH 21/53] docs: updates release --- RELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 81d3c198..103b41e1 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -5,7 +5,7 @@ When releasing a new version of Pest there are some checks and updates that need > **For Pest v1 you should use the `1.x` branch instead.** - Clear your local repository with: `git add . && git reset --hard && git checkout master` -- On the GitHub repository, check the contents of [github.com/pestphp/pest/compare/{latest_version}...master](https://github.com/pestphp/pest/compare/{latest_version}...master) and update the [changelog](CHANGELOG.md) file with the main changes for this release +- On the GitHub repository, check the contents of [github.com/pestphp/pest/compare/{latest_version}...2.x](https://github.com/pestphp/pest/compare/{latest_version}...master) and update the [changelog](CHANGELOG.md) file with the main changes for this release - Update the version number in [src/Pest.php](src/Pest.php) - Run the tests locally using: `composer test` - Commit the CHANGELOG and Pest file with the message: `git commit -m "release: vX.X.X"` From 627b6733802616f35b092d8e070ece26081a0e70 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 10:35:27 +0000 Subject: [PATCH 22/53] docs: updates release --- RELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index 103b41e1..2caae2c9 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,7 +4,7 @@ When releasing a new version of Pest there are some checks and updates that need > **For Pest v1 you should use the `1.x` branch instead.** -- Clear your local repository with: `git add . && git reset --hard && git checkout master` +- Clear your local repository with: `git add . && git reset --hard && git checkout 2.x` - On the GitHub repository, check the contents of [github.com/pestphp/pest/compare/{latest_version}...2.x](https://github.com/pestphp/pest/compare/{latest_version}...master) and update the [changelog](CHANGELOG.md) file with the main changes for this release - Update the version number in [src/Pest.php](src/Pest.php) - Run the tests locally using: `composer test` From 37d44340008fce9bc4f4dfc1807b39472aca73ca Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 10:36:51 +0000 Subject: [PATCH 23/53] release: v2.0.0 --- src/Pest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Pest.php b/src/Pest.php index b56ceb0b..df208d75 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.x-dev'; + return '2.0.0'; } function testDirectory(string $file = ''): string From 2973b600f51648952539604c6ebc4a948d7087df Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 10:39:49 +0000 Subject: [PATCH 24/53] release: v2.0.0 --- tests/.snapshots/help-command.txt | 2 +- tests/.snapshots/version-command.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/.snapshots/help-command.txt b/tests/.snapshots/help-command.txt index 70cfa7e3..256bc3c9 100644 --- a/tests/.snapshots/help-command.txt +++ b/tests/.snapshots/help-command.txt @@ -1,5 +1,5 @@ - Pest Testing Framework 2.x-dev. + Pest Testing Framework 2.0.0. USAGE: pest [options] diff --git a/tests/.snapshots/version-command.txt b/tests/.snapshots/version-command.txt index df653c1c..4c4c6b1b 100644 --- a/tests/.snapshots/version-command.txt +++ b/tests/.snapshots/version-command.txt @@ -1,3 +1,3 @@ - Pest Testing Framework 2.x-dev. + Pest Testing Framework 2.0.0. From 8f91f40e8ea8b35e04b7989bed6a8f9439e2a2d6 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 10:55:47 +0000 Subject: [PATCH 25/53] fix: removes `version` from `composer.json` --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index bf4b95be..cdad1d08 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "webmozart/assert": "<1.11.0", "phpunit/phpunit": ">10.0.16" }, - "version": "2.x-dev", "autoload": { "psr-4": { "Pest\\": "src/" From e3ab27e2ec74793aed4257384d9a8a4310342ce4 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 11:02:54 +0000 Subject: [PATCH 26/53] release: v2.0.1 --- CHANGELOG.md | 7 +++++++ src/Pest.php | 2 +- tests/.snapshots/help-command.txt | 2 +- tests/.snapshots/version-command.txt | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdccbd93..622adde6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +## [v2.0.1 (2023-03-20)](https://github.com/pestphp/pest/compare/v2.0.0...v2.0.1) + +### Fixed +- Wrong `version` configuration key on `composer.json` ([8f91f40](https://github.com/pestphp/pest/commit/8f91f40e8ea8b35e04b7989bed6a8f9439e2a2d6)) + +### + ## [v2.0.0 (2023-03-20)](https://github.com/pestphp/pest/compare/v1.22.6...v2.0.0) Please consult the [upgrade guide](https://pestphp.com/docs/upgrade-guide) and [release notes](https://pestphp.com/docs/announcing-pest2) in the official Pest documentation. diff --git a/src/Pest.php b/src/Pest.php index df208d75..7551d9a4 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.0.0'; + return '2.0.1'; } function testDirectory(string $file = ''): string diff --git a/tests/.snapshots/help-command.txt b/tests/.snapshots/help-command.txt index 256bc3c9..8c800421 100644 --- a/tests/.snapshots/help-command.txt +++ b/tests/.snapshots/help-command.txt @@ -1,5 +1,5 @@ - Pest Testing Framework 2.0.0. + Pest Testing Framework 2.0.1. USAGE: pest [options] diff --git a/tests/.snapshots/version-command.txt b/tests/.snapshots/version-command.txt index 4c4c6b1b..d9584130 100644 --- a/tests/.snapshots/version-command.txt +++ b/tests/.snapshots/version-command.txt @@ -1,3 +1,3 @@ - Pest Testing Framework 2.0.0. + Pest Testing Framework 2.0.1. From bb5dbc878ea11cf946172d3c2df1c26f26ec5d21 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 15:22:10 +0000 Subject: [PATCH 27/53] chore: bumps required version of `arch` plugin --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cdad1d08..23d5d96b 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "nunomaduro/collision": "^7.2.0", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.0", - "pestphp/pest-plugin-arch": "^2.0.0", + "pestphp/pest-plugin-arch": "^2.0.1", "phpunit/phpunit": "^10.0.16" }, "conflict": { From c64c41a4d9b9db5e86a36651445e5ad24ed97199 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 15:52:41 +0000 Subject: [PATCH 28/53] chore: requires `"phpunit/phpunit": "^10.0.17"` --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 23d5d96b..bbc508f0 100644 --- a/composer.json +++ b/composer.json @@ -18,16 +18,16 @@ ], "require": { "php": "^8.1.0", - "brianium/paratest": "^7.1.1", + "brianium/paratest": "^7.1.2", "nunomaduro/collision": "^7.2.0", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.0", "pestphp/pest-plugin-arch": "^2.0.1", - "phpunit/phpunit": "^10.0.16" + "phpunit/phpunit": "^10.0.17" }, "conflict": { "webmozart/assert": "<1.11.0", - "phpunit/phpunit": ">10.0.16" + "phpunit/phpunit": ">10.0.17" }, "autoload": { "psr-4": { From c9a80078111b5cb51f98f2375ee3acc032cb2e2d Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 16:00:11 +0000 Subject: [PATCH 29/53] chore: uses `instance` method of facade --- src/Bootstrappers/BootSubscribers.php | 2 +- src/Logging/TeamCity/TeamCityLogger.php | 3 +-- src/Plugins/Parallel/Paratest/WrapperRunner.php | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Bootstrappers/BootSubscribers.php b/src/Bootstrappers/BootSubscribers.php index 8a2df311..248b9dde 100644 --- a/src/Bootstrappers/BootSubscribers.php +++ b/src/Bootstrappers/BootSubscribers.php @@ -45,7 +45,7 @@ final class BootSubscribers implements Bootstrapper assert($instance instanceof Subscriber); - method_exists(Event\Facade::class, 'instance') ? Event\Facade::instance()->registerSubscriber($instance) : Event\Facade::registerSubscriber($instance); // @phpstan-ignore-line + Event\Facade::instance()->registerSubscriber($instance); } } } diff --git a/src/Logging/TeamCity/TeamCityLogger.php b/src/Logging/TeamCity/TeamCityLogger.php index 0394d058..fed115bc 100644 --- a/src/Logging/TeamCity/TeamCityLogger.php +++ b/src/Logging/TeamCity/TeamCityLogger.php @@ -237,8 +237,7 @@ final class TeamCityLogger new TestExecutionFinishedSubscriber($this), ]; - // @phpstan-ignore-next-line - method_exists(Facade::class, 'instance') ? Facade::instance()->registerSubscribers(...$subscribers) : Facade::registerSubscribers(...$subscribers); + Facade::instance()->registerSubscribers(...$subscribers); } private function setFlowId(): void diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 78764ce9..717dfcb9 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -115,8 +115,7 @@ final class WrapperRunner implements RunnerInterface TestResultFacade::init(); - // @phpstan-ignore-next-line - method_exists(EventFacade::class, 'instance') ? EventFacade::instance()->seal() : EventFacade::seal(); + EventFacade::instance()->seal(); $suiteLoader = new SuiteLoader($this->options, $this->output, $this->codeCoverageFilterRegistry); $this->pending = $this->getTestFiles($suiteLoader); From 17e242a5f60d55de7b7e2cc24fb6bd858a2ccec4 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 16:08:14 +0000 Subject: [PATCH 30/53] tests: windows global functions --- tests/Environments/Windows.php | 6 ++++++ tests/Pest.php | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 tests/Environments/Windows.php diff --git a/tests/Environments/Windows.php b/tests/Environments/Windows.php new file mode 100644 index 00000000..c646a7e0 --- /dev/null +++ b/tests/Environments/Windows.php @@ -0,0 +1,6 @@ +toBeString(); +}); + diff --git a/tests/Pest.php b/tests/Pest.php index d0f656bd..40095334 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -25,3 +25,7 @@ uses() $_SERVER['globalHook']->calls->afterAll++; }) ->in('Hooks'); + +function helper_returns_string() { + return 'string'; +} From 5723da104345315cb56bbfc7897cadf2187f99fb Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 16:10:53 +0000 Subject: [PATCH 31/53] tests: updates snapshot testing --- tests/Environments/Windows.php | 1 - tests/Pest.php | 3 ++- tests/Visual/Parallel.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Environments/Windows.php b/tests/Environments/Windows.php index c646a7e0..54122f54 100644 --- a/tests/Environments/Windows.php +++ b/tests/Environments/Windows.php @@ -3,4 +3,3 @@ test('global functions are loaded', function () { expect(helper_returns_string())->toBeString(); }); - diff --git a/tests/Pest.php b/tests/Pest.php index 40095334..23daca74 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -26,6 +26,7 @@ uses() }) ->in('Hooks'); -function helper_returns_string() { +function helper_returns_string() +{ return 'string'; } diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 237345d7..d985d69f 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -15,6 +15,6 @@ $run = function () { }; test('parallel', function () use ($run) { - expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 15 skipped, 640 passed (1578 assertions)') + expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 15 skipped, 641 passed (1579 assertions)') ->toContain('Parallel: 3 processes'); })->skip(PHP_OS_FAMILY === 'Windows'); From 6071d86ac6912e27f71ad98d7cd0bb6f49a23328 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 16:14:40 +0000 Subject: [PATCH 32/53] tests: update snapshot testing --- tests/.snapshots/success.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 82345dd7..4ed45aab 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -4,6 +4,9 @@ ✓ dependencies ✓ contracts + PASS Tests\Environments\Windows + ✓ global functions are loaded + PASS Tests\Features\AfterAll ✓ deletes file after all @@ -950,4 +953,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 18 skipped, 649 passed (1591 assertions) \ No newline at end of file + Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 18 skipped, 650 passed (1592 assertions) \ No newline at end of file From b887116e5ce9a69403ad620cad20f0a029474eb5 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 17:34:42 +0000 Subject: [PATCH 33/53] fix: `Pest.php` file not loaded in certain environments --- bin/pest | 3 +- bin/worker.php | 3 +- src/ConfigLoader.php | 113 ------------------------------------ tests/Unit/ConfigLoader.php | 19 ------ tests/Visual/Parallel.php | 2 +- 5 files changed, 3 insertions(+), 137 deletions(-) delete mode 100644 src/ConfigLoader.php delete mode 100644 tests/Unit/ConfigLoader.php diff --git a/bin/pest b/bin/pest index 8de2b9de..f480581f 100755 --- a/bin/pest +++ b/bin/pest @@ -1,7 +1,6 @@ #!/usr/bin/env php getParameterOption('--test-directory', (new ConfigLoader($rootPath))->getTestsDirectory()), + $input->getParameterOption('--test-directory', 'tests'), ); if ($dirty) { diff --git a/bin/worker.php b/bin/worker.php index 9fa983c7..f3b6b7b3 100644 --- a/bin/worker.php +++ b/bin/worker.php @@ -4,7 +4,6 @@ declare(strict_types=1); use ParaTest\WrapperRunner\ApplicationForWrapperWorker; use ParaTest\WrapperRunner\WrapperWorker; -use Pest\ConfigLoader; use Pest\Kernel; use Pest\Plugins\Actions\CallsHandleArguments; use Pest\TestSuite; @@ -18,7 +17,7 @@ $bootPest = (static function (): void { $rootPath = dirname(PHPUNIT_COMPOSER_INSTALL, 2); $testSuite = TestSuite::getInstance($rootPath, $workerArgv->getParameterOption( '--test-directory', - (new ConfigLoader($rootPath))->getTestsDirectory() + 'tests' )); $input = new ArgvInput(); diff --git a/src/ConfigLoader.php b/src/ConfigLoader.php deleted file mode 100644 index 870003c1..00000000 --- a/src/ConfigLoader.php +++ /dev/null @@ -1,113 +0,0 @@ -loadConfiguration(); - } - - /** - * Get the tests directory or fallback to default path. - */ - public function getTestsDirectory(): string - { - $suiteDirectory = []; - if (is_null($this->config)) { - return self::DEFAULT_TESTS_PATH; - } - - $suiteDirectory = $this->config->xpath('/phpunit/testsuites/testsuite/directory'); - - if ($suiteDirectory === []) { - return self::DEFAULT_TESTS_PATH; - } - - $directory = (string) ($suiteDirectory[0] ?? ''); - - if ($directory === '') { - return self::DEFAULT_TESTS_PATH; - } - - // Return the whole directory if only a separator found (e.g. `./tests`) - if (substr_count($directory, DIRECTORY_SEPARATOR) === 1) { - return is_dir($directory) ? $directory : self::DEFAULT_TESTS_PATH; - } - - $basePath = Str::beforeLast($directory, DIRECTORY_SEPARATOR); - - return is_dir($basePath) ? $basePath : self::DEFAULT_TESTS_PATH; - } - - /** - * Get the configuration file path. - */ - public function getConfigurationFilePath(): string|bool - { - $candidates = [ - $this->rootPath.'/phpunit.xml', - $this->rootPath.'/phpunit.dist.xml', - $this->rootPath.'/phpunit.xml.dist', - ]; - - foreach ($candidates as $candidate) { - if (is_file($candidate)) { - return realpath($candidate); - } - } - - return false; - } - - /** - * Load the configuration file. - */ - private function loadConfiguration(): void - { - $configPath = $this->getConfigurationFilePath(); - - if (is_bool($configPath)) { - return; - } - - $oldReportingLevel = error_reporting(0); - $content = file_get_contents($configPath); - - if ($content !== false) { - try { - $this->config = new SimpleXMLElement($content); - } catch (Throwable) { // @phpstan-ignore-line - // @ignoreException - } - } - - // Restore the correct error reporting - error_reporting($oldReportingLevel); - } -} diff --git a/tests/Unit/ConfigLoader.php b/tests/Unit/ConfigLoader.php deleted file mode 100644 index cae011ba..00000000 --- a/tests/Unit/ConfigLoader.php +++ /dev/null @@ -1,19 +0,0 @@ -toBeNull(); - expect($instance->getConfigurationFilePath())->toBeFalse(); - expect($instance->getTestsDirectory())->toBe(ConfigLoader::DEFAULT_TESTS_PATH); -}); - -it('fallbacks to default path if phpunit is not a valid XML')->skip(); -it('fallbacks to default path if failing to read phpunit content')->skip(); -it('fallbacks to default path if there is no test suites directory')->skip(); -it('fallbacks to default path if test suite directory has no value')->skip(); -it('fallbacks to default path if test suite directory does not exist')->skip(); -it('returns the parent folder of first test suite directory')->skip(); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index d985d69f..484da13b 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -15,6 +15,6 @@ $run = function () { }; test('parallel', function () use ($run) { - expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 15 skipped, 641 passed (1579 assertions)') + expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 640 passed (1576 assertions)') ->toContain('Parallel: 3 processes'); })->skip(PHP_OS_FAMILY === 'Windows'); From 8068bebebde19dc01e00ab43f129f9a1d0db418e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 17:36:18 +0000 Subject: [PATCH 34/53] chore: updates snapshots --- tests/.snapshots/success.txt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 4ed45aab..a4cd9c63 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -840,15 +840,6 @@ ✓ it allows global uses ✓ it allows multiple global uses registered in the same path - WARN Tests\Unit\ConfigLoader - ✓ it fallbacks to default path if no phpunit file is found - - it fallbacks to default path if phpunit is not a valid XML - - it fallbacks to default path if failing to read phpunit content - - it fallbacks to default path if there is no test suites directory - - it fallbacks to default path if test suite directory has no value - - it fallbacks to default path if test suite directory does not exist - - it returns the parent folder of first test suite directory - PASS Tests\Unit\Console\Help ✓ it outputs the help information when --help is used @@ -953,4 +944,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 18 skipped, 650 passed (1592 assertions) \ No newline at end of file + Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 649 passed (1589 assertions) \ No newline at end of file From b3a8aef6ac30ac24193aba4f23971d4b87c3789c Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 17:42:44 +0000 Subject: [PATCH 35/53] chore: improves tests --- tests/Visual/Parallel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 484da13b..16ca7396 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -9,7 +9,7 @@ $run = function () { $process->run(); - expect($process->getExitCode())->toBe(0); + // expect($process->getExitCode())->toBe(0); return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput()); }; From 522ac55d5fb01c9efe5b6c7c07dae64be1e6e528 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 17:45:35 +0000 Subject: [PATCH 36/53] chore: rebuilds snapshots --- tests/.snapshots/success.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index a4cd9c63..083ec696 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -944,4 +944,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 649 passed (1589 assertions) \ No newline at end of file + Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 649 passed (1588 assertions) \ No newline at end of file From a4932e41de10ed1424b9f99fd54a843f9918bdf7 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 17:51:54 +0000 Subject: [PATCH 37/53] release: v2.0.2 --- CHANGELOG.md | 7 +++++-- src/Pest.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 622adde6..c8972013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,16 @@ ## Unreleased +## [v2.0.2 (2023-03-20)](https://github.com/pestphp/pest/compare/v2.0.1...v2.0.2) + +### Fixed +- `Pest.php` not being loaded in certain scenarios ([b887116](https://github.com/pestphp/pest/commit/b887116e5ce9a69403ad620cad20f0a029474eb5)) + ## [v2.0.1 (2023-03-20)](https://github.com/pestphp/pest/compare/v2.0.0...v2.0.1) ### Fixed - Wrong `version` configuration key on `composer.json` ([8f91f40](https://github.com/pestphp/pest/commit/8f91f40e8ea8b35e04b7989bed6a8f9439e2a2d6)) -### - ## [v2.0.0 (2023-03-20)](https://github.com/pestphp/pest/compare/v1.22.6...v2.0.0) Please consult the [upgrade guide](https://pestphp.com/docs/upgrade-guide) and [release notes](https://pestphp.com/docs/announcing-pest2) in the official Pest documentation. diff --git a/src/Pest.php b/src/Pest.php index 7551d9a4..d0fa2ff3 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.0.1'; + return '2.0.2'; } function testDirectory(string $file = ''): string From 8782e9c34e8f8834fe9bf98c7f47043ceb813354 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 17:52:15 +0000 Subject: [PATCH 38/53] release: v2.0.2 --- tests/.snapshots/help-command.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/.snapshots/help-command.txt b/tests/.snapshots/help-command.txt index 8c800421..aa7cf29f 100644 --- a/tests/.snapshots/help-command.txt +++ b/tests/.snapshots/help-command.txt @@ -1,5 +1,5 @@ - Pest Testing Framework 2.0.1. + Pest Testing Framework 2.0.2. USAGE: pest [options] From 9d0cd32e3f9286d03f66636a395632972a66a52e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 20 Mar 2023 17:52:35 +0000 Subject: [PATCH 39/53] release: v2.0.2 --- tests/.snapshots/version-command.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/.snapshots/version-command.txt b/tests/.snapshots/version-command.txt index d9584130..0ad97038 100644 --- a/tests/.snapshots/version-command.txt +++ b/tests/.snapshots/version-command.txt @@ -1,3 +1,3 @@ - Pest Testing Framework 2.0.1. + Pest Testing Framework 2.0.2. From ecbaff503e0d367636d8ed88d8d821d79e28fd62 Mon Sep 17 00:00:00 2001 From: Dan Ang Date: Tue, 21 Mar 2023 14:37:17 +0100 Subject: [PATCH 40/53] Add Date/DateTimeImmutable to Expectations --- src/Mixins/Expectation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index 0513face..d087162d 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -124,7 +124,7 @@ final class Expectation * * @return self */ - public function toBeGreaterThan(int|float $expected, string $message = ''): self + public function toBeGreaterThan(int|float|\DateTime|\DateTimeImmutable $expected, string $message = ''): self { Assert::assertGreaterThan($expected, $this->value, $message); @@ -136,7 +136,7 @@ final class Expectation * * @return self */ - public function toBeGreaterThanOrEqual(int|float $expected, string $message = ''): self + public function toBeGreaterThanOrEqual(int|float|\DateTime|\DateTimeImmutable $expected, string $message = ''): self { Assert::assertGreaterThanOrEqual($expected, $this->value, $message); @@ -148,7 +148,7 @@ final class Expectation * * @return self */ - public function toBeLessThan(int|float $expected, string $message = ''): self + public function toBeLessThan(int|float|\DateTime|\DateTimeImmutable $expected, string $message = ''): self { Assert::assertLessThan($expected, $this->value, $message); @@ -160,7 +160,7 @@ final class Expectation * * @return self */ - public function toBeLessThanOrEqual(int|float $expected, string $message = ''): self + public function toBeLessThanOrEqual(int|float|\DateTime|\DateTimeImmutable $expected, string $message = ''): self { Assert::assertLessThanOrEqual($expected, $this->value, $message); From f4d19c90d3059d6eacc0ec3bc8b8e3239eda1006 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 13:42:10 +0000 Subject: [PATCH 41/53] chore: bumps dependencies --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bbc508f0..33ef9749 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": "^8.1.0", "brianium/paratest": "^7.1.2", - "nunomaduro/collision": "^7.2.0", + "nunomaduro/collision": "^7.3.1", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.0", "pestphp/pest-plugin-arch": "^2.0.1", From 236a9bd7ce8927b1ce88a1810b5d5d9eedd7e75f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 13:42:21 +0000 Subject: [PATCH 42/53] chore: style changes --- src/Expectation.php | 2 +- src/Support/Arr.php | 2 +- src/Support/Reflection.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Expectation.php b/src/Expectation.php index 07b0d5d5..537883bb 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -64,7 +64,7 @@ final class Expectation */ public function and(mixed $value): Expectation { - return $value instanceof static ? $value : new self($value); + return $value instanceof self ? $value : new self($value); } /** diff --git a/src/Support/Arr.php b/src/Support/Arr.php index bd80ae56..aed6c5a7 100644 --- a/src/Support/Arr.php +++ b/src/Support/Arr.php @@ -73,7 +73,7 @@ final class Arr foreach ($array as $key => $value) { if (is_array($value) && $value !== []) { - $results = array_merge($results, static::dot($value, $prepend.$key.'.')); + $results = array_merge($results, self::dot($value, $prepend.$key.'.')); } else { $results[$prepend.$value] = $value; } diff --git a/src/Support/Reflection.php b/src/Support/Reflection.php index 14edd7ad..18a71aa6 100644 --- a/src/Support/Reflection.php +++ b/src/Support/Reflection.php @@ -42,7 +42,7 @@ final class Reflection } if (is_callable($method)) { - return static::bindCallable($method, $args); + return self::bindCallable($method, $args); } throw $exception; @@ -72,7 +72,7 @@ final class Reflection return $test instanceof \PHPUnit\Framework\TestCase ? Closure::fromCallable($callable)->bindTo($test)(...$test->providedData()) - : static::bindCallable($callable); + : self::bindCallable($callable); } /** From 26bb0b6eec0add4e6239b56d6d4922aa1899a2af Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 13:42:10 +0000 Subject: [PATCH 43/53] chore: bumps dependencies From 48ae4bfc18fa15d50e9f4499c11e4d2ab4448cf1 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 13:43:01 +0000 Subject: [PATCH 44/53] =?UTF-8?q?fix:=20description=20when=20using=20`?= =?UTF-8?q?=E3=81=B5=E3=81=8C`=20chars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Support/Str.php | 2 +- tests/Unit/TestName.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Support/Str.php b/src/Support/Str.php index 9ed75c1f..896710c3 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -61,7 +61,7 @@ final class Str { $code = self::PREFIX.str_replace(' ', '_', $code); - return (string) preg_replace('/[^A-Z_a-z0-9]/', '_', $code); + return (string) preg_replace('/[^\p{L}_0-9]/', '_', $code); } /** diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php index 3f52e700..2d5ce4aa 100644 --- a/tests/Unit/TestName.php +++ b/tests/Unit/TestName.php @@ -11,3 +11,23 @@ it('may start with P', function (string $real, string $toBePrinted) { ['PPPackages\Foo', 'PPPackages\Foo'], ['PPPackages\Foo', 'PPPackages\Foo'], ]); + +$names = [ + 'ふが' => '__pest_evaluable_ふが', + 'ほげ' => 'ほげ', + '卜竹弓一十山' => '卜竹弓一十山', + '!p8VrB' => '!p8VrB', + '&xe6VeKWF#n4' => '&xe6VeKWF#n4', + '%%HurHUnw7zM!' => '%%HurHUnw7zM!', + 'rundeliekend' => 'rundeliekend', + 'g%%c!Jt9$fy#Kf' => 'g%%c!Jt9$fy#Kf', + 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX' => 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX', +]; + +foreach ($names as $name => $methodName) { + test($name) + ->expect(fn () => static::getLatestPrintableTestCaseMethodName()) + ->toBe($name) + ->and(fn () => $this->name()) + ->toBe($methodName); +} From ed3bb2634dbaf4c852d1da002c59b92df00e1a87 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 21 Mar 2023 15:15:38 +0100 Subject: [PATCH 45/53] using php documentation regex --- src/Support/Str.php | 3 ++- tests/Unit/TestName.php | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Support/Str.php b/src/Support/Str.php index 896710c3..21ee5c5b 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -61,7 +61,8 @@ final class Str { $code = self::PREFIX.str_replace(' ', '_', $code); - return (string) preg_replace('/[^\p{L}_0-9]/', '_', $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); } /** diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php index 2d5ce4aa..a7455d32 100644 --- a/tests/Unit/TestName.php +++ b/tests/Unit/TestName.php @@ -14,14 +14,15 @@ it('may start with P', function (string $real, string $toBePrinted) { $names = [ 'ふが' => '__pest_evaluable_ふが', - 'ほげ' => 'ほげ', - '卜竹弓一十山' => '卜竹弓一十山', - '!p8VrB' => '!p8VrB', - '&xe6VeKWF#n4' => '&xe6VeKWF#n4', - '%%HurHUnw7zM!' => '%%HurHUnw7zM!', - 'rundeliekend' => 'rundeliekend', - 'g%%c!Jt9$fy#Kf' => 'g%%c!Jt9$fy#Kf', - 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX' => 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX', + 'ほげ' => '__pest_evaluable_ほげ', + '卜竹弓一十山' => '__pest_evaluable_卜竹弓一十山', + '!p8VrB' => '__pest_evaluable__p8VrB', + '&xe6VeKWF#n4' => '__pest_evaluable__xe6VeKWF_n4', + '%%HurHUnw7zM!' => '__pest_evaluable___HurHUnw7zM_', + 'rundeliekend' => '__pest_evaluable_rundeliekend', + 'g%%c!Jt9$fy#Kf' => '__pest_evaluable_g__c_Jt9_fy_Kf', + 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX' => '__pest_evaluable_NRs_Gz2_hmB_W_BPD__b2U_3P_z_apnwSX', + 'ÀĤ{¼' => '__pest_evaluable_ÀĤ_¼', ]; foreach ($names as $name => $methodName) { From a8bd353ba6da06f44dea0c955ab61b8f9a461bb3 Mon Sep 17 00:00:00 2001 From: Dan Ang Date: Tue, 21 Mar 2023 14:37:31 +0100 Subject: [PATCH 46/53] Including tests for Date and DateTimeImmutable --- tests/.snapshots/success.txt | 6 +++++- tests/Features/Expect/toBeGreatherThan.php | 9 +++++++++ tests/Features/Expect/toBeGreatherThanOrEqual.php | 11 +++++++++++ tests/Features/Expect/toBeLessThan.php | 9 +++++++++ tests/Features/Expect/toBeLessThanOrEqual.php | 11 +++++++++++ tests/Visual/Parallel.php | 2 +- 6 files changed, 46 insertions(+), 2 deletions(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 083ec696..ad025028 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -334,12 +334,14 @@ PASS Tests\Features\Expect\toBeGreatherThan ✓ passes + ✓ passes with DateTime and DateTimeImmutable ✓ failures ✓ failures with custom message ✓ not failures PASS Tests\Features\Expect\toBeGreatherThanOrEqual ✓ passes + ✓ passes with DateTime and DateTimeImmutable ✓ failures ✓ failures with custom message ✓ not failures @@ -382,12 +384,14 @@ PASS Tests\Features\Expect\toBeLessThan ✓ passes + ✓ passes with DateTime and DateTimeImmutable ✓ failures ✓ failures with custom message ✓ not failures PASS Tests\Features\Expect\toBeLessThanOrEqual ✓ passes + ✓ passes with DateTime and DateTimeImmutable ✓ failures ✓ failures with custom message ✓ not failures @@ -944,4 +948,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 649 passed (1588 assertions) \ No newline at end of file + Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 653 passed (1604 assertions) \ No newline at end of file diff --git a/tests/Features/Expect/toBeGreatherThan.php b/tests/Features/Expect/toBeGreatherThan.php index 798c23bb..a3ceafef 100644 --- a/tests/Features/Expect/toBeGreatherThan.php +++ b/tests/Features/Expect/toBeGreatherThan.php @@ -7,6 +7,15 @@ test('passes', function () { expect(4)->toBeGreaterThan(3.9); }); +test('passes with DateTime and DateTimeImmutable', function () { + $now = new DateTime(); + $past = (new DateTimeImmutable())->modify('-1 day'); + + expect($now)->toBeGreaterThan($past); + + expect($past)->not->toBeGreaterThan($now); +}); + test('failures', function () { expect(4)->toBeGreaterThan(4); })->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toBeGreatherThanOrEqual.php b/tests/Features/Expect/toBeGreatherThanOrEqual.php index cfa1da07..4a0f62ad 100644 --- a/tests/Features/Expect/toBeGreatherThanOrEqual.php +++ b/tests/Features/Expect/toBeGreatherThanOrEqual.php @@ -7,6 +7,17 @@ test('passes', function () { expect(4)->toBeGreaterThanOrEqual(4); }); +test('passes with DateTime and DateTimeImmutable', function () { + $now = new DateTime(); + $past = (new DateTimeImmutable())->modify('-1 day'); + + expect($now)->toBeGreaterThanOrEqual($now); + + expect($now)->toBeGreaterThanOrEqual($past); + + expect($past)->not->toBeGreaterThanOrEqual($now); +}); + test('failures', function () { expect(4)->toBeGreaterThanOrEqual(4.1); })->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toBeLessThan.php b/tests/Features/Expect/toBeLessThan.php index 9002c424..802c1c08 100644 --- a/tests/Features/Expect/toBeLessThan.php +++ b/tests/Features/Expect/toBeLessThan.php @@ -7,6 +7,15 @@ test('passes', function () { expect(4)->toBeLessThan(5); }); +test('passes with DateTime and DateTimeImmutable', function () { + $now = new DateTime(); + $past = (new DateTimeImmutable())->modify('-1 day'); + + expect($past)->toBeLessThan($now); + + expect($now)->not->toBeLessThan($now); +}); + test('failures', function () { expect(4)->toBeLessThan(4); })->throws(ExpectationFailedException::class); diff --git a/tests/Features/Expect/toBeLessThanOrEqual.php b/tests/Features/Expect/toBeLessThanOrEqual.php index 4413e05f..e5643759 100644 --- a/tests/Features/Expect/toBeLessThanOrEqual.php +++ b/tests/Features/Expect/toBeLessThanOrEqual.php @@ -7,6 +7,17 @@ test('passes', function () { expect(4)->toBeLessThanOrEqual(4); }); +test('passes with DateTime and DateTimeImmutable', function () { + $now = new DateTime(); + $past = (new DateTimeImmutable())->modify('-1 day'); + + expect($now)->toBeLessThanOrEqual($now); + + expect($past)->toBeLessThanOrEqual($now); + + expect($now)->not->toBeLessThanOrEqual($past); +}); + test('failures', function () { expect(4)->toBeLessThanOrEqual(3.9); })->throws(ExpectationFailedException::class); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 16ca7396..b3817ef7 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -15,6 +15,6 @@ $run = function () { }; test('parallel', function () use ($run) { - expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 640 passed (1576 assertions)') + expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 644 passed (1592 assertions)') ->toContain('Parallel: 3 processes'); })->skip(PHP_OS_FAMILY === 'Windows'); From e0f2919f62f0d8bd94272fd0bd9bcea12d36f059 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 21 Mar 2023 17:39:01 +0100 Subject: [PATCH 47/53] expand Str::evaluable test cases --- tests/Unit/TestName.php | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php index a7455d32..b7f91d54 100644 --- a/tests/Unit/TestName.php +++ b/tests/Unit/TestName.php @@ -13,16 +13,52 @@ it('may start with P', function (string $real, string $toBePrinted) { ]); $names = [ - 'ふが' => '__pest_evaluable_ふが', + 'ふ+が+' => '__pest_evaluable_ふ_が_', 'ほげ' => '__pest_evaluable_ほげ', '卜竹弓一十山' => '__pest_evaluable_卜竹弓一十山', + 'アゴデヸ' => '__pest_evaluable_アゴデヸ', '!p8VrB' => '__pest_evaluable__p8VrB', '&xe6VeKWF#n4' => '__pest_evaluable__xe6VeKWF_n4', '%%HurHUnw7zM!' => '__pest_evaluable___HurHUnw7zM_', 'rundeliekend' => '__pest_evaluable_rundeliekend', 'g%%c!Jt9$fy#Kf' => '__pest_evaluable_g__c_Jt9_fy_Kf', 'NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX' => '__pest_evaluable_NRs_Gz2_hmB_W_BPD__b2U_3P_z_apnwSX', - 'ÀĤ{¼' => '__pest_evaluable_ÀĤ_¼', + 'ÀĤ{¼÷' => '__pest_evaluable_ÀĤ_¼÷', + 'ìèéàòç' => '__pest_evaluable_ìèéàòç', + 'زهراء المعادي' => '__pest_evaluable_زهراء_المعادي', + 'الجبيهه' => '__pest_evaluable_الجبيهه', + 'الظهران' => '__pest_evaluable_الظهران', + 'Каролин' => '__pest_evaluable_Каролин', + 'অ্যান্টার্কটিকা' => '__pest_evaluable_অ্যান্টার্কটিকা', + 'Frýdek-Místek"' => '__pest_evaluable_Frýdek_Místek_', + 'Allingåbro&' => '__pest_evaluable_Allingåbro_', + 'Κεντροαφρικανική Δημοκρατία' => '__pest_evaluable_Κεντροαφρικανική_Δημοκρατία', + 'آذربایجان غربی' => '__pest_evaluable_آذربایجان_غربی', + 'זימבבואה' => '__pest_evaluable_זימבבואה', + 'Belišće' => '__pest_evaluable_Belišće', + 'Գվատեմալա' => '__pest_evaluable_Գվատեմալա', + 'パプアニューギニア' => '__pest_evaluable_パプアニューギニア', + '富山県' => '__pest_evaluable_富山県', + 'Қарағанды' => '__pest_evaluable_Қарағанды', + 'Қостанай' => '__pest_evaluable_Қостанай', + '안양시 동안구' => '__pest_evaluable_안양시_동안구', + 'Itālija' => '__pest_evaluable_Itālija', + 'Honningsvåg' => '__pest_evaluable_Honningsvåg', + 'Águeda' => '__pest_evaluable_Águeda', + 'Râșcani' => '__pest_evaluable_Râșcani', + 'Năsăud' => '__pest_evaluable_Năsăud', + 'Орехово-Зуево' => '__pest_evaluable_Орехово_Зуево', + 'Čereňany' => '__pest_evaluable_Čereňany', + 'Moravče' => '__pest_evaluable_Moravče', + 'Šentjernej' => '__pest_evaluable_Šentjernej', + 'Врање' => '__pest_evaluable_Врање', + 'Крушевац' => '__pest_evaluable_Крушевац', + 'Åkersberga' => '__pest_evaluable_Åkersberga', + 'บอสเนียและเฮอร์เซโกวีนา' => '__pest_evaluable_บอสเนียและเฮอร์เซโกวีนา', + 'Birleşik Arap Emirlikleri' => '__pest_evaluable_Birleşik_Arap_Emirlikleri', + 'Німеччина' => '__pest_evaluable_Німеччина', + 'Nam Định' => '__pest_evaluable_Nam_Định', + '呼和浩特' => '__pest_evaluable_呼和浩特', ]; foreach ($names as $name => $methodName) { From bcd1503cade938853a55c1283b02b6b820ea0b69 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 16:54:37 +0000 Subject: [PATCH 48/53] feat: "only" method --- composer.json | 1 + overrides/TextUI/TestSuiteFilterProcessor.php | 128 ++++++++++++++++++ src/Bootstrappers/BootOverrides.php | 1 + src/PendingCalls/TestCall.php | 11 ++ src/Plugins/Only.php | 61 +++++++++ 5 files changed, 202 insertions(+) create mode 100644 overrides/TextUI/TestSuiteFilterProcessor.php create mode 100644 src/Plugins/Only.php diff --git a/composer.json b/composer.json index 33ef9749..3685d4df 100644 --- a/composer.json +++ b/composer.json @@ -92,6 +92,7 @@ "Pest\\Plugins\\Environment", "Pest\\Plugins\\Help", "Pest\\Plugins\\Memory", + "Pest\\Plugins\\Only", "Pest\\Plugins\\Printer", "Pest\\Plugins\\ProcessIsolation", "Pest\\Plugins\\Profile", diff --git a/overrides/TextUI/TestSuiteFilterProcessor.php b/overrides/TextUI/TestSuiteFilterProcessor.php new file mode 100644 index 00000000..31ce5fe6 --- /dev/null +++ b/overrides/TextUI/TestSuiteFilterProcessor.php @@ -0,0 +1,128 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPUnit\TextUI; + +use function array_map; +use Pest\Plugins\Only; +use PHPUnit\Event; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Runner\Filter\Factory; +use PHPUnit\TextUI\Configuration\Configuration; +use PHPUnit\TextUI\Configuration\FilterNotConfiguredException; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestSuiteFilterProcessor +{ + private Factory $filterFactory; + + public function __construct(Factory $factory = new Factory) + { + $this->filterFactory = $factory; + } + + /** + * @throws Event\RuntimeException + * @throws FilterNotConfiguredException + */ + public function process(Configuration $configuration, TestSuite $suite): void + { + if (! $configuration->hasFilter() && + ! $configuration->hasGroups() && + ! $configuration->hasExcludeGroups() && + ! $configuration->hasTestsCovering() && + ! $configuration->hasTestsUsing() && + ! Only::isEnabled() + ) { + return; + } + + if ($configuration->hasExcludeGroups()) { + $this->filterFactory->addExcludeGroupFilter( + $configuration->excludeGroups() + ); + } + + if (Only::isEnabled()) { + $this->filterFactory->addIncludeGroupFilter(['__pest_only']); + } elseif ($configuration->hasGroups()) { + $this->filterFactory->addIncludeGroupFilter( + $configuration->groups() + ); + } + + if ($configuration->hasTestsCovering()) { + $this->filterFactory->addIncludeGroupFilter( + array_map( + static fn (string $name): string => '__phpunit_covers_'.$name, + $configuration->testsCovering() + ) + ); + } + + if ($configuration->hasTestsUsing()) { + $this->filterFactory->addIncludeGroupFilter( + array_map( + static fn (string $name): string => '__phpunit_uses_'.$name, + $configuration->testsUsing() + ) + ); + } + + if ($configuration->hasFilter()) { + $this->filterFactory->addNameFilter( + $configuration->filter() + ); + } + + $suite->injectFilter($this->filterFactory); + + Event\Facade::emitter()->testSuiteFiltered( + Event\TestSuite\TestSuiteBuilder::from($suite) + ); + } +} diff --git a/src/Bootstrappers/BootOverrides.php b/src/Bootstrappers/BootOverrides.php index d25f935d..e1489d7c 100644 --- a/src/Bootstrappers/BootOverrides.php +++ b/src/Bootstrappers/BootOverrides.php @@ -23,6 +23,7 @@ final class BootOverrides implements Bootstrapper 'Runner/TestSuiteLoader.php', 'TextUI/Command/WarmCodeCoverageCacheCommand.php', 'TextUI/Output/Default/ProgressPrinter/TestSkippedSubscriber.php', + 'TextUI/TestSuiteFilterProcessor.php', ]; /** diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index c793ef17..8b237ec7 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -10,6 +10,7 @@ use Pest\Factories\Covers\CoversClass; use Pest\Factories\Covers\CoversFunction; use Pest\Factories\Covers\CoversNothing; use Pest\Factories\TestCaseMethodFactory; +use Pest\Plugins\Only; use Pest\Support\Backtrace; use Pest\Support\Exporter; use Pest\Support\HigherOrderCallables; @@ -134,6 +135,16 @@ final class TestCall return $this; } + /** + * Filters the test suite by "only" tests. + */ + public function only(): self + { + Only::enable($this); + + return $this; + } + /** * Skips the current test. */ diff --git a/src/Plugins/Only.php b/src/Plugins/Only.php new file mode 100644 index 00000000..2ede1724 --- /dev/null +++ b/src/Plugins/Only.php @@ -0,0 +1,61 @@ +group('__pest_only'); + + $lockFile = self::TEMPORARY_FOLDER.DIRECTORY_SEPARATOR.'only.lock'; + + if (! file_exists($lockFile)) { + touch($lockFile); + } + } + + /** + * Checks if "only" mode is enabled. + */ + public static function isEnabled(): bool + { + $lockFile = self::TEMPORARY_FOLDER.DIRECTORY_SEPARATOR.'only.lock'; + + return file_exists($lockFile); + } +} From e1e4f8d884e7d6c40e8552b5818e171eb669ac9a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 16:57:07 +0000 Subject: [PATCH 49/53] chore: rebuilds snapshots --- src/Plugins/Only.php | 2 +- tests/.snapshots/success.txt | 48 +++++++++++++++++++++++++++++++++++- tests/Visual/Parallel.php | 2 +- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/Plugins/Only.php b/src/Plugins/Only.php index 2ede1724..aa4556b8 100644 --- a/src/Plugins/Only.php +++ b/src/Plugins/Only.php @@ -29,7 +29,7 @@ final class Only implements Shutdownable public function shutdown(): void { $lockFile = self::TEMPORARY_FOLDER.DIRECTORY_SEPARATOR.'only.lock'; - + if (file_exists($lockFile)) { unlink($lockFile); } diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 083ec696..217f831f 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -910,6 +910,52 @@ ✓ it may start with P with ('P\PPPackages\Foo', 'PPPackages\Foo') ✓ it may start with P with ('PPPackages\Foo', 'PPPackages\Foo') #1 ✓ it may start with P with ('PPPackages\Foo', 'PPPackages\Foo') #2 + ✓ ふ+が+ + ✓ ほげ + ✓ 卜竹弓一十山 + ✓ アゴデヸ + ✓ !p8VrB + ✓ &xe6VeKWF#n4 + ✓ %%HurHUnw7zM! + ✓ rundeliekend + ✓ g%%c!Jt9$fy#Kf + ✓ NRs*Gz2@hmB$W$BPD%%b2U%3P%z%apnwSX + ✓ ÀĤ{¼÷ + ✓ ìèéàòç + ✓ زهراء المعادي + ✓ الجبيهه + ✓ الظهران + ✓ Каролин + ✓ অ্যান্টার্কটিকা + ✓ Frýdek-Místek" + ✓ Allingåbro& + ✓ Κεντροαφρικανική Δημοκρατία + ✓ آذربایجان غربی + ✓ זימבבואה + ✓ Belišće + ✓ Գվատեմալա + ✓ パプアニューギニア + ✓ 富山県 + ✓ Қарағанды + ✓ Қостанай + ✓ 안양시 동안구 + ✓ Itālija + ✓ Honningsvåg + ✓ Águeda + ✓ Râșcani + ✓ Năsăud + ✓ Орехово-Зуево + ✓ Čereňany + ✓ Moravče + ✓ Šentjernej + ✓ Врање + ✓ Крушевац + ✓ Åkersberga + ✓ บอสเนียและเฮอร์เซโกวีนา + ✓ Birleşik Arap Emirlikleri + ✓ Німеччина + ✓ Nam Định + ✓ 呼和浩特 PASS Tests\Unit\TestSuite ✓ it does not allow to add the same test description twice @@ -944,4 +990,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 649 passed (1588 assertions) \ No newline at end of file + Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 695 passed (1680 assertions) \ No newline at end of file diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 16ca7396..5c770e05 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -15,6 +15,6 @@ $run = function () { }; test('parallel', function () use ($run) { - expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 640 passed (1576 assertions)') + expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 686 passed (1668 assertions)') ->toContain('Parallel: 3 processes'); })->skip(PHP_OS_FAMILY === 'Windows'); From c34f649724609e5b6f9685e2723c38553997dab6 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 17:04:03 +0000 Subject: [PATCH 50/53] release: v2.1.0 --- CHANGELOG.md | 8 ++++++++ src/Pest.php | 2 +- tests/.snapshots/help-command.txt | 2 +- tests/.snapshots/version-command.txt | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8972013..811f5e15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +## [v2.1.0 (2023-03-21)](https://github.com/pestphp/pest/compare/v2.0.2...v2.1.0) + +### Added +- `only` test case method ([bcd1503](https://github.com/pestphp/pest/commit/bcd1503cade938853a55c1283b02b6b820ea0b69)) + +### Fixed +- Issues with different characters on test names ([715](https://github.com/pestphp/pest/pull/715)) + ## [v2.0.2 (2023-03-20)](https://github.com/pestphp/pest/compare/v2.0.1...v2.0.2) ### Fixed diff --git a/src/Pest.php b/src/Pest.php index d0fa2ff3..32978f6e 100644 --- a/src/Pest.php +++ b/src/Pest.php @@ -6,7 +6,7 @@ namespace Pest; function version(): string { - return '2.0.2'; + return '2.1.0'; } function testDirectory(string $file = ''): string diff --git a/tests/.snapshots/help-command.txt b/tests/.snapshots/help-command.txt index aa7cf29f..2ebc633d 100644 --- a/tests/.snapshots/help-command.txt +++ b/tests/.snapshots/help-command.txt @@ -1,5 +1,5 @@ - Pest Testing Framework 2.0.2. + Pest Testing Framework 2.1.0. USAGE: pest [options] diff --git a/tests/.snapshots/version-command.txt b/tests/.snapshots/version-command.txt index 0ad97038..a50a10ae 100644 --- a/tests/.snapshots/version-command.txt +++ b/tests/.snapshots/version-command.txt @@ -1,3 +1,3 @@ - Pest Testing Framework 2.0.2. + Pest Testing Framework 2.1.0. From 077ed287b779180f2cfefccd4b8047f06080812a Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 20:33:39 +0000 Subject: [PATCH 51/53] chore: updates snapshots --- tests/.snapshots/success.txt | 2 +- tests/Visual/Parallel.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 2db57d3f..23581808 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -994,4 +994,4 @@ PASS Tests\Visual\Version ✓ visual snapshot of help command output - Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 695 passed (1680 assertions) + Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 12 skipped, 699 passed (1696 assertions) \ No newline at end of file diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 5c770e05..0d9117cd 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -15,6 +15,6 @@ $run = function () { }; test('parallel', function () use ($run) { - expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 686 passed (1668 assertions)') + expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 9 skipped, 690 passed (1684 assertions)') ->toContain('Parallel: 3 processes'); })->skip(PHP_OS_FAMILY === 'Windows'); From 14dd5cb57b9432300ac4e8095f069941cb43bdb5 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 21:05:11 +0000 Subject: [PATCH 52/53] fix: test result on parallel --- composer.json | 2 +- src/Kernel.php | 7 ++++++- .../Parallel/Paratest/WrapperRunner.php | 11 ++--------- src/Result.php | 18 +++++++----------- tests/.snapshots/Failure.php.inc | 4 ++-- 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 3685d4df..c7140ad6 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": "^8.1.0", "brianium/paratest": "^7.1.2", - "nunomaduro/collision": "^7.3.1", + "nunomaduro/collision": "^7.3.2", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.0.0", "pestphp/pest-plugin-arch": "^2.0.1", diff --git a/src/Kernel.php b/src/Kernel.php index b56d32bd..0aeb8155 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -11,7 +11,9 @@ use Pest\Plugins\Actions\CallsBoot; use Pest\Plugins\Actions\CallsHandleArguments; use Pest\Plugins\Actions\CallsShutdown; use Pest\Support\Container; +use PHPUnit\TestRunner\TestResult\Facade; use PHPUnit\TextUI\Application; +use PHPUnit\TextUI\Configuration\Registry; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -90,8 +92,11 @@ final class Kernel ]); } + $configuration = Registry::get(); + $result = Facade::result(); + return CallsAddsOutput::execute( - Result::exitCode(), + Result::exitCode($configuration, $result), ); } diff --git a/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 717dfcb9..bec0dd5a 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -20,13 +20,13 @@ use ParaTest\Options; use ParaTest\RunnerInterface; use ParaTest\WrapperRunner\SuiteLoader; use ParaTest\WrapperRunner\WrapperWorker; +use Pest\Result; use Pest\TestSuite; use PHPUnit\Event\Facade as EventFacade; use PHPUnit\Runner\CodeCoverage; use PHPUnit\TestRunner\TestResult\Facade as TestResultFacade; use PHPUnit\TestRunner\TestResult\TestResult; use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry; -use PHPUnit\TextUI\ShellExitCodeCalculator; use PHPUnit\Util\ExcludeList; use function realpath; use SebastianBergmann\Timer\Timer; @@ -330,14 +330,7 @@ final class WrapperRunner implements RunnerInterface $this->generateCodeCoverageReports(); $this->generateLogs(); - $exitCode = (new ShellExitCodeCalculator())->calculate( - $this->options->configuration->failOnEmptyTestSuite(), - $this->options->configuration->failOnRisky(), - $this->options->configuration->failOnWarning(), - $this->options->configuration->failOnIncomplete(), - $this->options->configuration->failOnSkipped(), - $testResultSum, - ); + $exitCode = Result::exitCode($this->options->configuration, $testResultSum); $this->clearFiles($this->testresultFiles); $this->clearFiles($this->coverageFiles); diff --git a/src/Result.php b/src/Result.php index 4a613d29..9f0b6382 100644 --- a/src/Result.php +++ b/src/Result.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Pest; -use PHPUnit\TestRunner\TestResult\Facade; -use PHPUnit\TextUI\Configuration\Registry; +use PHPUnit\TestRunner\TestResult\TestResult; +use PHPUnit\TextUI\Configuration\Configuration; /** * @internal @@ -21,26 +21,24 @@ final class Result /** * If the exit code is different from 0. */ - public static function failed(): bool + public static function failed(Configuration $configuration, TestResult $result): bool { - return ! self::ok(); + return ! self::ok($configuration, $result); } /** * If the exit code is exactly 0. */ - public static function ok(): bool + public static function ok(Configuration $configuration, TestResult $result): bool { - return self::exitCode() === self::SUCCESS_EXIT; + return self::exitCode($configuration, $result) === self::SUCCESS_EXIT; } /** * Get the test execution's exit code. */ - public static function exitCode(): int + public static function exitCode(Configuration $configuration, TestResult $result): int { - $result = Facade::result(); - $returnCode = self::FAILURE_EXIT; if ($result->wasSuccessfulIgnoringPhpunitWarnings() @@ -48,8 +46,6 @@ final class Result $returnCode = self::SUCCESS_EXIT; } - $configuration = Registry::get(); - if ($configuration->failOnEmptyTestSuite() && $result->numberOfTests() === 0) { $returnCode = self::FAILURE_EXIT; } diff --git a/tests/.snapshots/Failure.php.inc b/tests/.snapshots/Failure.php.inc index 419c3b5d..ee55ce3d 100644 --- a/tests/.snapshots/Failure.php.inc +++ b/tests/.snapshots/Failure.php.inc @@ -1,6 +1,6 @@ ##teamcity[testSuiteStarted name='Tests/tests/Failure' locationHint='file://tests/.tests/Failure.php' flowId='1234'] ##teamcity[testStarted name='it can fail with comparison' locationHint='pest_qn://tests/.tests/Failure.php::it can fail with comparison' flowId='1234'] -##teamcity[testFailed name='it can fail with comparison' message='Failed asserting that true matches expected false.' details='at src/Mixins/Expectation.php:342|nat src/Support/ExpectationPipeline.php:75|nat src/Support/ExpectationPipeline.php:79|nat src/Expectation.php:300|nat tests/.tests/Failure.php:6|nat src/Factories/TestCaseMethodFactory.php:100|nat src/Concerns/Testable.php:272|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:272|nat src/Concerns/Testable.php:215|nat src/Kernel.php:84' type='comparisonFailure' actual='true' expected='false' flowId='1234'] +##teamcity[testFailed name='it can fail with comparison' message='Failed asserting that true matches expected false.' details='at src/Mixins/Expectation.php:342|nat src/Support/ExpectationPipeline.php:75|nat src/Support/ExpectationPipeline.php:79|nat src/Expectation.php:300|nat tests/.tests/Failure.php:6|nat src/Factories/TestCaseMethodFactory.php:100|nat src/Concerns/Testable.php:272|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:272|nat src/Concerns/Testable.php:215|nat src/Kernel.php:86' type='comparisonFailure' actual='true' expected='false' flowId='1234'] ##teamcity[testFinished name='it can fail with comparison' duration='100000' flowId='1234'] ##teamcity[testStarted name='it can be ignored because of no assertions' locationHint='pest_qn://tests/.tests/Failure.php::it can be ignored because of no assertions' flowId='1234'] ##teamcity[testIgnored name='it can be ignored because of no assertions' message='This test did not perform any assertions' details='' flowId='1234'] @@ -9,7 +9,7 @@ ##teamcity[testIgnored name='it can be ignored because it is skipped' message='This test was ignored.' details='' flowId='1234'] ##teamcity[testFinished name='it can be ignored because it is skipped' duration='100000' flowId='1234'] ##teamcity[testStarted name='it can fail' locationHint='pest_qn://tests/.tests/Failure.php::it can fail' flowId='1234'] -##teamcity[testFailed name='it can fail' message='oh noo' details='at tests/.tests/Failure.php:18|nat src/Factories/TestCaseMethodFactory.php:100|nat src/Concerns/Testable.php:272|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:272|nat src/Concerns/Testable.php:215|nat src/Kernel.php:84' flowId='1234'] +##teamcity[testFailed name='it can fail' message='oh noo' details='at tests/.tests/Failure.php:18|nat src/Factories/TestCaseMethodFactory.php:100|nat src/Concerns/Testable.php:272|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:272|nat src/Concerns/Testable.php:215|nat src/Kernel.php:86' flowId='1234'] ##teamcity[testFinished name='it can fail' duration='100000' flowId='1234'] ##teamcity[testStarted name='it is not done yet' locationHint='pest_qn://tests/.tests/Failure.php::it is not done yet' flowId='1234'] ##teamcity[testIgnored name='it is not done yet' message='This test was ignored.' details='' flowId='1234'] From f914f1ad8700c177baad8732663aaa6476cc6880 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 21 Mar 2023 21:07:57 +0000 Subject: [PATCH 53/53] fix: adds `--parallel` option to help --- src/Plugins/Help.php | 7 +++++++ tests/.snapshots/help-command.txt | 1 + 2 files changed, 8 insertions(+) diff --git a/src/Plugins/Help.php b/src/Plugins/Help.php index 22f1c9eb..1bb9a9cb 100644 --- a/src/Plugins/Help.php +++ b/src/Plugins/Help.php @@ -102,6 +102,13 @@ final class Help implements HandlesArguments 'desc' => 'Initialise a standard Pest configuration', ]], ...$content['Configuration']]; + $content['Execution'] = [...[ + [ + 'arg' => '--parallel', + 'desc' => 'Run tests in parallel', + ], + ], ...$content['Execution']]; + $content['Selection'] = array_merge([ [ 'arg' => '--bail', diff --git a/tests/.snapshots/help-command.txt b/tests/.snapshots/help-command.txt index 2ebc633d..29a62394 100644 --- a/tests/.snapshots/help-command.txt +++ b/tests/.snapshots/help-command.txt @@ -33,6 +33,7 @@ --test-suffix [suffixes] Only search for test in files with specified suffix(es). Default: Test.php,.phpt EXECUTION OPTIONS: + --parallel ........................................... Run tests in parallel --process-isolation ................ Run each test in a separate PHP process --globals-backup ................. Backup and restore $GLOBALS for each test --static-backup ......... Backup and restore static properties for each test