mirror of
https://github.com/pestphp/pest.git
synced 2026-03-09 09:17:23 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 805b81edc0 | |||
| c42541a3d9 | |||
| 3f352605ca | |||
| a1208b5876 | |||
| b5f89d1ff8 | |||
| cd823193cc | |||
| eb7bb34825 |
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## [v2.8.1 (2023-06-20)](https://github.com/pestphp/pest/compare/v2.8.0...v2.8.1)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixes "Cannot find TestCase object on call stack" ([eb7bb34](https://github.com/pestphp/pest/commit/eb7bb348253f412e806a6ba6f0df46c0435d0dfe))
|
||||||
|
|
||||||
## [v2.8.0 (2023-06-19)](https://github.com/pestphp/pest/compare/v2.7.0...v2.8.0)
|
## [v2.8.0 (2023-06-19)](https://github.com/pestphp/pest/compare/v2.7.0...v2.8.0)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -18,16 +18,16 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1.0",
|
"php": "^8.1.0",
|
||||||
"brianium/paratest": "^7.2.0",
|
"brianium/paratest": "^7.2.2",
|
||||||
"nunomaduro/collision": "^7.6.0",
|
"nunomaduro/collision": "^7.7.0",
|
||||||
"nunomaduro/termwind": "^1.15.1",
|
"nunomaduro/termwind": "^1.15.1",
|
||||||
"pestphp/pest-plugin": "^2.0.1",
|
"pestphp/pest-plugin": "^2.0.1",
|
||||||
"pestphp/pest-plugin-arch": "^2.2.1",
|
"pestphp/pest-plugin-arch": "^2.2.2",
|
||||||
"phpunit/phpunit": "^10.2.2"
|
"phpunit/phpunit": "^10.2.3"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"webmozart/assert": "<1.11.0",
|
"webmozart/assert": "<1.11.0",
|
||||||
"phpunit/phpunit": ">10.2.2"
|
"phpunit/phpunit": ">10.2.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|||||||
@ -89,7 +89,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;
|
||||||
|
|||||||
39
src/Bootstrappers/BootExcludeList.php
Normal file
39
src/Bootstrappers/BootExcludeList.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Pest\Bootstrappers;
|
||||||
|
|
||||||
|
use Pest\Contracts\Bootstrapper;
|
||||||
|
use PHPUnit\Util\ExcludeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
final class BootExcludeList implements Bootstrapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The directories to exclude.
|
||||||
|
*
|
||||||
|
* @var array<int, non-empty-string>
|
||||||
|
*/
|
||||||
|
private const EXCLUDE_LIST = [
|
||||||
|
'bin',
|
||||||
|
'overrides',
|
||||||
|
'resources',
|
||||||
|
'src',
|
||||||
|
'stubs',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boots the "exclude list" for PHPUnit to ignore Pest files.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
$baseDirectory = dirname(__DIR__, 2);
|
||||||
|
|
||||||
|
foreach (self::EXCLUDE_LIST as $directory) {
|
||||||
|
ExcludeList::addDirectory($baseDirectory.DIRECTORY_SEPARATOR.$directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Concerns;
|
namespace Pest\Concerns;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Pest\Expectation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -37,7 +36,7 @@ trait Pipeable
|
|||||||
/**
|
/**
|
||||||
* Register an interceptor that should replace an existing expectation.
|
* Register an interceptor that should replace an existing expectation.
|
||||||
*
|
*
|
||||||
* @param string|Closure(mixed $value, mixed ...$arguments):bool $filter
|
* @param string|Closure(mixed $value, mixed ...$arguments):bool $filter
|
||||||
*/
|
*/
|
||||||
public function intercept(string $name, string|Closure $filter, Closure $handler): void
|
public function intercept(string $name, string|Closure $filter, Closure $handler): void
|
||||||
{
|
{
|
||||||
|
|||||||
@ -33,6 +33,7 @@ final class Kernel
|
|||||||
Bootstrappers\BootFiles::class,
|
Bootstrappers\BootFiles::class,
|
||||||
Bootstrappers\BootView::class,
|
Bootstrappers\BootView::class,
|
||||||
Bootstrappers\BootKernelDump::class,
|
Bootstrappers\BootKernelDump::class,
|
||||||
|
Bootstrappers\BootExcludeList::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -153,7 +153,7 @@ final class Converter
|
|||||||
/**
|
/**
|
||||||
* Gets the test suite location.
|
* Gets the test suite location.
|
||||||
*/
|
*/
|
||||||
public function getTestSuiteLocation(TestSuite $testSuite): string|null
|
public function getTestSuiteLocation(TestSuite $testSuite): ?string
|
||||||
{
|
{
|
||||||
$tests = $testSuite->tests()->asArray();
|
$tests = $testSuite->tests()->asArray();
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ namespace Pest\Logging\TeamCity;
|
|||||||
*/
|
*/
|
||||||
final class ServiceMessage
|
final class ServiceMessage
|
||||||
{
|
{
|
||||||
private static int|null $flowId = null;
|
private static ?int $flowId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, string|int|null> $parameters
|
* @param array<string, string|int|null> $parameters
|
||||||
@ -32,7 +32,7 @@ final class ServiceMessage
|
|||||||
return "##teamcity[$this->type$paramsToString]";
|
return "##teamcity[$this->type$paramsToString]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function testSuiteStarted(string $name, string|null $location): self
|
public static function testSuiteStarted(string $name, ?string $location): self
|
||||||
{
|
{
|
||||||
return new self('testSuiteStarted', [
|
return new self('testSuiteStarted', [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
|||||||
@ -60,7 +60,7 @@ final class TeamCityLogger
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly OutputInterface $output,
|
private readonly OutputInterface $output,
|
||||||
private readonly Converter $converter,
|
private readonly Converter $converter,
|
||||||
private readonly int|null $flowId,
|
private readonly ?int $flowId,
|
||||||
private readonly bool $withoutDuration,
|
private readonly bool $withoutDuration,
|
||||||
) {
|
) {
|
||||||
$this->registerSubscribers();
|
$this->registerSubscribers();
|
||||||
|
|||||||
@ -33,7 +33,7 @@ final class Expectation
|
|||||||
/**
|
/**
|
||||||
* The exporter instance, if any.
|
* The exporter instance, if any.
|
||||||
*/
|
*/
|
||||||
private Exporter|null $exporter = null;
|
private ?Exporter $exporter = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new expectation.
|
* Creates a new expectation.
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '2.8.0';
|
return '2.8.3';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -89,7 +89,7 @@ final class DatasetsRepository
|
|||||||
* @param array<Closure|iterable<int|string, mixed>|string> $dataset
|
* @param array<Closure|iterable<int|string, mixed>|string> $dataset
|
||||||
* @return array<string, mixed>|null
|
* @return array<string, mixed>|null
|
||||||
*/
|
*/
|
||||||
public static function resolve(array $dataset, string $currentTestFile): array|null
|
public static function resolve(array $dataset, string $currentTestFile): ?array
|
||||||
{
|
{
|
||||||
if ($dataset === []) {
|
if ($dataset === []) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -18,7 +18,7 @@ final class Closure
|
|||||||
*
|
*
|
||||||
* @throws ShouldNotHappen
|
* @throws ShouldNotHappen
|
||||||
*/
|
*/
|
||||||
public static function bind(BaseClosure|null $closure, ?object $newThis, object|string|null $newScope = 'static'): BaseClosure
|
public static function bind(?BaseClosure $closure, ?object $newThis, object|string|null $newScope = 'static'): BaseClosure
|
||||||
{
|
{
|
||||||
if ($closure == null) {
|
if ($closure == null) {
|
||||||
throw ShouldNotHappen::fromMessage('Could not bind null closure.');
|
throw ShouldNotHappen::fromMessage('Could not bind null closure.');
|
||||||
|
|||||||
@ -32,7 +32,7 @@ final class ExceptionTrace
|
|||||||
|
|
||||||
$message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);
|
$message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);
|
||||||
|
|
||||||
if (class_exists($class) && count(class_parents($class)) > 0 && array_values(class_parents($class))[0] === TestCase::class) {
|
if (class_exists((string) $class) && (is_countable(class_parents($class)) ? count(class_parents($class)) : 0) > 0 && array_values(class_parents($class))[0] === TestCase::class) { // @phpstan-ignore-line
|
||||||
$message .= '. Did you forget to use the [uses()] function? Read more at: https://pestphp.com/docs/configuring-tests';
|
$message .= '. Did you forget to use the [uses()] function? Read more at: https://pestphp.com/docs/configuring-tests';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ final class GitDirtyTestCaseFilter implements TestCaseFilter
|
|||||||
/**
|
/**
|
||||||
* @var string[]|null
|
* @var string[]|null
|
||||||
*/
|
*/
|
||||||
private array|null $changedFiles = null;
|
private ?array $changedFiles = null;
|
||||||
|
|
||||||
public function __construct(private readonly string $projectRoot)
|
public function __construct(private readonly string $projectRoot)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
##teamcity[testSuiteStarted name='Tests/tests/Failure' locationHint='file://tests/.tests/Failure.php' flowId='1234']
|
##teamcity[testSuiteStarted name='Tests/tests/Failure' locationHint='file://tests/.tests/Failure.php' flowId='1234']
|
||||||
##teamcity[testCount count='8' flowId='1234']
|
##teamcity[testCount count='8' 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[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:343|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:302|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:302|nat src/Concerns/Testable.php:221|nat src/Kernel.php:90' 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 tests/.tests/Failure.php:6' type='comparisonFailure' actual='true' expected='false' flowId='1234']
|
||||||
##teamcity[testFinished name='it can fail with comparison' duration='100000' 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[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']
|
##teamcity[testIgnored name='it can be ignored because of no assertions' message='This test did not perform any assertions' details='' flowId='1234']
|
||||||
@ -10,10 +10,10 @@
|
|||||||
##teamcity[testIgnored name='it can be ignored because it is skipped' message='This test was ignored.' details='' flowId='1234']
|
##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[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[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:302|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:302|nat src/Concerns/Testable.php:221|nat src/Kernel.php:90' flowId='1234']
|
##teamcity[testFailed name='it can fail' message='oh noo' details='at tests/.tests/Failure.php:18' flowId='1234']
|
||||||
##teamcity[testFinished name='it can fail' duration='100000' flowId='1234']
|
##teamcity[testFinished name='it can fail' duration='100000' flowId='1234']
|
||||||
##teamcity[testStarted name='it throws exception' locationHint='pest_qn://tests/.tests/Failure.php::it throws exception' flowId='1234']
|
##teamcity[testStarted name='it throws exception' locationHint='pest_qn://tests/.tests/Failure.php::it throws exception' flowId='1234']
|
||||||
##teamcity[testFailed name='it throws exception' message='Exception: test error' details='at tests/.tests/Failure.php:22|nat src/Factories/TestCaseMethodFactory.php:100|nat src/Concerns/Testable.php:302|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:302|nat src/Concerns/Testable.php:221|nat src/Kernel.php:90' flowId='1234']
|
##teamcity[testFailed name='it throws exception' message='Exception: test error' details='at tests/.tests/Failure.php:22' flowId='1234']
|
||||||
##teamcity[testFinished name='it throws exception' duration='100000' flowId='1234']
|
##teamcity[testFinished name='it throws exception' 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[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']
|
##teamcity[testIgnored name='it is not done yet' message='This test was ignored.' details='' flowId='1234']
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
9▕ })->skip(! isset($_SERVER['COLLISION_TEST']));
|
9▕ })->skip(! isset($_SERVER['COLLISION_TEST']));
|
||||||
|
|
||||||
1 tests/Fixtures/CollisionTest.php:4
|
1 tests/Fixtures/CollisionTest.php:4
|
||||||
2 src/Factories/TestCaseMethodFactory.php:100
|
|
||||||
|
|
||||||
|
|
||||||
Tests: 1 failed, 2 passed (2 assertions)
|
Tests: 1 failed, 2 passed (2 assertions)
|
||||||
@ -18,7 +18,6 @@
|
|||||||
9▕ })->skip(! isset($_SERVER['COLLISION_TEST']));
|
9▕ })->skip(! isset($_SERVER['COLLISION_TEST']));
|
||||||
|
|
||||||
1 tests/Fixtures/CollisionTest.php:4
|
1 tests/Fixtures/CollisionTest.php:4
|
||||||
2 src/Factories/TestCaseMethodFactory.php:100
|
|
||||||
|
|
||||||
|
|
||||||
Tests: 1 failed, 1 passed (1 assertions)
|
Tests: 1 failed, 1 passed (1 assertions)
|
||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.8.0.
|
Pest Testing Framework 2.8.3.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.8.0.
|
Pest Testing Framework 2.8.3.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user