Compare commits

...

28 Commits
v2.35.0 ... 2.x

Author SHA1 Message Date
d66361b272 release: 2.36.1 2026-01-28 02:02:41 +00:00
93b5611059 chore: deprecates php 8.1 2026-01-28 01:55:42 +00:00
2ded999adf chore: bumps dependencies 2026-01-28 01:51:26 +00:00
cde074cfd4 chore: removes static jobs 2026-01-28 01:36:09 +00:00
499480f28a chore: only runs CI against stable 2026-01-28 01:34:18 +00:00
f8c88bd14d chore: requires latest versions of collision and termwind 2024-10-15 16:30:56 +01:00
d454a36a48 removes non reported error 2024-10-15 15:34:49 +01:00
61b6b8c7d9 release: v2.36.0 2024-10-15 15:31:46 +01:00
e8aaa586cb feat: php 8.4 support 2024-10-15 15:31:29 +01:00
9ceb0834ae chore: updates snapshots 2024-08-22 21:07:39 +01:00
86d2191cae chore: refactor TestClosureMustNotBeStatic 2024-08-22 20:59:42 +01:00
748beb17d5 chore: adjusts memory limit 2024-08-22 20:59:42 +01:00
7ba235f61a Merge pull request #1129 from tomb1n0/bugfix/alwaysCallTeardownRegardlessOfExceptions
[Bug] Always call parent teardown even if an exception is thrown
2024-08-22 20:50:59 +01:00
700bd517f4 Merge pull request #1117 from peterfox/bug/catch-static-closures
[Bug] provided explaination for static closures
2024-08-22 20:33:58 +01:00
cbcfa2c5e2 Merge pull request #1100 from faissaloux/fix-use-strict-types
Fix `toUseStrictTypes`
2024-08-22 20:32:21 +01:00
243e45a551 Merge pull request #1097 from arifszn/2.x
[2.x] Modify `Result::exitCode` logic to address warning handling with `--fail-on-warning`
2024-08-22 20:31:34 +01:00
823c3d4b17 chore: updates snapshots 2024-08-20 22:49:23 +01:00
39c9b15bc0 Update visual_snapshot_of_help_command_output.snap 2024-08-20 22:44:39 +01:00
b13acb630d release: 2.35.1 2024-08-20 22:41:50 +01:00
172d94c0ca chore: bumps depedencies 2024-08-20 22:41:07 +01:00
0697555dc2 chore: adjusts sponsors 2024-08-05 10:42:52 +01:00
adb2fb51df Always call parent teardown even if an exception is thrown 2024-04-08 10:03:55 +01:00
0ccbe5c8f0 Remove Laravel serialisable closure 2024-03-17 17:23:17 +00:00
a4f8ae1a12 Handles tests where a static closure is provided 2024-03-17 16:48:43 +00:00
6094682158 Add static closure check 2024-03-17 12:04:38 +00:00
2c3234fb3d fix bool type 2024-02-21 17:09:16 +01:00
1b64fef7ba fix toUseStrictTypes 2024-02-21 16:58:40 +01:00
a136231503 fix: modify Result::exitCode logic to address warning handling with --fail-on-warning 2024-02-20 18:24:37 +06:00
21 changed files with 114 additions and 188 deletions

View File

@ -1,44 +0,0 @@
name: Static Analysis
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
static:
if: github.event_name != 'schedule' || github.repository == 'pestphp/pest'
name: Static Tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
dependency-version: [prefer-lowest, prefer-stable]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer:v2
coverage: none
- name: Install Dependencies
run: composer update --prefer-stable --no-interaction --no-progress --ansi
- name: Type Check
run: composer test:type:check
- name: Type Coverage
run: composer test:type:coverage
- name: Refacto
run: composer test:refacto
- name: Style
run: composer test:lint

View File

@ -14,11 +14,8 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
symfony: ['6.4', '7.0'] symfony: ['6.4', '7.0']
php: ['8.1', '8.2', '8.3'] php: ['8.2', '8.3', '8.4']
dependency_version: [prefer-lowest, prefer-stable] dependency_version: [prefer-stable]
exclude:
- php: '8.1'
symfony: '7.0'
name: PHP ${{ matrix.php }} - Symfony ^${{ matrix.symfony }} - ${{ matrix.os }} - ${{ matrix.dependency_version }} name: PHP ${{ matrix.php }} - Symfony ^${{ matrix.symfony }} - ${{ matrix.os }} - ${{ matrix.dependency_version }}

