mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e00aba539a | |||
| 7799500d06 | |||
| c099991cd9 | |||
| e27d2e7394 | |||
| 8f738f5d49 | |||
| 1e2ca40c5b | |||
| 4522cb5dcb | |||
| 9ee4191020 | |||
| cc65009d0a | |||
| 453133d382 | |||
| dd0dddffd4 | |||
| 9a8f6e6414 | |||
| 4ece95a040 | |||
| 0cc09380bc | |||
| 4f35dbc607 | |||
| 8ea7b2b802 |
@ -22,17 +22,16 @@ 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)
|
||||||
- [Codecourse](https://codecourse.com/)
|
- [Codecourse](https://codecourse.com)
|
||||||
- [Laracasts](https://laracasts.com/)
|
- [Laracasts](https://laracasts.com)
|
||||||
|
- [Laradir](https://laradir.com)
|
||||||
- [Localazy](https://localazy.com)
|
- [Localazy](https://localazy.com)
|
||||||
- [Meema](https://meema.io)
|
|
||||||
- [Zapiet](https://www.zapiet.com)
|
- [Zapiet](https://www.zapiet.com)
|
||||||
|
|
||||||
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)**.
|
||||||
|
|||||||
@ -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.5.0",
|
||||||
"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.6.0",
|
||||||
"symfony/process": "^6.4.0|^7.0.1"
|
"symfony/process": "^6.4.0|^7.0.0"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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();
|
||||||
|
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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();
|
||||||
|
|
||||||
|
|||||||
@ -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();
|
||||||
|
|
||||||
|
|||||||
@ -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();
|
||||||
|
|
||||||
|
|||||||
@ -45,8 +45,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);
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ final class TestCall
|
|||||||
/**
|
/**
|
||||||
* 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 +92,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 +110,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
|
||||||
@ -375,7 +375,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();
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '2.27.0';
|
return '2.29.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.27.0.
|
Pest Testing Framework 2.29.1.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.27.0.
|
Pest Testing Framework 2.29.1.
|
||||||
|
|
||||||
|
|||||||
@ -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',
|
||||||
|
|||||||
Reference in New Issue
Block a user