mirror of
https://github.com/pestphp/pest.git
synced 2026-07-24 10:30:03 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fbb48ba3e5 |
@@ -44,7 +44,7 @@ jobs:
|
|||||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cache Composer dependencies
|
- name: Cache Composer dependencies
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
key: static-php-8.3-${{ matrix.dependency-version }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
|
key: static-php-8.3-${{ matrix.dependency-version }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ jobs:
|
|||||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cache Composer dependencies
|
- name: Cache Composer dependencies
|
||||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
key: ${{ matrix.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
|
key: ${{ matrix.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
|
||||||
|
|||||||
+5
-5
@@ -20,18 +20,18 @@
|
|||||||
"php": "^8.3.0",
|
"php": "^8.3.0",
|
||||||
"brianium/paratest": "^7.20.0",
|
"brianium/paratest": "^7.20.0",
|
||||||
"composer/xdebug-handler": "^3.0.5",
|
"composer/xdebug-handler": "^3.0.5",
|
||||||
"nunomaduro/collision": "^8.9.5",
|
"nunomaduro/collision": "^8.9.4",
|
||||||
"nunomaduro/termwind": "^2.4.0",
|
"nunomaduro/termwind": "^2.4.0",
|
||||||
"pestphp/pest-plugin": "^4.0.0",
|
"pestphp/pest-plugin": "^4.0.0",
|
||||||
"pestphp/pest-plugin-arch": "^4.0.2",
|
"pestphp/pest-plugin-arch": "^4.0.2",
|
||||||
"pestphp/pest-plugin-mutate": "^4.0.1",
|
"pestphp/pest-plugin-mutate": "^4.0.1",
|
||||||
"pestphp/pest-plugin-profanity": "^4.2.1",
|
"pestphp/pest-plugin-profanity": "^4.2.1",
|
||||||
"phpunit/phpunit": "^12.5.31",
|
"phpunit/phpunit": "^12.5.30",
|
||||||
"symfony/process": "^7.4.13|^8.1.0"
|
"symfony/process": "^7.4.13|^8.1.0"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"filp/whoops": "<2.18.3",
|
"filp/whoops": "<2.18.3",
|
||||||
"phpunit/phpunit": ">12.5.31",
|
"phpunit/phpunit": ">12.5.30",
|
||||||
"sebastian/exporter": "<7.0.0",
|
"sebastian/exporter": "<7.0.0",
|
||||||
"webmozart/assert": "<1.11.0"
|
"webmozart/assert": "<1.11.0"
|
||||||
},
|
},
|
||||||
@@ -59,11 +59,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mrpunyapal/peststan": "^0.2.11",
|
"mrpunyapal/peststan": "^0.2.10",
|
||||||
"pestphp/pest-dev-tools": "^4.1.0",
|
"pestphp/pest-dev-tools": "^4.1.0",
|
||||||
"pestphp/pest-plugin-browser": "^4.3.1",
|
"pestphp/pest-plugin-browser": "^4.3.1",
|
||||||
"pestphp/pest-plugin-type-coverage": "^4.0.4",
|
"pestphp/pest-plugin-type-coverage": "^4.0.4",
|
||||||
"psy/psysh": "^0.12.24"
|
"psy/psysh": "^0.12.23"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
use Rector\CodingStyle\Rector\ArrowFunction\ArrowFunctionDelegatingCallToFirstClassCallableRector;
|
use Rector\CodingStyle\Rector\ArrowFunction\ArrowFunctionDelegatingCallToFirstClassCallableRector;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\DeadCode\Rector\ClassMethod\RemoveDuplicatedReturnSelfDocblockRector;
|
|
||||||
use Rector\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstructorRector;
|
use Rector\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstructorRector;
|
||||||
use Rector\DeadCode\Rector\ClassMethod\RemoveReturnTagIncompatibleWithNativeTypeRector;
|
|
||||||
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessUnionReturnDocblockRector;
|
|
||||||
use Rector\TypeDeclaration\Rector\ClassMethod\NarrowObjectReturnTypeRector;
|
use Rector\TypeDeclaration\Rector\ClassMethod\NarrowObjectReturnTypeRector;
|
||||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
||||||
|
|
||||||
@@ -21,11 +18,6 @@ return RectorConfig::configure()
|
|||||||
ArrowFunctionDelegatingCallToFirstClassCallableRector::class,
|
ArrowFunctionDelegatingCallToFirstClassCallableRector::class,
|
||||||
NarrowObjectReturnTypeRector::class,
|
NarrowObjectReturnTypeRector::class,
|
||||||
RemoveParentDelegatingConstructorRector::class,
|
RemoveParentDelegatingConstructorRector::class,
|
||||||
RemoveDuplicatedReturnSelfDocblockRector::class,
|
|
||||||
RemoveUselessUnionReturnDocblockRector::class,
|
|
||||||
RemoveReturnTagIncompatibleWithNativeTypeRector::class => [
|
|
||||||
__DIR__.'/src/Expectations/HigherOrderExpectation.php',
|
|
||||||
],
|
|
||||||
])
|
])
|
||||||
->withPreparedSets(
|
->withPreparedSets(
|
||||||
deadCode: true,
|
deadCode: true,
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Pest\Exceptions;
|
|
||||||
|
|
||||||
use RuntimeException;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
final class DatasetProviderError extends RuntimeException
|
|
||||||
{
|
|
||||||
public function __construct(Throwable $previous)
|
|
||||||
{
|
|
||||||
parent::__construct($previous->getMessage(), (int) $previous->getCode(), $previous);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -130,7 +130,7 @@ final class Expectation
|
|||||||
if (getenv('PARATEST') !== false || isset($_SERVER['COLLISION_PRINTER'])) {
|
if (getenv('PARATEST') !== false || isset($_SERVER['COLLISION_PRINTER'])) {
|
||||||
ob_start();
|
ob_start();
|
||||||
var_dump($this->value, ...$arguments);
|
var_dump($this->value, ...$arguments);
|
||||||
$output = ob_get_clean();
|
$output = (string) ob_get_clean();
|
||||||
|
|
||||||
throw new ExpectationFailedException($output);
|
throw new ExpectationFailedException($output);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,6 @@ final class TestCaseFactory
|
|||||||
$classCode = <<<PHP
|
$classCode = <<<PHP
|
||||||
namespace $namespace;
|
namespace $namespace;
|
||||||
|
|
||||||
use Pest\Exceptions\DatasetProviderError as __PestDatasetProviderError;
|
|
||||||
use Pest\Repositories\DatasetsRepository as __PestDatasets;
|
use Pest\Repositories\DatasetsRepository as __PestDatasets;
|
||||||
use Pest\TestSuite as __PestTestSuite;
|
use Pest\TestSuite as __PestTestSuite;
|
||||||
|
|
||||||
|
|||||||
@@ -235,10 +235,6 @@ final class TestCaseMethodFactory
|
|||||||
$attributesCode
|
$attributesCode
|
||||||
public function $methodName(...\$arguments)
|
public function $methodName(...\$arguments)
|
||||||
{
|
{
|
||||||
if (count(\$arguments) === 1 && \$arguments[0] instanceof __PestDatasetProviderError) {
|
|
||||||
throw \$arguments[0]->getPrevious() ?? \$arguments[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return \$this->__runTest(
|
return \$this->__runTest(
|
||||||
\$this->__test,
|
\$this->__test,
|
||||||
...\$arguments,
|
...\$arguments,
|
||||||
@@ -265,11 +261,7 @@ final class TestCaseMethodFactory
|
|||||||
|
|
||||||
public static function $dataProviderName()
|
public static function $dataProviderName()
|
||||||
{
|
{
|
||||||
try {
|
return __PestDatasets::get(self::\$__filename, "$methodName");
|
||||||
return __PestDatasets::get(self::\$__filename, "$methodName");
|
|
||||||
} catch (\Throwable \$throwable) {
|
|
||||||
return [[new __PestDatasetProviderError(\$throwable)]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '4.7.6';
|
return '4.7.4';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
+1
-4
@@ -219,11 +219,8 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
|||||||
if (! $watchPatterns->isEnabled()) {
|
if (! $watchPatterns->isEnabled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (! $watchPatterns->isLocally()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ! self::argumentPresent('--ci', $arguments);
|
return ! ($watchPatterns->isLocally() && self::argumentPresent('--ci', $arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 4.7.6.
|
Pest Testing Framework 4.7.4.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 4.7.6.
|
Pest Testing Framework 4.7.4.
|
||||||
|
|
||||||
|
|||||||
@@ -136,11 +136,6 @@
|
|||||||
✓ describe()->with() preserves depends → first with (9)
|
✓ describe()->with() preserves depends → first with (9)
|
||||||
✓ describe()->with() preserves depends → second with (9)
|
✓ describe()->with() preserves depends → second with (9)
|
||||||
|
|
||||||
PASS Tests\Features\DatasetProviderErrors
|
|
||||||
✓ reports missing datasets as errors for a single file run
|
|
||||||
✓ reports missing datasets as errors alongside passing tests
|
|
||||||
✓ reports dataset closure exceptions as errors
|
|
||||||
|
|
||||||
PASS Tests\Features\DatasetsTests - 1 todo
|
PASS Tests\Features\DatasetsTests - 1 todo
|
||||||
✓ it throws exception if dataset does not exist
|
✓ it throws exception if dataset does not exist
|
||||||
✓ it throws exception if dataset already exist
|
✓ it throws exception if dataset already exist
|
||||||
@@ -1946,4 +1941,4 @@
|
|||||||
✓ pass with dataset with ('my-datas-set-value')
|
✓ pass with dataset with ('my-datas-set-value')
|
||||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||||
|
|
||||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1333 passed (3020 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1330 passed (3010 assertions)
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
dataset('throws', function () {
|
|
||||||
throw new RuntimeException('boom from dataset');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('x', function ($a) {
|
|
||||||
expect($a)->toBeTrue();
|
|
||||||
})->with('throws');
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
it('references a missing dataset', function ($value) {
|
|
||||||
expect($value)->toBeTruthy();
|
|
||||||
})->with('missing');
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
it('passes normally', function () {
|
|
||||||
expect(true)->toBeTrue();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('references a missing dataset', function ($value) {
|
|
||||||
expect($value)->toBeTruthy();
|
|
||||||
})->with('missing');
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Symfony\Component\Process\Process;
|
|
||||||
|
|
||||||
$run = function (string $target): array {
|
|
||||||
$process = new Process(
|
|
||||||
['php', 'bin/pest', $target],
|
|
||||||
dirname(__DIR__, 2),
|
|
||||||
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
|
|
||||||
);
|
|
||||||
|
|
||||||
$process->run();
|
|
||||||
|
|
||||||
return [
|
|
||||||
'output' => removeAnsiEscapeSequences($process->getOutput().$process->getErrorOutput()),
|
|
||||||
'code' => $process->getExitCode(),
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
test('reports missing datasets as errors for a single file run', function () use ($run) {
|
|
||||||
$result = $run('tests/.tests/IssueOnly.php');
|
|
||||||
|
|
||||||
expect($result['output'])
|
|
||||||
->toContain("A dataset with the name `missing` does not exist. You can create it using `dataset('missing', ['a', 'b']);`.")
|
|
||||||
->toContain('FAILED')
|
|
||||||
->toContain('Tests: 1 failed');
|
|
||||||
|
|
||||||
expect($result['code'])->not->toBe(0);
|
|
||||||
})->skipOnWindows();
|
|
||||||
|
|
||||||
test('reports missing datasets as errors alongside passing tests', function () use ($run) {
|
|
||||||
$result = $run('tests/.tests/IssueWithPassing.php');
|
|
||||||
|
|
||||||
expect($result['output'])
|
|
||||||
->toContain("A dataset with the name `missing` does not exist. You can create it using `dataset('missing', ['a', 'b']);`.")
|
|
||||||
->toContain('1 passed')
|
|
||||||
->toContain('1 failed');
|
|
||||||
|
|
||||||
expect($result['code'])->not->toBe(0);
|
|
||||||
})->skipOnWindows();
|
|
||||||
|
|
||||||
test('reports dataset closure exceptions as errors', function () use ($run) {
|
|
||||||
$result = $run('tests/.tests/DatasetClosureThrows.php');
|
|
||||||
|
|
||||||
expect($result['output'])
|
|
||||||
->toContain('boom from dataset');
|
|
||||||
|
|
||||||
expect($result['code'])->not->toBe(0);
|
|
||||||
})->skipOnWindows();
|
|
||||||
@@ -24,13 +24,13 @@ test('parallel', function () use ($run) {
|
|||||||
$file = file_get_contents(__FILE__);
|
$file = file_get_contents(__FILE__);
|
||||||
$file = preg_replace(
|
$file = preg_replace(
|
||||||
'/\$expected = \'.*?\';/',
|
'/\$expected = \'.*?\';/',
|
||||||
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1317 passed (2969 assertions)';",
|
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1314 passed (2959 assertions)';",
|
||||||
$file,
|
$file,
|
||||||
);
|
);
|
||||||
file_put_contents(__FILE__, $file);
|
file_put_contents(__FILE__, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1317 passed (2969 assertions)';
|
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1314 passed (2959 assertions)';
|
||||||
|
|
||||||
expect($output)
|
expect($output)
|
||||||
->toContain("Tests: {$expected}")
|
->toContain("Tests: {$expected}")
|
||||||
|
|||||||
Reference in New Issue
Block a user