Compare commits

...

27 Commits

Author SHA1 Message Date
3457841a9b release: v2.31.0 2024-01-11 15:33:20 +00:00
5258e569c1 feat: adds skipOnPHP 2024-01-11 15:33:12 +00:00
abb416c2ff chore: bumps dependencies 2024-01-11 15:32:44 +00:00
dc1e4f040d docs: adds sponsor 2024-01-04 18:26:20 +00:00
5e1e701ce5 Merge pull request #1051 from krencl/fix-cache-directory-config-override
Fix cache directory config override
2024-01-02 14:33:48 +00:00
f004591c5a fix: checking existing argument with equal sign 2024-01-02 15:03:46 +01:00
86a96dd157 fix: overriding cli argument --cache-directory 2024-01-02 15:01:13 +01:00
97dc32f9d2 release: v2.30.0 2023-12-28 10:36:40 +00:00
a3ab065343 chore: coding style 2023-12-28 10:36:30 +00:00
c390721ac3 chore: update snapshots 2023-12-28 10:34:22 +00:00
f83d758d4b feat: adds fails 2023-12-28 10:31:39 +00:00
e00aba539a release: v2.29.1 2023-12-27 15:27:07 +00:00
7799500d06 release: v2.29.0 2023-12-27 11:12:01 +00:00
c099991cd9 Merge pull request #1044 from nhrrs/fix-typo
Fix typo in `toBeClass`
2023-12-23 02:03:57 +00:00
e27d2e7394 Fix typo in toBeClass 2023-12-23 00:36:41 +00:00
8f738f5d49 Revert "Merge pull request #919 from WendellAdriel/feature/coverage-errors-only-flag-2"
This reverts commit 1e2ca40c5b, reversing
changes made to 4522cb5dcb.
2023-12-17 22:03:15 +00:00
1e2ca40c5b Merge pull request #919 from WendellAdriel/feature/coverage-errors-only-flag-2
[2.x] Print only files below the min coverage
2023-12-17 21:56:14 +00:00
4522cb5dcb Merge pull request #1014 from mjsafarali/chore/docker-file-optimization
[2.x] Dockerfile Optimization
2023-12-17 21:39:38 +00:00
9ee4191020 release: v2.28.1 2023-12-15 11:42:34 +00:00
cc65009d0a chore: adds "phpunit/phpunit": "^10.5.3" support 2023-12-15 11:42:23 +00:00
453133d382 chore: code style changes 2023-12-15 11:42:09 +00:00
dd0dddffd4 docs: updates sponsors 2023-12-11 12:05:58 +00:00
9a8f6e6414 release: v2.28.0 2023-12-05 19:06:22 +00:00
4ece95a040 tests: uses arch function 2023-12-05 19:06:11 +00:00
0cc09380bc chore: bumps dependencies 2023-12-05 19:06:03 +00:00
4f35dbc607 chore: optimized version of the Dockerfile 2023-11-18 14:57:03 +03:30
8ea7b2b802 Add errors-only flag 2023-08-18 10:13:28 +01:00
26 changed files with 188 additions and 62 deletions

View File