View File

@ -31,8 +31,10 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
- [Akaunting](https://akaunting.com/?ref=pestphp) - [Akaunting](https://akaunting.com/?ref=pestphp)
- [Codecourse](https://codecourse.com/?ref=pestphp) - [Codecourse](https://codecourse.com/?ref=pestphp)
- [DocuWriter.ai](https://www.docuwriter.ai/?ref=pestphp)
- [Laracasts](https://laracasts.com/?ref=pestphp) - [Laracasts](https://laracasts.com/?ref=pestphp)
- [Localazy](https://localazy.com/?ref=pestphp) - [Localazy](https://localazy.com/?ref=pestphp)
- [Route4Me](https://www.route4me.com/?ref=pestphp)
- [Zapiet](https://www.zapiet.com/?ref=pestphp) - [Zapiet](https://www.zapiet.com/?ref=pestphp)
Pest is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**. Pest is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

View File

@ -17,16 +17,17 @@
} }
], ],
"require": { "require": {
"php": "^8.1.0", "php": "^8.2.0",
"brianium/paratest": "^7.3.1", "brianium/paratest": "^7.4.9",
"nunomaduro/collision": "^7.10.0|^8.3.0", "nunomaduro/collision": "^7.11.0|^8.5.0",
"nunomaduro/termwind": "^1.15.1|^2.0.1", "nunomaduro/termwind": "^1.16.0|^2.3.3",
"pestphp/pest-plugin": "^2.1.1", "pestphp/pest-plugin": "^2.1.1",
"pestphp/pest-plugin-arch": "^2.7.0", "pestphp/pest-plugin-arch": "^2.7.0",
"phpunit/phpunit": "^10.5.17" "phpunit/phpunit": "^10.5.63"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": ">10.5.17", "filp/whoops": "<2.16.0",
"phpunit/phpunit": ">10.5.63",
"sebastian/exporter": "<5.1.0", "sebastian/exporter": "<5.1.0",
"webmozart/assert": "<1.11.0" "webmozart/assert": "<1.11.0"
}, },
@ -51,9 +52,9 @@
] ]
}, },
"require-dev": { "require-dev": {
"pestphp/pest-dev-tools": "^2.16.0", "pestphp/pest-dev-tools": "^2.17.0",
"pestphp/pest-plugin-type-coverage": "^2.8.5", "pestphp/pest-plugin-type-coverage": "^2.8.7",
"symfony/process": "^6.4.0|^7.1.3" "symfony/process": "^6.4.0|^7.4.4"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,
@ -68,22 +69,12 @@
"bin/pest" "bin/pest"
], ],
"scripts": { "scripts": {
"refacto": "rector",
"lint": "pint",
"test:refacto": "rector --dry-run",
"test:lint": "pint --test",
"test:type:check": "phpstan analyse --ansi --memory-limit=-1 --debug",
"test:type:coverage": "php bin/pest --type-coverage --min=100",
"test:unit": "php bin/pest --colors=always --exclude-group=integration --compact", "test:unit": "php bin/pest --colors=always --exclude-group=integration --compact",
"test:inline": "php bin/pest --colors=always --configuration=phpunit.inline.xml", "test:inline": "php bin/pest --colors=always --configuration=phpunit.inline.xml",
"test:parallel": "php bin/pest --colors=always --exclude-group=integration --parallel --processes=3", "test:parallel": "php bin/pest --colors=always --exclude-group=integration --parallel --processes=3",
"test:integration": "php bin/pest --colors=always --group=integration", "test:integration": "php bin/pest --colors=always --group=integration",
"update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always --update-snapshots", "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always --update-snapshots",
"test": [ "test": [
"@test:refacto",
"@test:lint",
"@test:type:check",
"@test:type:coverage",
"@test:unit", "@test:unit",
"@test:parallel", "@test:parallel",
"@test:integration" "@test:integration"

View File

@ -1,6 +1,5 @@
includes: includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/ergebnis/phpstan-rules/rules.neon
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
parameters: parameters:
@ -12,12 +11,4 @@ parameters:
reportUnmatchedIgnoredErrors: true reportUnmatchedIgnoredErrors: true
ignoreErrors: ignoreErrors:
- "#has a nullable return type declaration.#"
- "#Language construct isset\\(\\) should not be used.#"
- "#is not allowed to extend#"
- "#is concrete, but does not have a Test suffix#"
- "#with a nullable type declaration#"
- "#type mixed is not subtype of native#" - "#type mixed is not subtype of native#"
- "# with null as default value#"
- "#has parameter \\$closure with default value.#"
- "#has parameter \\$description with default value.#"

View File

@ -234,11 +234,13 @@ trait Testable
$afterEach = ChainableClosure::bound($this->__afterEach, $afterEach); $afterEach = ChainableClosure::bound($this->__afterEach, $afterEach);
} }
$this->__callClosure($afterEach, func_get_args()); try {
$this->__callClosure($afterEach, func_get_args());
} finally {
parent::tearDown();
parent::tearDown(); TestSuite::getInstance()->test = null;
}
TestSuite::getInstance()->test = null;
} }
/** /**

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Pest\Exceptions;
use InvalidArgumentException;
use NunoMaduro\Collision\Contracts\RenderlessEditor;
use NunoMaduro\Collision\Contracts\RenderlessTrace;
use Pest\Factories\TestCaseMethodFactory;
use Symfony\Component\Console\Exception\ExceptionInterface;
/**
* @internal
*/
final class TestClosureMustNotBeStatic extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace
{
/**
* Creates a new Exception instance.
*/
public function __construct(TestCaseMethodFactory $method)
{
parent::__construct(
sprintf(
'Test closure must not be static. Please remove the `static` keyword from the `%s` method in `%s`.',
$method->description,
$method->filename
)
);
}
}

