mirror of
https://github.com/pestphp/pest.git
synced 2026-03-09 09:17:23 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f7a1663dd | |||
| f3f35a2ed1 | |||
| 86a6b32715 | |||
| be41181b43 | |||
| 632ffc2f8e | |||
| 705f19dd87 | |||
| 5637dfa75d | |||
| cf5275293f | |||
| 81efe5953b | |||
| a37a3b9f99 | |||
| 9100913184 | |||
| 8fdb0b3d32 |
34
CHANGELOG.md
34
CHANGELOG.md
@ -2,9 +2,41 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## [v2.9.4 (2023-07-22)](https://github.com/pestphp/pest/compare/v2.9.3...v2.9.4)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Output on `describe` `beforeEach` failure ([5637dfa](https://github.com/pestphp/pest/commit/5637dfa75d1a331adc810935536cde7c3196af06))
|
||||||
|
|
||||||
|
## [v2.9.3 (2023-07-20)](https://github.com/pestphp/pest/compare/v2.9.2...v2.9.3)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Snapshots directory on Windows environments ([cf52752](https://github.com/pestphp/pest/commit/cf5275293fe693ec2cf4dbadbadae01daaa08169))
|
||||||
|
|
||||||
|
## [v2.9.2 (2023-07-20)](https://github.com/pestphp/pest/compare/v2.9.1...v2.9.2)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `beforeEach` on Windows environments ([a37a3b9](https://github.com/pestphp/pest/commit/a37a3b9f9931bc1ab1ea9e1d6d38dfb55dde3f74))
|
||||||
|
|
||||||
|
## [v2.9.1 (2023-07-20)](https://github.com/pestphp/pest/compare/v2.9.0...v2.9.1)
|
||||||
|
|
||||||
|
### Chore
|
||||||
|
|
||||||
|
- Bumps PHPUnit to `^10.2.6` ([8fdb0b3](https://github.com/pestphp/pest/commit/8fdb0b3d32ce9ee12bd182f22751c2b41a53e97b))
|
||||||
|
|
||||||
## [v2.9.0 (2023-07-19)](https://github.com/pestphp/pest/compare/v2.8.1...v2.9.0)
|
## [v2.9.0 (2023-07-19)](https://github.com/pestphp/pest/compare/v2.8.1...v2.9.0)
|
||||||
|
|
||||||
TODO
|
> "Spicy Summer" is the codename assigned to Pest 2.9, for full details check our announcement: [https://pestphp.com/docs/pest-spicy-summer-release](https://pestphp.com/docs/pest-spicy-summer-release)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Built-in Snapshot Testing ([c828756](https://github.com/pestphp/pest/commit/c8287567eb8c3dbea5845b2a6f70804b094b4b60))
|
||||||
|
- Describe Blocks ([c828756](https://github.com/pestphp/pest/commit/c8287567eb8c3dbea5845b2a6f70804b094b4b60))
|
||||||
|
- Architectural Testing++ ([c828756](https://github.com/pestphp/pest/commit/c8287567eb8c3dbea5845b2a6f70804b094b4b60))
|
||||||
|
- Type Coverage Plugin ([c828756](https://github.com/pestphp/pest/commit/c8287567eb8c3dbea5845b2a6f70804b094b4b60))
|
||||||
|
- Drift Plugin ([c828756](https://github.com/pestphp/pest/commit/c8287567eb8c3dbea5845b2a6f70804b094b4b60))
|
||||||
|
|
||||||
## [v2.8.1 (2023-06-20)](https://github.com/pestphp/pest/compare/v2.8.0...v2.8.1)
|
## [v2.8.1 (2023-06-20)](https://github.com/pestphp/pest/compare/v2.8.0...v2.8.1)
|
||||||
|
|
||||||
|
|||||||
@ -18,16 +18,16 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.1.0",
|
"php": "^8.1.0",
|
||||||
"brianium/paratest": "^7.2.2",
|
"brianium/paratest": "^7.2.3",
|
||||||
"nunomaduro/collision": "^7.7.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.2",
|
"pestphp/pest-plugin-arch": "^2.2.3",
|
||||||
"phpunit/phpunit": "^10.2.3"
|
"phpunit/phpunit": "^10.2.6"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"webmozart/assert": "<1.11.0",
|
"webmozart/assert": "<1.11.0",
|
||||||
"phpunit/phpunit": ">10.2.3"
|
"phpunit/phpunit": ">10.2.6"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
@ -51,7 +51,7 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"pestphp/pest-dev-tools": "^2.12.0",
|
"pestphp/pest-dev-tools": "^2.12.0",
|
||||||
"pestphp/pest-plugin-type-coverage": "^2.0.0",
|
"pestphp/pest-plugin-type-coverage": "^2.0.0",
|
||||||
"symfony/process": "^6.3.0"
|
"symfony/process": "^6.3.2"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
@ -103,6 +103,7 @@
|
|||||||
"Pest\\Plugins\\Profile",
|
"Pest\\Plugins\\Profile",
|
||||||
"Pest\\Plugins\\Retry",
|
"Pest\\Plugins\\Retry",
|
||||||
"Pest\\Plugins\\Snapshot",
|
"Pest\\Plugins\\Snapshot",
|
||||||
|
"Pest\\Plugins\\Verbose",
|
||||||
"Pest\\Plugins\\Version",
|
"Pest\\Plugins\\Version",
|
||||||
"Pest\\Plugins\\Parallel"
|
"Pest\\Plugins\\Parallel"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -185,6 +185,27 @@ trait Testable
|
|||||||
{
|
{
|
||||||
TestSuite::getInstance()->test = $this;
|
TestSuite::getInstance()->test = $this;
|
||||||
|
|
||||||
|
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
|
||||||
|
|
||||||
|
$description = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description;
|
||||||
|
|
||||||
|
if ($method->repetitions > 1) {
|
||||||
|
$matches = [];
|
||||||
|
preg_match('/\((.*?)\)/', $description, $matches);
|
||||||
|
|
||||||
|
if (count($matches) > 1) {
|
||||||
|
if (str_contains($description, 'with '.$matches[0].' /')) {
|
||||||
|
$description = str_replace('with '.$matches[0].' /', '', $description);
|
||||||
|
} else {
|
||||||
|
$description = str_replace('with '.$matches[0], '', $description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$description .= ' @ repetition '.($matches[1].' of '.$method->repetitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->__description = self::$__latestDescription = $description;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$beforeEach = TestSuite::getInstance()->beforeEach->get(self::$__filename)[1];
|
$beforeEach = TestSuite::getInstance()->beforeEach->get(self::$__filename)[1];
|
||||||
@ -236,7 +257,9 @@ trait Testable
|
|||||||
{
|
{
|
||||||
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
|
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
|
||||||
|
|
||||||
$this->__description = self::$__latestDescription = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description;
|
if ($method->repetitions > 1) {
|
||||||
|
array_shift($arguments);
|
||||||
|
}
|
||||||
|
|
||||||
$underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure');
|
$underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure');
|
||||||
$testParameterTypes = array_values(Reflection::getFunctionArguments($underlyingTest));
|
$testParameterTypes = array_values(Reflection::getFunctionArguments($underlyingTest));
|
||||||
|
|||||||
24
src/Exceptions/InvalidArgumentException.php
Normal file
24
src/Exceptions/InvalidArgumentException.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Pest\Exceptions;
|
||||||
|
|
||||||
|
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||||
|
use NunoMaduro\Collision\Contracts\RenderlessEditor;
|
||||||
|
use NunoMaduro\Collision\Contracts\RenderlessTrace;
|
||||||
|
use Symfony\Component\Console\Exception\ExceptionInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
final class InvalidArgumentException extends BaseInvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates a new Exception instance.
|
||||||
|
*/
|
||||||
|
public function __construct(string $message)
|
||||||
|
{
|
||||||
|
parent::__construct($message, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -417,7 +417,7 @@ final class Expectation
|
|||||||
{
|
{
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this,
|
$this,
|
||||||
fn (ObjectDescription $object): bool => $object->reflectionClass->isFinal(),
|
fn (ObjectDescription $object): bool => ! enum_exists($object->name) && $object->reflectionClass->isFinal(),
|
||||||
'to be final',
|
'to be final',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
);
|
);
|
||||||
@ -430,7 +430,7 @@ final class Expectation
|
|||||||
{
|
{
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this,
|
$this,
|
||||||
fn (ObjectDescription $object): bool => $object->reflectionClass->isReadOnly() && assert(true), // @phpstan-ignore-line,
|
fn (ObjectDescription $object): bool => ! enum_exists($object->name) && $object->reflectionClass->isReadOnly(),
|
||||||
'to be readonly',
|
'to be readonly',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
);
|
);
|
||||||
@ -498,7 +498,7 @@ final class Expectation
|
|||||||
{
|
{
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this,
|
$this,
|
||||||
fn (ObjectDescription $object): bool => class_exists($object->name),
|
fn (ObjectDescription $object): bool => class_exists($object->name) && ! enum_exists($object->name),
|
||||||
'to be class',
|
'to be class',
|
||||||
FileLineFinder::where(fn (string $line): bool => true),
|
FileLineFinder::where(fn (string $line): bool => true),
|
||||||
);
|
);
|
||||||
@ -595,12 +595,12 @@ final class Expectation
|
|||||||
/**
|
/**
|
||||||
* Asserts that the given expectation target to have the given suffix.
|
* Asserts that the given expectation target to have the given suffix.
|
||||||
*/
|
*/
|
||||||
public function toHaveSuffix(string $suffix): ArchExpectation
|
public function toHavePrefix(string $suffix): ArchExpectation
|
||||||
{
|
{
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this,
|
$this,
|
||||||
fn (ObjectDescription $object): bool => str_ends_with($object->reflectionClass->getName(), $suffix),
|
fn (ObjectDescription $object): bool => str_starts_with($object->reflectionClass->getName(), $suffix),
|
||||||
"to have suffix '{$suffix}'",
|
"to have prefix '{$suffix}'",
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -608,12 +608,12 @@ final class Expectation
|
|||||||
/**
|
/**
|
||||||
* Asserts that the given expectation target to have the given suffix.
|
* Asserts that the given expectation target to have the given suffix.
|
||||||
*/
|
*/
|
||||||
public function toHavePrefix(string $suffix): ArchExpectation
|
public function toHaveSuffix(string $suffix): ArchExpectation
|
||||||
{
|
{
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this,
|
$this,
|
||||||
fn (ObjectDescription $object): bool => str_starts_with($object->reflectionClass->getName(), $suffix),
|
fn (ObjectDescription $object): bool => str_ends_with($object->reflectionClass->getName(), $suffix),
|
||||||
"to have prefix '{$suffix}'",
|
"to have suffix '{$suffix}'",
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,7 +96,7 @@ final class OppositeExpectation
|
|||||||
{
|
{
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$this->original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isFinal(),
|
fn (ObjectDescription $object): bool => ! enum_exists($object->name) && ! $object->reflectionClass->isFinal(),
|
||||||
'not to be final',
|
'not to be final',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
);
|
);
|
||||||
@ -109,7 +109,7 @@ final class OppositeExpectation
|
|||||||
{
|
{
|
||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this->original,
|
$this->original,
|
||||||
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isReadOnly() && assert(true), // @phpstan-ignore-line
|
fn (ObjectDescription $object): bool => ! enum_exists($object->name) && ! $object->reflectionClass->isReadOnly(),
|
||||||
'not to be readonly',
|
'not to be readonly',
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
);
|
);
|
||||||
@ -128,6 +128,14 @@ final class OppositeExpectation
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given expectation targets are not traits.
|
||||||
|
*/
|
||||||
|
public function toBeTraits(): ArchExpectation
|
||||||
|
{
|
||||||
|
return $this->toBeTrait();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the given expectation target is not abstract.
|
* Asserts that the given expectation target is not abstract.
|
||||||
*/
|
*/
|
||||||
@ -154,6 +162,35 @@ final class OppositeExpectation
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given expectation targets are not enums.
|
||||||
|
*/
|
||||||
|
public function toBeEnums(): ArchExpectation
|
||||||
|
{
|
||||||
|
return $this->toBeEnum();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given expectation targets is an class.
|
||||||
|
*/
|
||||||
|
public function toBeClass(): ArchExpectation
|
||||||
|
{
|
||||||
|
return Targeted::make(
|
||||||
|
$this->original,
|
||||||
|
fn (ObjectDescription $object): bool => ! class_exists($object->name),
|
||||||
|
'not to be class',
|
||||||
|
FileLineFinder::where(fn (string $line): bool => true),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given expectation targets are not classes.
|
||||||
|
*/
|
||||||
|
public function toBeClasses(): ArchExpectation
|
||||||
|
{
|
||||||
|
return $this->toBeClass();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the given expectation target is not interface.
|
* Asserts that the given expectation target is not interface.
|
||||||
*/
|
*/
|
||||||
@ -167,6 +204,14 @@ final class OppositeExpectation
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the given expectation targets are not interfaces.
|
||||||
|
*/
|
||||||
|
public function toBeInterfaces(): ArchExpectation
|
||||||
|
{
|
||||||
|
return $this->toBeInterface();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the given expectation target to be subclass of the given class.
|
* Asserts that the given expectation target to be subclass of the given class.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -26,6 +26,11 @@ final class TestCaseMethodFactory
|
|||||||
*/
|
*/
|
||||||
public ?string $describing = null;
|
public ?string $describing = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The test's number of repetitions.
|
||||||
|
*/
|
||||||
|
public int $repetitions = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the test is a "todo".
|
* Determines if the test is a "todo".
|
||||||
*/
|
*/
|
||||||
@ -140,7 +145,7 @@ final class TestCaseMethodFactory
|
|||||||
$attributes = (new $attribute())->__invoke($this, $attributes);
|
$attributes = (new $attribute())->__invoke($this, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->datasets !== []) {
|
if ($this->datasets !== [] || $this->repetitions > 1) {
|
||||||
$dataProviderName = $methodName.'_dataset';
|
$dataProviderName = $methodName.'_dataset';
|
||||||
$annotations[] = "@dataProvider $dataProviderName";
|
$annotations[] = "@dataProvider $dataProviderName";
|
||||||
$datasetsCode = $this->buildDatasetForEvaluation($methodName, $dataProviderName);
|
$datasetsCode = $this->buildDatasetForEvaluation($methodName, $dataProviderName);
|
||||||
@ -177,7 +182,13 @@ final class TestCaseMethodFactory
|
|||||||
*/
|
*/
|
||||||
private function buildDatasetForEvaluation(string $methodName, string $dataProviderName): string
|
private function buildDatasetForEvaluation(string $methodName, string $dataProviderName): string
|
||||||
{
|
{
|
||||||
DatasetsRepository::with($this->filename, $methodName, $this->datasets);
|
$datasets = $this->datasets;
|
||||||
|
|
||||||
|
if ($this->repetitions > 1) {
|
||||||
|
$datasets = [range(1, $this->repetitions), ...$datasets];
|
||||||
|
}
|
||||||
|
|
||||||
|
DatasetsRepository::with($this->filename, $methodName, $datasets);
|
||||||
|
|
||||||
return <<<EOF
|
return <<<EOF
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace Pest\PendingCalls;
|
namespace Pest\PendingCalls;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use InvalidArgumentException;
|
use Pest\Exceptions\InvalidArgumentException;
|
||||||
use Pest\Factories\Covers\CoversClass;
|
use Pest\Factories\Covers\CoversClass;
|
||||||
use Pest\Factories\Covers\CoversFunction;
|
use Pest\Factories\Covers\CoversFunction;
|
||||||
use Pest\Factories\Covers\CoversNothing;
|
use Pest\Factories\Covers\CoversNothing;
|
||||||
@ -214,6 +214,20 @@ final class TestCall
|
|||||||
: $this;
|
: $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repeats the current test the given number of times.
|
||||||
|
*/
|
||||||
|
public function repeat(int $times): self
|
||||||
|
{
|
||||||
|
if ($times < 1) {
|
||||||
|
throw new InvalidArgumentException('The number of repetitions must be greater than 0.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->testCaseMethod->repetitions = $times;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the test as "todo".
|
* Sets the test as "todo".
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '2.9.0';
|
return '2.10.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
38
src/Plugins/Verbose.php
Normal file
38
src/Plugins/Verbose.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Pest\Plugins;
|
||||||
|
|
||||||
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
final class Verbose implements HandlesArguments
|
||||||
|
{
|
||||||
|
use Concerns\HandleArguments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of verbosity levels.
|
||||||
|
*/
|
||||||
|
private const VERBOSITY_LEVELS = ['v', 'vv', 'vvv', 'q'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function handleArguments(array $arguments): array
|
||||||
|
{
|
||||||
|
foreach (self::VERBOSITY_LEVELS as $level) {
|
||||||
|
if ($this->hasArgument('-'.$level, $arguments)) {
|
||||||
|
$arguments = $this->popArgument('-'.$level, $arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->hasArgument('--quiet', $arguments)) {
|
||||||
|
return $this->popArgument('--quiet', $arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arguments;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -115,7 +115,7 @@ final class Backtrace
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str_contains($trace['file'], 'pest/src')) {
|
if (str_contains($trace['file'], 'pest'.DIRECTORY_SEPARATOR.'src')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,8 +76,10 @@ final class TestSuite
|
|||||||
$this->afterEach = new AfterEachRepository();
|
$this->afterEach = new AfterEachRepository();
|
||||||
$this->afterAll = new AfterAllRepository();
|
$this->afterAll = new AfterAllRepository();
|
||||||
$this->rootPath = (string) realpath($rootPath);
|
$this->rootPath = (string) realpath($rootPath);
|
||||||
|
$this->snapshots = new SnapshotRepository(
|
||||||
$this->snapshots = new SnapshotRepository($this->rootPath.'/'.$this->testPath, '.pest/snapshots');
|
implode(DIRECTORY_SEPARATOR, [$this->rootPath, $this->testPath]),
|
||||||
|
implode(DIRECTORY_SEPARATOR, ['.pest', 'snapshots']),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.9.0.
|
Pest Testing Framework 2.10.0.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.9.0.
|
Pest Testing Framework 2.10.0.
|
||||||
|
|
||||||
|
|||||||
@ -762,6 +762,95 @@
|
|||||||
! notice → This is a notice description // tests/Features/Notices.php:4
|
! notice → This is a notice description // tests/Features/Notices.php:4
|
||||||
! a "describe" group of tests → notice → This is a notice description // tests/Features/Notices.php:11
|
! a "describe" group of tests → notice → This is a notice description // tests/Features/Notices.php:11
|
||||||
|
|
||||||
|
PASS Tests\Features\Repeat
|
||||||
|
✓ once
|
||||||
|
✓ multiple times @ repetition 1 of 5
|
||||||
|
✓ multiple times @ repetition 2 of 5
|
||||||
|
✓ multiple times @ repetition 3 of 5
|
||||||
|
✓ multiple times @ repetition 4 of 5
|
||||||
|
✓ multiple times @ repetition 5 of 5
|
||||||
|
✓ multiple times with single dataset dataset "a" @ repetition 1 of 6
|
||||||
|
✓ multiple times with single dataset dataset "b" @ repetition 1 of 6
|
||||||
|
✓ multiple times with single dataset dataset "c" @ repetition 1 of 6
|
||||||
|
✓ multiple times with single dataset dataset "a" @ repetition 2 of 6
|
||||||
|
✓ multiple times with single dataset dataset "b" @ repetition 2 of 6
|
||||||
|
✓ multiple times with single dataset dataset "c" @ repetition 2 of 6
|
||||||
|
✓ multiple times with single dataset dataset "a" @ repetition 3 of 6
|
||||||
|
✓ multiple times with single dataset dataset "b" @ repetition 3 of 6
|
||||||
|
✓ multiple times with single dataset dataset "c" @ repetition 3 of 6
|
||||||
|
✓ multiple times with single dataset dataset "a" @ repetition 4 of 6
|
||||||
|
✓ multiple times with single dataset dataset "b" @ repetition 4 of 6
|
||||||
|
✓ multiple times with single dataset dataset "c" @ repetition 4 of 6
|
||||||
|
✓ multiple times with single dataset dataset "a" @ repetition 5 of 6
|
||||||
|
✓ multiple times with single dataset dataset "b" @ repetition 5 of 6
|
||||||
|
✓ multiple times with single dataset dataset "c" @ repetition 5 of 6
|
||||||
|
✓ multiple times with single dataset dataset "a" @ repetition 6 of 6
|
||||||
|
✓ multiple times with single dataset dataset "b" @ repetition 6 of 6
|
||||||
|
✓ multiple times with single dataset dataset "c" @ repetition 6 of 6
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (4) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (5) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (6) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (4) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (5) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (6) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (4) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (5) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (6) @ repetition 1 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (4) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (5) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (6) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (4) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (5) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (6) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (4) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (5) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (6) @ repetition 2 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (4) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (5) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (6) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (4) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (5) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (6) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (4) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (5) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (6) @ repetition 3 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (4) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (5) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (6) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (4) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (5) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (6) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (4) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (5) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (6) @ repetition 4 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (4) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (5) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (6) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (4) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (5) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (6) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (4) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (5) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (6) @ repetition 5 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (4) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (5) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (6) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (4) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (5) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (6) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (4) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (5) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (6) @ repetition 6 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (4) @ repetition 7 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (5) @ repetition 7 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "a" / (6) @ repetition 7 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (4) @ repetition 7 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (5) @ repetition 7 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "b" / (6) @ repetition 7 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (4) @ repetition 7 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (5) @ repetition 7 of 7
|
||||||
|
✓ multiple times with multiple dataset dataset "c" / (6) @ repetition 7 of 7
|
||||||
|
|
||||||
PASS Tests\Features\ScopedDatasets\Directory\NestedDirectory1\TestFileInNestedDirectoryWithDatasetsFile
|
PASS Tests\Features\ScopedDatasets\Directory\NestedDirectory1\TestFileInNestedDirectoryWithDatasetsFile
|
||||||
✓ uses dataset with (1)
|
✓ uses dataset with (1)
|
||||||
✓ uses dataset with (2)
|
✓ uses dataset with (2)
|
||||||
@ -1052,6 +1141,7 @@
|
|||||||
✓ it can return an array of all test suite filenames
|
✓ it can return an array of all test suite filenames
|
||||||
|
|
||||||
PASS Tests\Visual\BeforeEachTestName
|
PASS Tests\Visual\BeforeEachTestName
|
||||||
|
✓ description
|
||||||
✓ latest description
|
✓ latest description
|
||||||
|
|
||||||
PASS Tests\Visual\Collision
|
PASS Tests\Visual\Collision
|
||||||
@ -1084,4 +1174,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, 742 passed (1787 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 830 passed (1927 assertions)
|
||||||
18
tests/Features/Repeat.php
Normal file
18
tests/Features/Repeat.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
test('once', function () {
|
||||||
|
expect(true)->toBeTrue();
|
||||||
|
})->repeat(times: 1);
|
||||||
|
|
||||||
|
test('multiple times', function () {
|
||||||
|
expect(true)->toBeTrue();
|
||||||
|
})->repeat(times: 5);
|
||||||
|
|
||||||
|
test('multiple times with single dataset', function (int $number) {
|
||||||
|
expect([1, 2, 3])->toContain($number);
|
||||||
|
})->repeat(times: 6)->with(['a' => 1, 'b' => 2, 'c' => 3]);
|
||||||
|
|
||||||
|
test('multiple times with multiple dataset', function (int $numberA, int $numberB) {
|
||||||
|
expect([1, 2, 3])->toContain($numberA)
|
||||||
|
->and([4, 5, 6])->toContain($numberB);
|
||||||
|
})->repeat(times: 7)->with(['a' => 1, 'b' => 2, 'c' => 3], [4, 5, 6]);
|
||||||
@ -1,6 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
beforeEach(fn () => $this->latestDescription = self::$__latestDescription);
|
beforeEach(function () {
|
||||||
|
$this->description = $this->__description;
|
||||||
|
$this->latestDescription = self::$__latestDescription;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('description', function () {
|
||||||
|
expect($this->description)->toBe('description');
|
||||||
|
});
|
||||||
|
|
||||||
test('latest description', function () {
|
test('latest description', function () {
|
||||||
expect($this->latestDescription)->toBe('latest description');
|
expect($this->latestDescription)->toBe('latest description');
|
||||||
|
|||||||
@ -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, 732 passed (1773 assertions)')
|
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 819 passed (1912 assertions)')
|
||||||
->toContain('Parallel: 3 processes');
|
->toContain('Parallel: 3 processes');
|
||||||
})->skipOnWindows();
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user