@ -22,17 +22,17 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
### Platinum Sponsors ### Platinum Sponsors
- **[Forge](https://forge.laravel.com)** - **[Forge](https://forge.laravel.com)**
- **[LoadForge](https://loadforge.com)**
- **[Spatie](https://spatie.be)** - **[Spatie](https://spatie.be)**
- **[Worksome](https://www.worksome.com/)** - **[Worksome](https://www.worksome.com/)**
### Premium Sponsors ### Premium Sponsors
- [Akaunting](https://akaunting.com) - [Akaunting](https://akaunting.com/?ref=pestphp)
- [Codecourse](https://codecourse.com/) - [Codecourse](https://codecourse.com/?ref=pestphp)
- [Laracasts](https://laracasts.com/) - [Laracasts](https://laracasts.com/?ref=pestphp)
- [Localazy](https://localazy.com) - [Laradir](https://laradir.com/?ref=pestphp)
- [Meema](https://meema.io) - [Localazy](https://localazy.com/?ref=pestphp)
- [Zapiet](https://www.zapiet.com) - [Stormlikes](https://www.stormlikes.net/?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

@ -19,14 +19,14 @@
"require": { "require": {
"php": "^8.1.0", "php": "^8.1.0",
"brianium/paratest": "^7.3.1", "brianium/paratest": "^7.3.1",
"nunomaduro/collision": "^7.10.0|^8.0.0", "nunomaduro/collision": "^7.10.0|^8.0.1",
"nunomaduro/termwind": "^1.15.1|^2.0.0", "nunomaduro/termwind": "^1.15.1|^2.0.0",
"pestphp/pest-plugin": "^2.1.1", "pestphp/pest-plugin": "^2.1.1",
"pestphp/pest-plugin-arch": "^2.4.1", "pestphp/pest-plugin-arch": "^2.6.1",
"phpunit/phpunit": "^10.5.1" "phpunit/phpunit": "^10.5.5"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": ">10.5.1", "phpunit/phpunit": ">10.5.5",
"sebastian/exporter": "<5.1.0", "sebastian/exporter": "<5.1.0",
"webmozart/assert": "<1.11.0" "webmozart/assert": "<1.11.0"
}, },
@ -52,8 +52,8 @@
}, },
"require-dev": { "require-dev": {
"pestphp/pest-dev-tools": "^2.16.0", "pestphp/pest-dev-tools": "^2.16.0",
"pestphp/pest-plugin-type-coverage": "^2.5.0", "pestphp/pest-plugin-type-coverage": "^2.8.0",
"symfony/process": "^6.4.0|^7.0.1" "symfony/process": "^6.4.0|^7.0.2"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,

View File

@ -1,21 +1,16 @@
ARG PHP=8.1 ARG PHP=8.1
FROM php:${PHP}-cli-alpine FROM php:${PHP}-cli-alpine
RUN apk update \ RUN apk update && apk add \
&& apk add zip libzip-dev icu-dev git zip libzip-dev icu-dev git \
RUN docker-php-ext-configure zip RUN docker-php-ext-configure zip intl
RUN docker-php-ext-install zip RUN docker-php-ext-install zip intl
RUN docker-php-ext-enable zip RUN docker-php-ext-enable zip intl
RUN docker-php-ext-configure intl RUN apk add --no-cache linux-headers
RUN docker-php-ext-install intl
RUN docker-php-ext-enable intl
RUN apk add --no-cache $PHPIZE_DEPS linux-headers
RUN pecl install xdebug RUN pecl install xdebug
RUN docker-php-ext-enable xdebug RUN docker-php-ext-enable xdebug
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html WORKDIR /var/www/html

View File

@ -91,7 +91,7 @@ final class DefaultResultCache implements ResultCache
*/ */
private array $times = []; private array $times = [];
public function __construct(string $filepath = null) public function __construct(?string $filepath = null)
{ {
if ($filepath !== null && is_dir($filepath)) { if ($filepath !== null && is_dir($filepath)) {
$filepath .= DIRECTORY_SEPARATOR.self::DEFAULT_RESULT_CACHE_FILENAME; $filepath .= DIRECTORY_SEPARATOR.self::DEFAULT_RESULT_CACHE_FILENAME;

View File

@ -190,7 +190,7 @@ final class Expectation
* *
* @return EachExpectation<TValue> * @return EachExpectation<TValue>
*/ */
public function each(callable $callback = null): EachExpectation public function each(?callable $callback = null): EachExpectation
{ {
if (! is_iterable($this->value)) { if (! is_iterable($this->value)) {
throw new BadMethodCallException('Expectation value is not iterable.'); throw new BadMethodCallException('Expectation value is not iterable.');
@ -535,7 +535,7 @@ final class Expectation
} }
/** /**
* Asserts that the given expectation targets is an class. * Asserts that the given expectation target is a class.
*/ */
public function toBeClass(): ArchExpectation public function toBeClass(): ArchExpectation
{ {

View File

@ -55,7 +55,7 @@ if (! function_exists('beforeEach')) {
* *
* @return HigherOrderTapProxy<Expectable|TestCall|TestCase>|Expectable|TestCall|TestCase|mixed * @return HigherOrderTapProxy<Expectable|TestCall|TestCase>|Expectable|TestCall|TestCase|mixed
*/ */
function beforeEach(Closure $closure = null): BeforeEachCall function beforeEach(?Closure $closure = null): BeforeEachCall
{ {
$filename = Backtrace::file(); $filename = Backtrace::file();
@ -116,7 +116,7 @@ if (! function_exists('test')) {
* *
* @return Expectable|TestCall|TestCase|mixed * @return Expectable|TestCall|TestCase|mixed
*/ */
function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall function test(?string $description = null, ?Closure $closure = null): HigherOrderTapProxy|TestCall
{ {
if ($description === null && TestSuite::getInstance()->test instanceof \PHPUnit\Framework\TestCase) { if ($description === null && TestSuite::getInstance()->test instanceof \PHPUnit\Framework\TestCase) {
return new HigherOrderTapProxy(TestSuite::getInstance()->test); return new HigherOrderTapProxy(TestSuite::getInstance()->test);
@ -136,7 +136,7 @@ if (! function_exists('it')) {
* *
* @return Expectable|TestCall|TestCase|mixed * @return Expectable|TestCall|TestCase|mixed
*/ */
function it(string $description, Closure $closure = null): TestCall function it(string $description, ?Closure $closure = null): TestCall
{ {
$description = sprintf('it %s', $description); $description = sprintf('it %s', $description);
@ -171,7 +171,7 @@ if (! function_exists('afterEach')) {
* *
* @return Expectable|HigherOrderTapProxy<Expectable|TestCall|TestCase>|TestCall|mixed * @return Expectable|HigherOrderTapProxy<Expectable|TestCall|TestCase>|TestCall|mixed
*/ */
function afterEach(Closure $closure = null): AfterEachCall function afterEach(?Closure $closure = null): AfterEachCall
{ {
$filename = Backtrace::file(); $filename = Backtrace::file();

View File

@ -106,7 +106,7 @@ final class ServiceMessage
]); ]);
} }
public static function testIgnored(string $name, string $message, string $details = null): self public static function testIgnored(string $name, string $message, ?string $details = null): self
{ {
return new self('testIgnored', [ return new self('testIgnored', [
'name' => $name, 'name' => $name,

View File

@ -920,7 +920,7 @@ final class Expectation
* @param (Closure(Throwable): mixed)|string $exception * @param (Closure(Throwable): mixed)|string $exception
* @return self<TValue> * @return self<TValue>
*/ */
public function toThrow(callable|string|Throwable $exception, string $exceptionMessage = null, string $message = ''): self public function toThrow(callable|string|Throwable $exception, ?string $exceptionMessage = null, string $message = ''): self
{ {
$callback = NullClosure::create(); $callback = NullClosure::create();

View File

@ -35,7 +35,7 @@ final class AfterEachCall
public function __construct( public function __construct(
private readonly TestSuite $testSuite, private readonly TestSuite $testSuite,
private readonly string $filename, private readonly string $filename,
Closure $closure = null ?Closure $closure = null
) { ) {
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create(); $this->closure = $closure instanceof Closure ? $closure : NullClosure::create();

View File

@ -40,7 +40,7 @@ final class BeforeEachCall
public function __construct( public function __construct(
public readonly TestSuite $testSuite, public readonly TestSuite $testSuite,
private readonly string $filename, private readonly string $filename,
Closure $closure = null ?Closure $closure = null
) { ) {
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create(); $this->closure = $closure instanceof Closure ? $closure : NullClosure::create();

View File

@ -18,6 +18,7 @@ use Pest\Support\HigherOrderCallables;
use Pest\Support\NullClosure; use Pest\Support\NullClosure;
use Pest\Support\Str; use Pest\Support\Str;
use Pest\TestSuite; use Pest\TestSuite;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
@ -45,8 +46,8 @@ final class TestCall
public function __construct( public function __construct(
private readonly TestSuite $testSuite, private readonly TestSuite $testSuite,
private readonly string $filename, private readonly string $filename,
string $description = null, ?string $description = null,
Closure $closure = null ?Closure $closure = null
) { ) {
$this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure); $this->testCaseMethod = new TestCaseMethodFactory($filename, $description, $closure);
@ -57,10 +58,18 @@ final class TestCall
$this->testSuite->beforeEach->get($this->filename)[0]($this); $this->testSuite->beforeEach->get($this->filename)[0]($this);
} }
/**
* Asserts that the test fails with the given message.
*/
public function fails(?string $message = null): self
{
return $this->throws(AssertionFailedError::class, $message);
}
/** /**
* Asserts that the test throws the given `$exceptionClass` when called. * Asserts that the test throws the given `$exceptionClass` when called.
*/ */
public function throws(string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self public function throws(string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self
{ {
if (is_int($exception)) { if (is_int($exception)) {
$exceptionCode = $exception; $exceptionCode = $exception;
@ -92,7 +101,7 @@ final class TestCall
* *
* @param (callable(): bool)|bool $condition * @param (callable(): bool)|bool $condition
*/ */
public function throwsIf(callable|bool $condition, string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self public function throwsIf(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self
{ {
$condition = is_callable($condition) $condition = is_callable($condition)
? $condition ? $condition
@ -110,7 +119,7 @@ final class TestCall
* *
* @param (callable(): bool)|bool $condition * @param (callable(): bool)|bool $condition
*/ */
public function throwsUnless(callable|bool $condition, string|int $exception, string $exceptionMessage = null, int $exceptionCode = null): self public function throwsUnless(callable|bool $condition, string|int $exception, ?string $exceptionMessage = null, ?int $exceptionCode = null): self
{ {
$condition = is_callable($condition) $condition = is_callable($condition)
? $condition ? $condition
@ -199,12 +208,37 @@ final class TestCall
return $this; return $this;
} }
/**
* Skips the current test on the given PHP version.
*/
public function skipOnPhp(string $version): self
{
if (mb_strlen($version) < 2) {
throw new InvalidArgumentException('The version must start with [<] or [>].');
}
if (str_starts_with($version, '>=') || str_starts_with($version, '<=')) {
$operator = substr($version, 0, 2);
$version = substr($version, 2);
} elseif (str_starts_with($version, '>') || str_starts_with($version, '<')) {
$operator = $version[0];
$version = substr($version, 1);
// ensure starts with number:
} elseif (is_numeric($version[0])) {
$operator = '==';
} else {
throw new InvalidArgumentException('The version must start with [<, >, <=, >=] or a number.');
}
return $this->skip(version_compare(PHP_VERSION, $version, $operator), sprintf('This test is skipped on PHP [%s%s].', $operator, $version));
}
/** /**
* Skips the current test if the given test is running on Windows. * Skips the current test if the given test is running on Windows.
*/ */
public function skipOnWindows(): self public function skipOnWindows(): self
{ {
return $this->skipOn('Windows', 'This test is skipped on [Windows].'); return $this->skipOnOs('Windows', 'This test is skipped on [Windows].');
} }
/** /**
@ -212,7 +246,7 @@ final class TestCall
*/ */
public function skipOnMac(): self public function skipOnMac(): self
{ {
return $this->skipOn('Darwin', 'This test is skipped on [Mac].'); return $this->skipOnOs('Darwin', 'This test is skipped on [Mac].');
} }
/** /**
@ -220,13 +254,13 @@ final class TestCall
*/ */
public function skipOnLinux(): self public function skipOnLinux(): self
{ {
return $this->skipOn('Linux', 'This test is skipped on [Linux].'); return $this->skipOnOs('Linux', 'This test is skipped on [Linux].');
} }
/** /**
* Skips the current test if the given test is running on the given operating systems. * Skips the current test if the given test is running on the given operating systems.
*/ */
private function skipOn(string $osFamily, string $message): self private function skipOnOs(string $osFamily, string $message): self
{ {
return $osFamily === PHP_OS_FAMILY return $osFamily === PHP_OS_FAMILY
? $this->skip($message) ? $this->skip($message)
@ -375,7 +409,7 @@ final class TestCall
* *
* @param array<int, mixed>|null $arguments * @param array<int, mixed>|null $arguments
*/ */
private function addChain(string $file, int $line, string $name, array $arguments = null): self private function addChain(string $file, int $line, string $name, ?array $arguments = null): self
{ {
$exporter = Exporter::default(); $exporter = Exporter::default();

View File

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

View File

@ -30,10 +30,12 @@ final class Cache implements HandlesArguments
*/ */
public function handleArguments(array $arguments): array public function handleArguments(array $arguments): array
{ {
$arguments = $this->pushArgument( if (! $this->hasArgument('--cache-directory', $arguments)) {
sprintf('--cache-directory=%s', realpath(self::TEMPORARY_FOLDER)), $arguments = $this->pushArgument(
$arguments sprintf('--cache-directory=%s', realpath(self::TEMPORARY_FOLDER)),
); $arguments
);
}
if (! $this->hasArgument('--parallel', $arguments)) { if (! $this->hasArgument('--parallel', $arguments)) {
return $this->pushArgument('--cache-result', $arguments); return $this->pushArgument('--cache-result', $arguments);

View File

@ -16,7 +16,17 @@ trait HandleArguments
*/ */
public function hasArgument(string $argument, array $arguments): bool public function hasArgument(string $argument, array $arguments): bool
{ {
return in_array($argument, $arguments, true); foreach ($arguments as $arg) {
if ($arg === $argument) {
return true;
}
if (str_starts_with($arg, "$argument=")) {
return true;
}
}
return false;
} }
/** /**

View File

@ -45,7 +45,7 @@ final class Environment implements HandlesArguments
/** /**
* Gets the environment name. * Gets the environment name.
*/ */
public static function name(string $name = null): string public static function name(?string $name = null): string
{ {
if (is_string($name)) { if (is_string($name)) {
self::$name = $name; self::$name = $name;

View File

@ -41,7 +41,7 @@ final class Exporter
* *
* @param array<int|string, mixed> $data * @param array<int|string, mixed> $data
*/ */
public function shortenedRecursiveExport(array &$data, Context $context = null): string public function shortenedRecursiveExport(array &$data, ?Context $context = null): string
{ {
$result = []; $result = [];
$array = $data; $array = $data;

View File

@ -87,8 +87,8 @@ final class TestSuite
* Returns the current instance of the test suite. * Returns the current instance of the test suite.
*/ */
public static function getInstance( public static function getInstance(
string $rootPath = null, ?string $rootPath = null,
string $testPath = null, ?string $testPath = null,
): TestSuite { ): TestSuite {
if (is_string($rootPath) && is_string($testPath)) { if (is_string($rootPath) && is_string($testPath)) {
self::$instance = new TestSuite($rootPath, $testPath); self::$instance = new TestSuite($rootPath, $testPath);

View File

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

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.27.0. Pest Testing Framework 2.31.0.

View File

@ -898,6 +898,14 @@
✓ it skips with falsy closure condition ✓ it skips with falsy closure condition
✓ it can be used in higher order tests ✓ it can be used in higher order tests
PASS Tests\Features\Fail
✓ it may fail
✓ it may fail with the given message
PASS Tests\Features\Fails
✓ it may fail
✓ it may fail with the given message
WARN Tests\Features\Helpers WARN Tests\Features\Helpers
✓ it can set/get properties on $this ✓ it can set/get properties on $this
! it gets null if property do not exist → Undefined property Tests\Features\Helpers::$wqdwqdqw ! it gets null if property do not exist → Undefined property Tests\Features\Helpers::$wqdwqdqw
@ -1085,6 +1093,12 @@
- it can use something in the test case as a condition → This test was skipped - it can use something in the test case as a condition → This test was skipped
- it can user higher order callables and skip - it can user higher order callables and skip
WARN Tests\Features\SkipOnPhp
✓ it can run on php version
- it can skip on specific php version → This test is skipped on PHP [==8.3.1].
✓ it can run on specific php version
- it can skip on php versions depending on constraint → This test is skipped on PHP [>=7.4.0].
PASS Tests\Features\Test PASS Tests\Features\Test
✓ a test ✓ a test
✓ higher order message test ✓ higher order message test
@ -1204,6 +1218,14 @@
PASS Tests\Unit\Overrides\ThrowableBuilder PASS Tests\Unit\Overrides\ThrowableBuilder
✓ collision editor can be added to the stack trace ✓ collision editor can be added to the stack trace
PASS Tests\Unit\Plugins\Concerns\HandleArguments
✓ method hasArgument with ('--long-argument', true)
✓ method hasArgument with ('-a', true)
✓ method hasArgument with ('--with-equal-sign', true)
✓ method hasArgument with ('someValue', true)
✓ method hasArgument with ('--a', false)
✓ method hasArgument with ('--undefined-argument', false)
PASS Tests\Unit\Plugins\Environment PASS Tests\Unit\Plugins\Environment
✓ environment is set to CI when --ci option is used ✓ environment is set to CI when --ci option is used
✓ environment is set to Local when --ci option is not used ✓ environment is set to Local when --ci option is not used
@ -1356,4 +1378,4 @@
WARN Tests\Visual\Version WARN Tests\Visual\Version
- visual snapshot of help command output - visual snapshot of help command output
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 966 passed (2286 assertions) Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 21 skipped, 978 passed (2304 assertions)

View File

@ -2,12 +2,12 @@
use Pest\Expectation; use Pest\Expectation;
test('globals') arch('globals')
->expect(['dd', 'dump', 'ray', 'die', 'var_dump', 'sleep']) ->expect(['dd', 'dump', 'ray', 'die', 'var_dump', 'sleep'])
->not->toBeUsed() ->not->toBeUsed()
->ignoring(Expectation::class); ->ignoring(Expectation::class);
test('dependencies') arch('dependencies')
->expect('Pest') ->expect('Pest')
->toOnlyUse([ ->toOnlyUse([
'dd', 'dd',
@ -24,7 +24,7 @@ test('dependencies')
'Symfony\Component\Process', 'Symfony\Component\Process',
])->ignoring(['Composer', 'PHPUnit', 'SebastianBergmann']); ])->ignoring(['Composer', 'PHPUnit', 'SebastianBergmann']);
test('contracts') arch('contracts')
->expect('Pest\Contracts') ->expect('Pest\Contracts')
->toOnlyUse([ ->toOnlyUse([
'NunoMaduro\Collision\Contracts', 'NunoMaduro\Collision\Contracts',

11
tests/Features/Fail.php Normal file
View File

@ -0,0 +1,11 @@
<?php
use PHPUnit\Framework\AssertionFailedError;
it('may fail', function () {
$this->fail();
})->throws(AssertionFailedError::class);
it('may fail with the given message', function () {
$this->fail('this is a failure');
})->throws(AssertionFailedError::class, 'this is a failure');

9
tests/Features/Fails.php Normal file
View File

@ -0,0 +1,9 @@
<?php
it('may fail', function () {
$this->fail();
})->fails();
it('may fail with the given message', function () {
$this->fail('this is a failure');
})->fails('this is a failure');

View File

@ -0,0 +1,17 @@
<?php
it('can run on php version')
->skipOnPhp('<=7.4.0')
->assertTrue(true);
it('can skip on specific php version')
->skipOnPhp(PHP_VERSION)
->assertTrue(false);
it('can run on specific php version')
->skipOnPhp('7.4.0')
->assertTrue(true);
it('can skip on php versions depending on constraint')
->skipOnPhp('>=7.4.0')
->assertTrue(false);

View File

@ -0,0 +1,26 @@
<?php
use Pest\Plugins\Concerns\HandleArguments;
test('method hasArgument', function (string $argument, bool $expectedResult) {
$obj = new class
{
use HandleArguments;
};
$arguments = [
'--long-argument',
'someValue',
'-a',
'--with-equal-sign=1337',
];
expect($obj->hasArgument($argument, $arguments))->toBe($expectedResult);
})->with([
['--long-argument', true],
['-a', true],
['--with-equal-sign', true],
['someValue', true],
['--a', false],
['--undefined-argument', false],
]);

View File

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