View File

@ -441,7 +441,7 @@ final class Expectation
{ {
return Targeted::make( return Targeted::make(
$this, $this,
fn (ObjectDescription $object): bool => str_contains((string) file_get_contents($object->path), 'declare(strict_types=1);'), fn (ObjectDescription $object): bool => (bool) preg_match('/^<\?php\s+declare\(.*?strict_types\s?=\s?1.*?\);/', (string) file_get_contents($object->path)),
'to use strict types', 'to use strict types',
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')), FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
); );

View File

@ -82,7 +82,7 @@ final class OppositeExpectation
{ {
return Targeted::make( return Targeted::make(
$this->original, $this->original,
fn (ObjectDescription $object): bool => ! str_contains((string) file_get_contents($object->path), 'declare(strict_types=1);'), fn (ObjectDescription $object): bool => ! (bool) preg_match('/^<\?php\s+declare\(.*?strict_types\s?=\s?1.*?\);/', (string) file_get_contents($object->path)),
'not to use strict types', 'not to use strict types',
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')), FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
); );

View File

@ -20,7 +20,7 @@ abstract class Attribute
* @param array<int, string> $attributes * @param array<int, string> $attributes
* @return array<int, string> * @return array<int, string>
*/ */
public function __invoke(TestCaseMethodFactory $method, array $attributes): array // @phpstan-ignore-line public function __invoke(TestCaseMethodFactory $method, array $attributes): array
{ {
return $attributes; return $attributes;
} }

View File

@ -11,6 +11,7 @@ use Pest\Contracts\HasPrintableTestCaseName;
use Pest\Exceptions\DatasetMissing; use Pest\Exceptions\DatasetMissing;
use Pest\Exceptions\ShouldNotHappen; use Pest\Exceptions\ShouldNotHappen;
use Pest\Exceptions\TestAlreadyExist; use Pest\Exceptions\TestAlreadyExist;
use Pest\Exceptions\TestClosureMustNotBeStatic;
use Pest\Exceptions\TestDescriptionMissing; use Pest\Exceptions\TestDescriptionMissing;
use Pest\Factories\Concerns\HigherOrderable; use Pest\Factories\Concerns\HigherOrderable;
use Pest\Support\Reflection; use Pest\Support\Reflection;
@ -193,7 +194,7 @@ final class TestCaseFactory
} }
PHP; PHP;
eval($classCode); // @phpstan-ignore-line eval($classCode);
} catch (ParseError $caught) { } catch (ParseError $caught) {
throw new RuntimeException(sprintf( throw new RuntimeException(sprintf(
"Unable to create test case for test file at %s. \n %s", "Unable to create test case for test file at %s. \n %s",
@ -216,6 +217,14 @@ final class TestCaseFactory
throw new TestAlreadyExist($method->filename, $method->description); throw new TestAlreadyExist($method->filename, $method->description);
} }
if (
$method->closure instanceof \Closure &&
(new \ReflectionFunction($method->closure))->isStatic()
) {
throw new TestClosureMustNotBeStatic($method);
}
if (! $method->receivesArguments()) { if (! $method->receivesArguments()) {
if (! $method->closure instanceof \Closure) { if (! $method->closure instanceof \Closure) {
throw ShouldNotHappen::fromMessage('The test closure may not be empty.'); throw ShouldNotHappen::fromMessage('The test closure may not be empty.');

View File

@ -40,7 +40,7 @@ final class KernelDump
*/ */
public function disable(): void public function disable(): void
{ {
@ob_clean(); // @phpstan-ignore-line @ob_clean();
if ($this->buffer !== '') { if ($this->buffer !== '') {
$this->flush(); $this->flush();

View File

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

View File

@ -40,28 +40,31 @@ final class Result
*/ */
public static function exitCode(Configuration $configuration, TestResult $result): int public static function exitCode(Configuration $configuration, TestResult $result): int
{ {
if ($result->wasSuccessfulIgnoringPhpunitWarnings() if ($result->wasSuccessful()) {
&& ! $result->hasTestTriggeredPhpunitWarningEvents()) { if ($configuration->failOnWarning()) {
return self::SUCCESS_EXIT; $warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents()
+ count($result->warnings())
+ count($result->phpWarnings());
if ($warnings > 0) {
return self::FAILURE_EXIT;
}
}
if (! $result->hasTestTriggeredPhpunitWarningEvents()) {
return self::SUCCESS_EXIT;
}
} }
if ($configuration->failOnEmptyTestSuite() && ResultReflection::numberOfTests($result) === 0) { if ($configuration->failOnEmptyTestSuite() && ResultReflection::numberOfTests($result) === 0) {
return self::FAILURE_EXIT; return self::FAILURE_EXIT;
} }
if ($result->wasSuccessfulIgnoringPhpunitWarnings()) { if ($result->wasSuccessful()) {
if ($configuration->failOnRisky() && $result->hasTestConsideredRiskyEvents()) { if ($configuration->failOnRisky() && $result->hasTestConsideredRiskyEvents()) {
$returnCode = self::FAILURE_EXIT; $returnCode = self::FAILURE_EXIT;
} }
$warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents()
+ count($result->warnings())
+ count($result->phpWarnings());
if ($configuration->failOnWarning() && $warnings > 0) {
$returnCode = self::FAILURE_EXIT;
}
if ($configuration->failOnIncomplete() && $result->hasTestMarkedIncompleteEvents()) { if ($configuration->failOnIncomplete() && $result->hasTestMarkedIncompleteEvents()) {
$returnCode = self::FAILURE_EXIT; $returnCode = self::FAILURE_EXIT;
} }

View File

@ -1,5 +1,5 @@
Pest Testing Framework 2.35.0. Pest Testing Framework 2.36.1.
USAGE: pest <file> [options] USAGE: pest <file> [options]
@ -45,7 +45,7 @@
--disallow-test-output ................. Be strict about output during tests --disallow-test-output ................. Be strict about output during tests
--enforce-time-limit ................. Enforce time limit based on test size --enforce-time-limit ................. Enforce time limit based on test size
--default-time-limit [sec] Timeout in seconds for tests that have no declared size --default-time-limit [sec] Timeout in seconds for tests that have no declared size
--dont-report-useless-tests .. Do not report tests that do not test anything --do-not-report-useless-tests Do not report tests that do not test anything
--stop-on-defect ... Stop after first error, failure, warning, or risky test --stop-on-defect ... Stop after first error, failure, warning, or risky test
--stop-on-error ..................................... Stop after first error --stop-on-error ..................................... Stop after first error
--stop-on-failure ................................. Stop after first failure --stop-on-failure ................................. Stop after first failure
@ -59,9 +59,21 @@
--fail-on-warning Signal failure using shell exit code when a warning was triggered --fail-on-warning Signal failure using shell exit code when a warning was triggered
--fail-on-risky Signal failure using shell exit code when a test was considered risky --fail-on-risky Signal failure using shell exit code when a test was considered risky
--fail-on-deprecation Signal failure using shell exit code when a deprecation was triggered --fail-on-deprecation Signal failure using shell exit code when a deprecation was triggered
--fail-on-phpunit-deprecation Signal failure using shell exit code when a PHPUnit deprecation was triggered
--fail-on-phpunit-warning Signal failure using shell exit code when a PHPUnit warning was triggered
--fail-on-notice Signal failure using shell exit code when a notice was triggered --fail-on-notice Signal failure using shell exit code when a notice was triggered
--fail-on-skipped Signal failure using shell exit code when a test was skipped --fail-on-skipped Signal failure using shell exit code when a test was skipped
--fail-on-incomplete Signal failure using shell exit code when a test was marked incomplete --fail-on-incomplete Signal failure using shell exit code when a test was marked incomplete
--fail-on-all-issues Signal failure using shell exit code when an issue is triggered
--do-not-fail-on-empty-test-suite Do not signal failure using shell exit code when no tests were run
--do-not-fail-on-warning Do not signal failure using shell exit code when a warning was triggered
--do-not-fail-on-risky Do not signal failure using shell exit code when a test was considered risky
--do-not-fail-on-deprecation Do not signal failure using shell exit code when a deprecation was triggered
--do-not-fail-on-phpunit-deprecation Do not signal failure using shell exit code when a PHPUnit deprecation was triggered
--do-not-fail-on-phpunit-warning Do not signal failure using shell exit code when a PHPUnit warning was triggered
--do-not-fail-on-notice Do not signal failure using shell exit code when a notice was triggered
--do-not-fail-on-skipped Do not signal failure using shell exit code when a test was skipped
--do-not-fail-on-incomplete Do not signal failure using shell exit code when a test was marked incomplete
--cache-result ............................ Write test results to cache file --cache-result ............................ Write test results to cache file
--do-not-cache-result .............. Do not write test results to cache file --do-not-cache-result .............. Do not write test results to cache file
--order-by [order] Run tests in order: default|defects|depends|duration|no-depends|random|reverse|size --order-by [order] Run tests in order: default|defects|depends|duration|no-depends|random|reverse|size
@ -78,9 +90,11 @@
--display-incomplete .................. Display details for incomplete tests --display-incomplete .................. Display details for incomplete tests
--display-skipped ........................ Display details for skipped tests --display-skipped ........................ Display details for skipped tests
--display-deprecations . Display details for deprecations triggered by tests --display-deprecations . Display details for deprecations triggered by tests
--display-phpunit-deprecations .... Display details for PHPUnit deprecations
--display-errors ............. Display details for errors triggered by tests --display-errors ............. Display details for errors triggered by tests
--display-notices ........... Display details for notices triggered by tests --display-notices ........... Display details for notices triggered by tests
--display-warnings ......... Display details for warnings triggered by tests --display-warnings ......... Display details for warnings triggered by tests
--display-all-issues ..... Display details for all issues that are triggered
--reverse-list .............................. Print defects in reverse order --reverse-list .............................. Print defects in reverse order
--teamcity . Replace default progress and result output with TeamCity format --teamcity . Replace default progress and result output with TeamCity format
--testdox ................ Replace default result output with TestDox format --testdox ................ Replace default result output with TestDox format
@ -105,6 +119,8 @@
--coverage-html [dir] Write code coverage report in HTML format to directory --coverage-html [dir] Write code coverage report in HTML format to directory
--coverage-php [file] .......... Write serialized code coverage data to file --coverage-php [file] .......... Write serialized code coverage data to file
--coverage-text=[file] Write code coverage report in text format to file [default: standard output] --coverage-text=[file] Write code coverage report in text format to file [default: standard output]
--only-summary-for-coverage-text Option for code coverage report in text format: only show summary
--show-uncovered-for-coverage-text Option for code coverage report in text format: show uncovered files
--coverage-xml [dir] . Write code coverage report in XML format to directory --coverage-xml [dir] . Write code coverage report in XML format to directory
--warm-coverage-cache ........................... Warm static analysis cache --warm-coverage-cache ........................... Warm static analysis cache
--coverage-filter [dir] ........... Include [dir] in code coverage reporting --coverage-filter [dir] ........... Include [dir] in code coverage reporting

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.35.0. Pest Testing Framework 2.36.1.

View File

@ -1173,16 +1173,6 @@
PASS Tests\Hooks\BeforeEachTest PASS Tests\Hooks\BeforeEachTest
✓ global beforeEach execution order ✓ global beforeEach execution order
PASS Tests\Overrides\VersionsTest
✓ versions with dataset "Runner/Filter/NameFilterIterator.php"
✓ versions with dataset "Runner/ResultCache/DefaultResultCache.php"
✓ versions with dataset "Runner/TestSuiteLoader.php"
✓ versions with dataset "TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php"
✓ versions with dataset "TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php"
✓ versions with dataset "TextUI/TestSuiteFilterProcessor.php"
✓ versions with dataset "Event/Value/ThrowableBuilder.php"
✓ versions with dataset "Logging/JUnit/JunitXmlLogger.php"
PASS Tests\PHPUnit\CustomAffixes\InvalidTestName PASS Tests\PHPUnit\CustomAffixes\InvalidTestName
✓ it runs file names like @#$%^&()-_=+.php ✓ it runs file names like @#$%^&()-_=+.php
@ -1287,26 +1277,6 @@
✓ it can resolve builtin value types ✓ it can resolve builtin value types
✓ it cannot resolve a parameter without type ✓ it cannot resolve a parameter without type
PASS Tests\Unit\Support\DatasetInfo
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Datase…rs.php', true)
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Datasets.php', false)
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…rs.php', true)
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…rs.php', false)
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…ts.php', false)
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Datase…rs.php', false)
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Datasets.php', true)
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…rs.php', false) #1
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…rs.php', false) #2
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…ts.php', true)
✓ it computes the dataset scope with ('/var/www/project/tests/Datase…rs.php', '/var/www/project/tests')
✓ it computes the dataset scope with ('/var/www/project/tests/Datasets.php', '/var/www/project/tests')
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Features')
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…rs.php') #1
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…ts.php', '/var/www/project/tests/Features')
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…ollers')
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…rs.php') #2
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…ts.php', '/var/www/project/tests/Featur…ollers')
PASS Tests\Unit\Support\ExceptionTrace PASS Tests\Unit\Support\ExceptionTrace
✓ it ensures the given closures reports the correct class name ✓ it ensures the given closures reports the correct class name
✓ it ensures the given closures reports the correct class name and suggests the [uses()] function ✓ it ensures the given closures reports the correct class name and suggests the [uses()] function
@ -1381,6 +1351,7 @@
PASS Tests\Unit\TestSuite PASS Tests\Unit\TestSuite
✓ it does not allow to add the same test description twice ✓ it does not allow to add the same test description twice
✓ it does not allow static closures
✓ it alerts users about tests with arguments but no input ✓ it alerts users about tests with arguments but no input
✓ it can return an array of all test suite filenames ✓ it can return an array of all test suite filenames
@ -1424,4 +1395,4 @@
WARN Tests\Visual\Version WARN Tests\Visual\Version
- visual snapshot of help command output - visual snapshot of help command output
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1013 passed (2405 assertions) Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 988 passed (2381 assertions)

View File

@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
use Pest\Bootstrappers\BootOverrides;
test('versions', function (string $vendorPath, string $expectedHash) {
expect(hash_file('sha256', $vendorPath))->toBe($expectedHash);
})->with(function () {
foreach (BootOverrides::FILES as $hash => $file) {
$path = implode(DIRECTORY_SEPARATOR, [
dirname(__DIR__, 2),
'vendor/phpunit/phpunit/src',
$file,
]);
yield $file => [$path, $hash];
}
});

View File

@ -1,36 +0,0 @@
<?php
use Pest\Support\DatasetInfo;
it('can check if dataset is defined inside a Datasets directory', function (string $file, bool $inside) {
expect(DatasetInfo::isInsideADatasetsDirectory($file))->toBe($inside);
})->with([
['file' => '/var/www/project/tests/Datasets/Numbers.php', 'inside' => true],
['file' => '/var/www/project/tests/Datasets.php', 'inside' => false],
['file' => '/var/www/project/tests/Features/Datasets/Numbers.php', 'inside' => true],
['file' => '/var/www/project/tests/Features/Numbers.php', 'inside' => false],
['file' => '/var/www/project/tests/Features/Datasets.php', 'inside' => false],
]);
it('can check if dataset is defined inside a Datasets.php file', function (string $path, bool $inside) {
expect(DatasetInfo::isADatasetsFile($path))->toBe($inside);
})->with([
['file' => '/var/www/project/tests/Datasets/Numbers.php', 'inside' => false],
['file' => '/var/www/project/tests/Datasets.php', 'inside' => true],
['file' => '/var/www/project/tests/Features/Datasets/Numbers.php', 'inside' => false],
['file' => '/var/www/project/tests/Features/Numbers.php', 'inside' => false],
['file' => '/var/www/project/tests/Features/Datasets.php', 'inside' => true],
]);
it('computes the dataset scope', function (string $file, string $scope) {
expect(DatasetInfo::scope($file))->toBe($scope);
})->with([
['file' => '/var/www/project/tests/Datasets/Numbers.php', 'scope' => '/var/www/project/tests'],
['file' => '/var/www/project/tests/Datasets.php', 'scope' => '/var/www/project/tests'],
['file' => '/var/www/project/tests/Features/Datasets/Numbers.php', 'scope' => '/var/www/project/tests/Features'],
['file' => '/var/www/project/tests/Features/Numbers.php', 'scope' => '/var/www/project/tests/Features/Numbers.php'],
['file' => '/var/www/project/tests/Features/Datasets.php', 'scope' => '/var/www/project/tests/Features'],
['file' => '/var/www/project/tests/Features/Controllers/Datasets/Numbers.php', 'scope' => '/var/www/project/tests/Features/Controllers'],
['file' => '/var/www/project/tests/Features/Controllers/Numbers.php', 'scope' => '/var/www/project/tests/Features/Controllers/Numbers.php'],
['file' => '/var/www/project/tests/Features/Controllers/Datasets.php', 'scope' => '/var/www/project/tests/Features/Controllers'],
]);

View File

@ -2,6 +2,7 @@
use Pest\Exceptions\DatasetMissing; use Pest\Exceptions\DatasetMissing;
use Pest\Exceptions\TestAlreadyExist; use Pest\Exceptions\TestAlreadyExist;
use Pest\Exceptions\TestClosureMustNotBeStatic;
use Pest\Factories\TestCaseMethodFactory; use Pest\Factories\TestCaseMethodFactory;
use Pest\TestSuite; use Pest\TestSuite;
@ -16,6 +17,16 @@ it('does not allow to add the same test description twice', function () {
sprintf('A test with the description `%s` already exists in the filename `%s`.', 'bar', 'foo'), sprintf('A test with the description `%s` already exists in the filename `%s`.', 'bar', 'foo'),
); );
it('does not allow static closures', function () {
$testSuite = new TestSuite(getcwd(), 'tests');
$method = new TestCaseMethodFactory('foo', 'bar', static function () {});
$testSuite->tests->set($method);
})->throws(
TestClosureMustNotBeStatic::class,
'Test closure must not be static. Please remove the `static` keyword from the `bar` method in `foo`.',
);
it('alerts users about tests with arguments but no input', function () { it('alerts users about tests with arguments but no input', function () {
$testSuite = new TestSuite(getcwd(), 'tests'); $testSuite = new TestSuite(getcwd(), 'tests');

View File

@ -16,7 +16,7 @@ $run = function () {
test('parallel', function () use ($run) { test('parallel', function () use ($run) {
expect($run('--exclude-group=integration')) expect($run('--exclude-group=integration'))
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 998 passed (2358 assertions)') ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 973 passed (2334 assertions)')
->toContain('Parallel: 3 processes'); ->toContain('Parallel: 3 processes');
})->skipOnWindows(); })->skipOnWindows();