mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0ff2c8ec2 | |||
| 5e41e546a0 | |||
| 6a8a4f3243 | |||
| ef29b4f091 | |||
| ef120125e0 | |||
| 8a9a416133 | |||
| 4783334f15 | |||
| e8f122bf47 | |||
| 9fc607a2b8 | |||
| b33af71036 | |||
| 3c6c89a6ad | |||
| 55f6b5696e | |||
| 303f4c0113 | |||
| 35a1fcd0cf | |||
| a7a3e4240e | |||
| e4af33867b | |||
| 680111fb1e | |||
| aa6ff95ea4 |
@ -21,6 +21,8 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
|
|||||||
|
|
||||||
### Platinum Sponsors
|
### Platinum Sponsors
|
||||||
|
|
||||||
|
- **[LaraJobs](https://larajobs.com)**
|
||||||
|
- **[Brokerchooser](https://brokerchooser.com)**
|
||||||
- **[Forge](https://forge.laravel.com)**
|
- **[Forge](https://forge.laravel.com)**
|
||||||
- **[Spatie](https://spatie.be)**
|
- **[Spatie](https://spatie.be)**
|
||||||
- **[Worksome](https://www.worksome.com/)**
|
- **[Worksome](https://www.worksome.com/)**
|
||||||
@ -30,9 +32,7 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
|
|||||||
- [Akaunting](https://akaunting.com/?ref=pestphp)
|
- [Akaunting](https://akaunting.com/?ref=pestphp)
|
||||||
- [Codecourse](https://codecourse.com/?ref=pestphp)
|
- [Codecourse](https://codecourse.com/?ref=pestphp)
|
||||||
- [Laracasts](https://laracasts.com/?ref=pestphp)
|
- [Laracasts](https://laracasts.com/?ref=pestphp)
|
||||||
- [Laradir](https://laradir.com/?ref=pestphp)
|
|
||||||
- [Localazy](https://localazy.com/?ref=pestphp)
|
- [Localazy](https://localazy.com/?ref=pestphp)
|
||||||
- [Stormlikes](https://www.stormlikes.net/?ref=pestphp)
|
|
||||||
- [Zapiet](https://www.zapiet.com/?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)**.
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
|||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
$bootPest = (static function (): void {
|
$bootPest = (static function (): void {
|
||||||
$workerArgv = new ArgvInput();
|
$workerArgv = new ArgvInput;
|
||||||
|
|
||||||
$rootPath = dirname(PHPUNIT_COMPOSER_INSTALL, 2);
|
$rootPath = dirname(PHPUNIT_COMPOSER_INSTALL, 2);
|
||||||
$testSuite = TestSuite::getInstance($rootPath, $workerArgv->getParameterOption(
|
$testSuite = TestSuite::getInstance($rootPath, $workerArgv->getParameterOption(
|
||||||
@ -20,7 +20,7 @@ $bootPest = (static function (): void {
|
|||||||
'tests'
|
'tests'
|
||||||
));
|
));
|
||||||
|
|
||||||
$input = new ArgvInput();
|
$input = new ArgvInput;
|
||||||
|
|
||||||
$output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true);
|
$output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true);
|
||||||
|
|
||||||
|
|||||||
@ -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.1.1",
|
"nunomaduro/collision": "^7.10.0|^8.3.0",
|
||||||
"nunomaduro/termwind": "^1.15.1|^2.0.1",
|
"nunomaduro/termwind": "^1.15.1|^2.0.1",
|
||||||
"pestphp/pest-plugin": "^2.1.1",
|
"pestphp/pest-plugin": "^2.1.1",
|
||||||
"pestphp/pest-plugin-arch": "^2.7.0",
|
"pestphp/pest-plugin-arch": "^2.7.0",
|
||||||
"phpunit/phpunit": "^10.5.15"
|
"phpunit/phpunit": "^10.5.17"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"phpunit/phpunit": ">10.5.15",
|
"phpunit/phpunit": ">10.5.17",
|
||||||
"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.8.1",
|
"pestphp/pest-plugin-type-coverage": "^2.8.5",
|
||||||
"symfony/process": "^6.4.0|^7.0.4"
|
"symfony/process": "^6.4.0|^7.1.3"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
|||||||
@ -32,8 +32,7 @@ final class BootSubscribers implements Bootstrapper
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Container $container,
|
private readonly Container $container,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boots the list of Subscribers.
|
* Boots the list of Subscribers.
|
||||||
|
|||||||
@ -50,7 +50,7 @@ final class Thanks
|
|||||||
$wantsToSupport = false;
|
$wantsToSupport = false;
|
||||||
|
|
||||||
if (getenv('PEST_NO_SUPPORT') !== 'true' && $this->input->isInteractive()) {
|
if (getenv('PEST_NO_SUPPORT') !== 'true' && $this->input->isInteractive()) {
|
||||||
$wantsToSupport = (new SymfonyQuestionHelper())->ask(
|
$wantsToSupport = (new SymfonyQuestionHelper)->ask(
|
||||||
new ArrayInput([]),
|
new ArrayInput([]),
|
||||||
$this->output,
|
$this->output,
|
||||||
new ConfirmationQuestion(
|
new ConfirmationQuestion(
|
||||||
|
|||||||
@ -421,7 +421,7 @@ final class Expectation
|
|||||||
*/
|
*/
|
||||||
public function any(): Any
|
public function any(): Any
|
||||||
{
|
{
|
||||||
return new Any();
|
return new Any;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -515,7 +515,7 @@ final class Expectation
|
|||||||
return Targeted::make(
|
return Targeted::make(
|
||||||
$this,
|
$this,
|
||||||
fn (ObjectDescription $object): bool => $object->reflectionClass->hasMethod($method),
|
fn (ObjectDescription $object): bool => $object->reflectionClass->hasMethod($method),
|
||||||
'to have method',
|
sprintf("to have method '%s'", $method),
|
||||||
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,9 +24,7 @@ final class EachExpectation
|
|||||||
*
|
*
|
||||||
* @param Expectation<TValue> $original
|
* @param Expectation<TValue> $original
|
||||||
*/
|
*/
|
||||||
public function __construct(private readonly Expectation $original)
|
public function __construct(private readonly Expectation $original) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new expectation.
|
* Creates a new expectation.
|
||||||
|
|||||||
@ -36,9 +36,7 @@ final class OppositeExpectation
|
|||||||
*
|
*
|
||||||
* @param Expectation<TValue> $original
|
* @param Expectation<TValue> $original
|
||||||
*/
|
*/
|
||||||
public function __construct(private readonly Expectation $original)
|
public function __construct(private readonly Expectation $original) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the value array not has the provided $keys.
|
* Asserts that the value array not has the provided $keys.
|
||||||
|
|||||||
@ -28,8 +28,8 @@ trait HigherOrderable
|
|||||||
*/
|
*/
|
||||||
private function bootHigherOrderable(): void
|
private function bootHigherOrderable(): void
|
||||||
{
|
{
|
||||||
$this->chains = new HigherOrderMessageCollection();
|
$this->chains = new HigherOrderMessageCollection;
|
||||||
$this->factoryProxies = new HigherOrderMessageCollection();
|
$this->factoryProxies = new HigherOrderMessageCollection;
|
||||||
$this->proxies = new HigherOrderMessageCollection();
|
$this->proxies = new HigherOrderMessageCollection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,5 @@ namespace Pest\Factories\Covers;
|
|||||||
*/
|
*/
|
||||||
final class CoversClass
|
final class CoversClass
|
||||||
{
|
{
|
||||||
public function __construct(public string $class)
|
public function __construct(public string $class) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,5 @@ namespace Pest\Factories\Covers;
|
|||||||
*/
|
*/
|
||||||
final class CoversFunction
|
final class CoversFunction
|
||||||
{
|
{
|
||||||
public function __construct(public string $function)
|
public function __construct(public string $function) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,4 @@ namespace Pest\Factories\Covers;
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class CoversNothing
|
final class CoversNothing {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -154,7 +154,7 @@ final class TestCaseFactory
|
|||||||
foreach ($classAvailableAttributes as $attribute) {
|
foreach ($classAvailableAttributes as $attribute) {
|
||||||
$classAttributes = array_reduce(
|
$classAttributes = array_reduce(
|
||||||
$methods,
|
$methods,
|
||||||
fn (array $carry, TestCaseMethodFactory $methodFactory): array => (new $attribute())->__invoke($methodFactory, $carry),
|
fn (array $carry, TestCaseMethodFactory $methodFactory): array => (new $attribute)->__invoke($methodFactory, $carry),
|
||||||
$classAttributes
|
$classAttributes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,11 +138,11 @@ final class TestCaseMethodFactory
|
|||||||
$attributes = [];
|
$attributes = [];
|
||||||
|
|
||||||
foreach ($annotationsToUse as $annotation) {
|
foreach ($annotationsToUse as $annotation) {
|
||||||
$annotations = (new $annotation())->__invoke($this, $annotations);
|
$annotations = (new $annotation)->__invoke($this, $annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($attributesToUse as $attribute) {
|
foreach ($attributesToUse as $attribute) {
|
||||||
$attributes = (new $attribute())->__invoke($this, $attributes);
|
$attributes = (new $attribute)->__invoke($this, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->datasets !== [] || $this->repetitions > 1) {
|
if ($this->datasets !== [] || $this->repetitions > 1) {
|
||||||
|
|||||||
@ -67,7 +67,7 @@ final class Kernel
|
|||||||
->add(Container::class, $container);
|
->add(Container::class, $container);
|
||||||
|
|
||||||
$kernel = new self(
|
$kernel = new self(
|
||||||
new Application(),
|
new Application,
|
||||||
$output,
|
$output,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ final class Converter
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly string $rootPath,
|
private readonly string $rootPath,
|
||||||
) {
|
) {
|
||||||
$this->stateGenerator = new StateGenerator();
|
$this->stateGenerator = new StateGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -17,8 +17,7 @@ final class ServiceMessage
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly string $type,
|
private readonly string $type,
|
||||||
private readonly array $parameters,
|
private readonly array $parameters,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
public function toString(): string
|
public function toString(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,9 +14,7 @@ abstract class Subscriber
|
|||||||
/**
|
/**
|
||||||
* Creates a new Subscriber instance.
|
* Creates a new Subscriber instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(private readonly TeamCityLogger $logger)
|
public function __construct(private readonly TeamCityLogger $logger) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new TeamCityLogger instance.
|
* Creates a new TeamCityLogger instance.
|
||||||
|
|||||||
@ -7,6 +7,4 @@ namespace Pest\Matchers;
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class Any
|
final class Any {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -314,7 +314,7 @@ final class Expectation
|
|||||||
*
|
*
|
||||||
* @return self<TValue>
|
* @return self<TValue>
|
||||||
*/
|
*/
|
||||||
public function toHaveProperty(string $name, mixed $value = new Any(), string $message = ''): self
|
public function toHaveProperty(string $name, mixed $value = new Any, string $message = ''): self
|
||||||
{
|
{
|
||||||
$this->toBeObject();
|
$this->toBeObject();
|
||||||
|
|
||||||
@ -467,6 +467,18 @@ final class Expectation
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the value is a list.
|
||||||
|
*
|
||||||
|
* @return self<TValue>
|
||||||
|
*/
|
||||||
|
public function toBeList(string $message = ''): self
|
||||||
|
{
|
||||||
|
Assert::assertIsList($this->value, $message);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the value is of type bool.
|
* Asserts that the value is of type bool.
|
||||||
*
|
*
|
||||||
@ -642,7 +654,7 @@ final class Expectation
|
|||||||
*
|
*
|
||||||
* @return self<TValue>
|
* @return self<TValue>
|
||||||
*/
|
*/
|
||||||
public function toHaveKey(string|int $key, mixed $value = new Any(), string $message = ''): self
|
public function toHaveKey(string|int $key, mixed $value = new Any, string $message = ''): self
|
||||||
{
|
{
|
||||||
if (is_object($this->value) && method_exists($this->value, 'toArray')) {
|
if (is_object($this->value) && method_exists($this->value, 'toArray')) {
|
||||||
$array = $this->value->toArray();
|
$array = $this->value->toArray();
|
||||||
|
|||||||
@ -42,7 +42,7 @@ final class Panic
|
|||||||
try {
|
try {
|
||||||
$output = Container::getInstance()->get(OutputInterface::class);
|
$output = Container::getInstance()->get(OutputInterface::class);
|
||||||
} catch (Throwable) { // @phpstan-ignore-line
|
} catch (Throwable) { // @phpstan-ignore-line
|
||||||
$output = new ConsoleOutput();
|
$output = new ConsoleOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert($output instanceof OutputInterface);
|
assert($output instanceof OutputInterface);
|
||||||
|
|||||||
@ -39,7 +39,7 @@ final class AfterEachCall
|
|||||||
) {
|
) {
|
||||||
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
||||||
|
|
||||||
$this->proxies = new HigherOrderMessageCollection();
|
$this->proxies = new HigherOrderMessageCollection;
|
||||||
|
|
||||||
$this->describing = DescribeCall::describing();
|
$this->describing = DescribeCall::describing();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,8 +44,8 @@ final class BeforeEachCall
|
|||||||
) {
|
) {
|
||||||
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
||||||
|
|
||||||
$this->testCallProxies = new HigherOrderMessageCollection();
|
$this->testCallProxies = new HigherOrderMessageCollection;
|
||||||
$this->testCaseProxies = new HigherOrderMessageCollection();
|
$this->testCaseProxies = new HigherOrderMessageCollection;
|
||||||
|
|
||||||
$this->describing = DescribeCall::describing();
|
$this->describing = DescribeCall::describing();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -369,7 +369,7 @@ final class TestCall
|
|||||||
*/
|
*/
|
||||||
public function coversNothing(): self
|
public function coversNothing(): self
|
||||||
{
|
{
|
||||||
$this->testCaseMethod->covers = [new CoversNothing()];
|
$this->testCaseMethod->covers = [new CoversNothing];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '2.34.5';
|
return '2.35.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -97,7 +97,7 @@ final class Help implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
private function getContent(): array
|
private function getContent(): array
|
||||||
{
|
{
|
||||||
$helpReflection = new PHPUnitHelp();
|
$helpReflection = new PHPUnitHelp;
|
||||||
|
|
||||||
$content = (fn (): array => $this->elements())->call($helpReflection);
|
$content = (fn (): array => $this->elements())->call($helpReflection);
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ final class Parallel implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
public static function isEnabled(): bool
|
public static function isEnabled(): bool
|
||||||
{
|
{
|
||||||
$argv = new ArgvInput();
|
$argv = new ArgvInput;
|
||||||
if ($argv->hasParameterOption('--parallel')) {
|
if ($argv->hasParameterOption('--parallel')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ final class Parallel implements HandlesArguments
|
|||||||
$arguments
|
$arguments
|
||||||
);
|
);
|
||||||
|
|
||||||
$exitCode = $this->paratestCommand()->run(new ArgvInput($filteredArguments), new CleanConsoleOutput());
|
$exitCode = $this->paratestCommand()->run(new ArgvInput($filteredArguments), new CleanConsoleOutput);
|
||||||
|
|
||||||
return CallsAddsOutput::execute($exitCode);
|
return CallsAddsOutput::execute($exitCode);
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ final class Parallel implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
private function hasArgumentsThatWouldBeFasterWithoutParallel(): bool
|
private function hasArgumentsThatWouldBeFasterWithoutParallel(): bool
|
||||||
{
|
{
|
||||||
$arguments = new ArgvInput();
|
$arguments = new ArgvInput;
|
||||||
|
|
||||||
foreach (self::UNSUPPORTED_ARGUMENTS as $unsupportedArgument) {
|
foreach (self::UNSUPPORTED_ARGUMENTS as $unsupportedArgument) {
|
||||||
if ($arguments->hasParameterOption($unsupportedArgument)) {
|
if ($arguments->hasParameterOption($unsupportedArgument)) {
|
||||||
|
|||||||
@ -63,8 +63,7 @@ final class ResultPrinter
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly OutputInterface $output,
|
private readonly OutputInterface $output,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
public function print(string $buffer): void
|
public function print(string $buffer): void
|
||||||
{
|
{
|
||||||
@ -79,9 +78,7 @@ final class ResultPrinter
|
|||||||
$this->output->write(OutputFormatter::escape($buffer));
|
$this->output->write(OutputFormatter::escape($buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function flush(): void
|
public function flush(): void {}
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$this->compactPrinter = CompactPrinter::default();
|
$this->compactPrinter = CompactPrinter::default();
|
||||||
@ -172,7 +169,7 @@ final class ResultPrinter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$state = (new StateGenerator())->fromPhpUnitTestResult($this->passedTests, $testResult);
|
$state = (new StateGenerator)->fromPhpUnitTestResult($this->passedTests, $testResult);
|
||||||
|
|
||||||
$this->compactPrinter->errors($state);
|
$this->compactPrinter->errors($state);
|
||||||
$this->compactPrinter->recap($state, $testResult, $duration, $this->options);
|
$this->compactPrinter->recap($state, $testResult, $duration, $this->options);
|
||||||
|
|||||||
@ -91,13 +91,13 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
private readonly OutputInterface $output
|
private readonly OutputInterface $output
|
||||||
) {
|
) {
|
||||||
$this->printer = new ResultPrinter($output, $options);
|
$this->printer = new ResultPrinter($output, $options);
|
||||||
$this->timer = new Timer();
|
$this->timer = new Timer;
|
||||||
|
|
||||||
$wrapper = realpath(
|
$wrapper = realpath(
|
||||||
dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'worker.php',
|
dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'worker.php',
|
||||||
);
|
);
|
||||||
assert($wrapper !== false);
|
assert($wrapper !== false);
|
||||||
$phpFinder = new PhpExecutableFinder();
|
$phpFinder = new PhpExecutableFinder;
|
||||||
$phpBin = $phpFinder->find(false);
|
$phpBin = $phpFinder->find(false);
|
||||||
assert($phpBin !== false);
|
assert($phpBin !== false);
|
||||||
$parameters = [$phpBin];
|
$parameters = [$phpBin];
|
||||||
@ -110,7 +110,7 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
$parameters[] = $wrapper;
|
$parameters[] = $wrapper;
|
||||||
|
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
$this->codeCoverageFilterRegistry = new CodeCoverageFilterRegistry();
|
$this->codeCoverageFilterRegistry = new CodeCoverageFilterRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(): int
|
public function run(): int
|
||||||
@ -357,7 +357,7 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$coverageManager = new CodeCoverage();
|
$coverageManager = new CodeCoverage;
|
||||||
$coverageManager->init(
|
$coverageManager->init(
|
||||||
$this->options->configuration,
|
$this->options->configuration,
|
||||||
$this->codeCoverageFilterRegistry,
|
$this->codeCoverageFilterRegistry,
|
||||||
@ -389,8 +389,8 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$testSuite = (new LogMerger())->merge($this->junitFiles);
|
$testSuite = (new LogMerger)->merge($this->junitFiles);
|
||||||
(new Writer())->write(
|
(new Writer)->write(
|
||||||
$testSuite,
|
$testSuite,
|
||||||
$this->options->configuration->logfileJunit(),
|
$this->options->configuration->logfileJunit(),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -21,8 +21,7 @@ final class SnapshotRepository
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
readonly private string $testsPath,
|
readonly private string $testsPath,
|
||||||
readonly private string $snapshotsPath,
|
readonly private string $snapshotsPath,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the snapshot exists.
|
* Checks if the snapshot exists.
|
||||||
|
|||||||
@ -24,8 +24,7 @@ final class EnsureTeamCityEnabled implements ConfiguredSubscriber
|
|||||||
private readonly InputInterface $input,
|
private readonly InputInterface $input,
|
||||||
private readonly OutputInterface $output,
|
private readonly OutputInterface $output,
|
||||||
private readonly TestSuite $testSuite,
|
private readonly TestSuite $testSuite,
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the subscriber.
|
* Runs the subscriber.
|
||||||
|
|||||||
@ -26,7 +26,7 @@ final class Container
|
|||||||
public static function getInstance(): self
|
public static function getInstance(): self
|
||||||
{
|
{
|
||||||
if (! self::$instance instanceof \Pest\Support\Container) {
|
if (! self::$instance instanceof \Pest\Support\Container) {
|
||||||
self::$instance = new self();
|
self::$instance = new self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ final class Coverage
|
|||||||
*/
|
*/
|
||||||
public static function isAvailable(): bool
|
public static function isAvailable(): bool
|
||||||
{
|
{
|
||||||
$runtime = new Runtime();
|
$runtime = new Runtime;
|
||||||
|
|
||||||
if (! $runtime->canCollectCodeCoverage()) {
|
if (! $runtime->canCollectCodeCoverage()) {
|
||||||
return false;
|
return false;
|
||||||
@ -67,7 +67,7 @@ final class Coverage
|
|||||||
*/
|
*/
|
||||||
public static function usingXdebug(): bool
|
public static function usingXdebug(): bool
|
||||||
{
|
{
|
||||||
return (new Runtime())->hasXdebug();
|
return (new Runtime)->hasXdebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -30,8 +30,7 @@ final class ExpectationPipeline
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Closure $closure
|
private readonly Closure $closure
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of Expectation Pipeline with given closure.
|
* Creates a new instance of Expectation Pipeline with given closure.
|
||||||
|
|||||||
@ -32,7 +32,7 @@ final class Exporter
|
|||||||
public static function default(): self
|
public static function default(): self
|
||||||
{
|
{
|
||||||
return new self(
|
return new self(
|
||||||
new BaseExporter()
|
new BaseExporter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ final class Exporter
|
|||||||
$array = $data;
|
$array = $data;
|
||||||
$itemsCount = 0;
|
$itemsCount = 0;
|
||||||
$exporter = self::default();
|
$exporter = self::default();
|
||||||
$context ??= new Context();
|
$context ??= new Context;
|
||||||
|
|
||||||
$context->add($data);
|
$context->add($data);
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,6 @@ final class NullClosure
|
|||||||
*/
|
*/
|
||||||
public static function create(): Closure
|
public static function create(): Closure
|
||||||
{
|
{
|
||||||
return Closure::fromCallable(function (): void {
|
return Closure::fromCallable(function (): void {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ final class StateGenerator
|
|||||||
{
|
{
|
||||||
public function fromPhpUnitTestResult(int $passedTests, PHPUnitTestResult $testResult): State
|
public function fromPhpUnitTestResult(int $passedTests, PHPUnitTestResult $testResult): State
|
||||||
{
|
{
|
||||||
$state = new State();
|
$state = new State;
|
||||||
|
|
||||||
foreach ($testResult->testErroredEvents() as $testResultEvent) {
|
foreach ($testResult->testErroredEvents() as $testResultEvent) {
|
||||||
if ($testResultEvent instanceof Errored) {
|
if ($testResultEvent instanceof Errored) {
|
||||||
|
|||||||
@ -76,7 +76,7 @@ final class GitDirtyTestCaseFilter implements TestCaseFilter
|
|||||||
$dirtyFiles = array_values($dirtyFiles);
|
$dirtyFiles = array_values($dirtyFiles);
|
||||||
|
|
||||||
if ($dirtyFiles === []) {
|
if ($dirtyFiles === []) {
|
||||||
Panic::with(new NoDirtyTestsFound());
|
Panic::with(new NoDirtyTestsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->changedFiles = $dirtyFiles;
|
$this->changedFiles = $dirtyFiles;
|
||||||
|
|||||||
@ -71,11 +71,11 @@ final class TestSuite
|
|||||||
string $rootPath,
|
string $rootPath,
|
||||||
public string $testPath,
|
public string $testPath,
|
||||||
) {
|
) {
|
||||||
$this->beforeAll = new BeforeAllRepository();
|
$this->beforeAll = new BeforeAllRepository;
|
||||||
$this->beforeEach = new BeforeEachRepository();
|
$this->beforeEach = new BeforeEachRepository;
|
||||||
$this->tests = new TestRepository();
|
$this->tests = new TestRepository;
|
||||||
$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(
|
||||||
implode(DIRECTORY_SEPARATOR, [$this->rootPath, $this->testPath]),
|
implode(DIRECTORY_SEPARATOR, [$this->rootPath, $this->testPath]),
|
||||||
@ -101,7 +101,7 @@ final class TestSuite
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! self::$instance instanceof self) {
|
if (! self::$instance instanceof self) {
|
||||||
Panic::with(new InvalidPestCommand());
|
Panic::with(new InvalidPestCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
|
|||||||
@ -6,5 +6,5 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
use CreatesApplication;
|
//
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.34.5.
|
Pest Testing Framework 2.35.0.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 2.34.5.
|
Pest Testing Framework 2.35.0.
|
||||||
|
|
||||||
|
|||||||
@ -511,6 +511,12 @@
|
|||||||
✓ passes with strings
|
✓ passes with strings
|
||||||
✓ failures
|
✓ failures
|
||||||
✓ failures with custom message
|
✓ failures with custom message
|
||||||
|
✓ not failures
|
||||||
|
|
||||||
|
PASS Tests\Features\Expect\toBeList
|
||||||
|
✓ pass
|
||||||
|
✓ failures
|
||||||
|
✓ failures with custom message
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Features\Expect\toBeLowercase
|
PASS Tests\Features\Expect\toBeLowercase
|
||||||
@ -1418,4 +1424,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, 20 skipped, 1009 passed (2395 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1013 passed (2405 assertions)
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
|
|
||||||
beforeEach(function () use ($state) {
|
beforeEach(function () use ($state) {
|
||||||
$this->state = $state;
|
$this->state = $state;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$foo = new \stdClass();
|
$foo = new \stdClass;
|
||||||
$foo->bar = 0;
|
$foo->bar = 0;
|
||||||
|
|
||||||
beforeAll(function () use ($foo) {
|
beforeAll(function () use ($foo) {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
|||||||
it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));
|
it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));
|
||||||
|
|
||||||
it('adds coverage if --coverage exist', function () {
|
it('adds coverage if --coverage exist', function () {
|
||||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
$plugin = new CoveragePlugin(new ConsoleOutput);
|
||||||
|
|
||||||
expect($plugin->coverage)->toBeFalse();
|
expect($plugin->coverage)->toBeFalse();
|
||||||
$arguments = $plugin->handleArguments([]);
|
$arguments = $plugin->handleArguments([]);
|
||||||
@ -20,7 +20,7 @@ it('adds coverage if --coverage exist', function () {
|
|||||||
})->skip(! \Pest\Support\Coverage::isAvailable() || ! function_exists('xdebug_info') || ! in_array('coverage', xdebug_info('mode'), true), 'Coverage is not available');
|
})->skip(! \Pest\Support\Coverage::isAvailable() || ! function_exists('xdebug_info') || ! in_array('coverage', xdebug_info('mode'), true), 'Coverage is not available');
|
||||||
|
|
||||||
it('adds coverage if --min exist', function () {
|
it('adds coverage if --min exist', function () {
|
||||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
$plugin = new CoveragePlugin(new ConsoleOutput);
|
||||||
expect($plugin->coverageMin)->toEqual(0.0)
|
expect($plugin->coverageMin)->toEqual(0.0)
|
||||||
->and($plugin->coverage)->toBeFalse();
|
->and($plugin->coverage)->toBeFalse();
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ it('adds coverage if --min exist', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('generates coverage based on file input', function () {
|
it('generates coverage based on file input', function () {
|
||||||
expect(Coverage::getMissingCoverage(new class()
|
expect(Coverage::getMissingCoverage(new class
|
||||||
{
|
{
|
||||||
public function lineCoverageData(): array
|
public function lineCoverageData(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,9 +10,7 @@ use Tests\Fixtures\Covers\CoversTrait;
|
|||||||
|
|
||||||
$runCounter = 0;
|
$runCounter = 0;
|
||||||
|
|
||||||
function testCoversFunction()
|
function testCoversFunction() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
it('uses the correct PHPUnit attribute for class', function () {
|
it('uses the correct PHPUnit attribute for class', function () {
|
||||||
$attributes = (new ReflectionClass($this))->getAttributes();
|
$attributes = (new ReflectionClass($this))->getAttributes();
|
||||||
|
|||||||
@ -46,7 +46,7 @@ test('it truncates the description', function () {
|
|||||||
// it gets tested by the integration test
|
// it gets tested by the integration test
|
||||||
})->with([str_repeat('Fooo', 10)]);
|
})->with([str_repeat('Fooo', 10)]);
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
|
|
||||||
$datasets = [[1], [2]];
|
$datasets = [[1], [2]];
|
||||||
@ -119,7 +119,7 @@ class Bar
|
|||||||
}
|
}
|
||||||
|
|
||||||
$namedDatasets = [
|
$namedDatasets = [
|
||||||
new Bar(),
|
new Bar,
|
||||||
];
|
];
|
||||||
|
|
||||||
test('lazy named datasets', function ($text) {
|
test('lazy named datasets', function ($text) {
|
||||||
@ -132,12 +132,12 @@ it('creates unique test case names', function (string $name, Plugin $plugin, boo
|
|||||||
expect(true)->toBeTrue();
|
expect(true)->toBeTrue();
|
||||||
$counter++;
|
$counter++;
|
||||||
})->with([
|
})->with([
|
||||||
['Name 1', new Plugin(), true],
|
['Name 1', new Plugin, true],
|
||||||
['Name 1', new Plugin(), true],
|
['Name 1', new Plugin, true],
|
||||||
['Name 1', new Plugin(), false],
|
['Name 1', new Plugin, false],
|
||||||
['Name 2', new Plugin(), false],
|
['Name 2', new Plugin, false],
|
||||||
['Name 2', new Plugin(), true],
|
['Name 2', new Plugin, true],
|
||||||
['Name 1', new Plugin(), true],
|
['Name 1', new Plugin, true],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
it('creates unique test case names - count', function () use (&$counter) {
|
it('creates unique test case names - count', function () use (&$counter) {
|
||||||
@ -230,7 +230,7 @@ test('more than two datasets did the job right', function () use ($state) {
|
|||||||
expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246');
|
expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246');
|
||||||
});
|
});
|
||||||
|
|
||||||
$wrapped_generator_state = new stdClass();
|
$wrapped_generator_state = new stdClass;
|
||||||
$wrapped_generator_state->text = '';
|
$wrapped_generator_state->text = '';
|
||||||
$wrapped_generator_function_datasets = [1, 2, 3, 4];
|
$wrapped_generator_function_datasets = [1, 2, 3, 4];
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
it('gives access the the underlying expectException', function () {
|
it('gives access the the underlying expectException', function () {
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
throw new InvalidArgumentException();
|
throw new InvalidArgumentException;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('catch exceptions', function () {
|
it('catch exceptions', function () {
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
it('can access methods', function () {
|
it('can access methods', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->name()->toBeString()->toEqual('Has Methods');
|
->name()->toBeString()->toEqual('Has Methods');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can access multiple methods', function () {
|
it('can access multiple methods', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->name()->toBeString()->toEqual('Has Methods')
|
->name()->toBeString()->toEqual('Has Methods')
|
||||||
->quantity()->toBeInt()->toEqual(20);
|
->quantity()->toBeInt()->toEqual(20);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with not', function () {
|
it('works with not', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->name()->not->toEqual('world')->toEqual('Has Methods')
|
->name()->not->toEqual('world')->toEqual('Has Methods')
|
||||||
->quantity()->toEqual(20)->not()->toEqual('bar')->not->toBeNull;
|
->quantity()->toEqual(20)->not()->toEqual('bar')->not->toBeNull;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can accept arguments', function () {
|
it('can accept arguments', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->multiply(5, 4)->toBeInt->toEqual(20);
|
->multiply(5, 4)->toBeInt->toEqual(20);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with each', function () {
|
it('works with each', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->attributes()->toBeArray->each->not()->toBeNull
|
->attributes()->toBeArray->each->not()->toBeNull
|
||||||
->attributes()->each(function ($attribute) {
|
->attributes()->each(function ($attribute) {
|
||||||
$attribute->not->toBeNull();
|
$attribute->not->toBeNull();
|
||||||
@ -31,14 +31,14 @@ it('works with each', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works inside of each', function () {
|
it('works inside of each', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->books()->each(function ($book) {
|
->books()->each(function ($book) {
|
||||||
$book->title->not->toBeNull->cost->toBeGreaterThan(19);
|
$book->title->not->toBeNull->cost->toBeGreaterThan(19);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with sequence', function () {
|
it('works with sequence', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->books()->sequence(
|
->books()->sequence(
|
||||||
function ($book) {
|
function ($book) {
|
||||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||||
@ -50,7 +50,7 @@ it('works with sequence', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can compose complex expectations', function () {
|
it('can compose complex expectations', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->toBeObject()
|
->toBeObject()
|
||||||
->name()->toEqual('Has Methods')->not()->toEqual('bar')
|
->name()->toEqual('Has Methods')->not()->toEqual('bar')
|
||||||
->quantity()->not->toEqual('world')->toEqual(20)->toBeInt
|
->quantity()->not->toEqual('world')->toEqual(20)->toBeInt
|
||||||
@ -68,7 +68,7 @@ it('can compose complex expectations', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can handle nested method calls', function () {
|
it('can handle nested method calls', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
|
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
|
||||||
->newInstance()->name()->toEqual('Has Methods')->not->toBeInt
|
->newInstance()->name()->toEqual('Has Methods')->not->toBeInt
|
||||||
->name()->toEqual('Has Methods')
|
->name()->toEqual('Has Methods')
|
||||||
@ -76,14 +76,14 @@ it('can handle nested method calls', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with higher order tests')
|
it('works with higher order tests')
|
||||||
->expect(new HasMethods())
|
->expect(new HasMethods)
|
||||||
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
|
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
|
||||||
->newInstance()->name()->toEqual('Has Methods')->not->toBeArray
|
->newInstance()->name()->toEqual('Has Methods')->not->toBeArray
|
||||||
->name()->toEqual('Has Methods')
|
->name()->toEqual('Has Methods')
|
||||||
->books()->each->toBeArray;
|
->books()->each->toBeArray;
|
||||||
|
|
||||||
it('can use the scoped method to lock into the given level for expectations', function () {
|
it('can use the scoped method to lock into the given level for expectations', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->attributes()->scoped(fn ($attributes) => $attributes
|
->attributes()->scoped(fn ($attributes) => $attributes
|
||||||
->name->toBe('Has Methods')
|
->name->toBe('Has Methods')
|
||||||
->quantity->toBe(20)
|
->quantity->toBe(20)
|
||||||
@ -100,7 +100,7 @@ it('can use the scoped method to lock into the given level for expectations', fu
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works consistently with the json expectation method', function () {
|
it('works consistently with the json expectation method', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->jsonString()->json()->id->toBe(1)
|
->jsonString()->json()->id->toBe(1)
|
||||||
->jsonString()->json()->name->toBe('Has Methods')->toBeString()
|
->jsonString()->json()->name->toBe('Has Methods')->toBeString()
|
||||||
->jsonString()->json()->quantity->toBe(20)->toBeInt();
|
->jsonString()->json()->quantity->toBe(20)->toBeInt();
|
||||||
@ -152,6 +152,6 @@ class HasMethods
|
|||||||
|
|
||||||
public function newInstance()
|
public function newInstance()
|
||||||
{
|
{
|
||||||
return new static();
|
return new static;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
it('can access methods and properties', function () {
|
it('can access methods and properties', function () {
|
||||||
expect(new HasMethodsAndProperties())
|
expect(new HasMethodsAndProperties)
|
||||||
->name->toEqual('Has Methods and Properties')->not()->toEqual('bar')
|
->name->toEqual('Has Methods and Properties')->not()->toEqual('bar')
|
||||||
->multiply(3, 4)->not->toBeString->toEqual(12)
|
->multiply(3, 4)->not->toBeString->toEqual(12)
|
||||||
->posts->each(function ($post) {
|
->posts->each(function ($post) {
|
||||||
@ -19,7 +19,7 @@ it('can access methods and properties', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can handle nested methods and properties', function () {
|
it('can handle nested methods and properties', function () {
|
||||||
expect(new HasMethodsAndProperties())
|
expect(new HasMethodsAndProperties)
|
||||||
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
|
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
|
||||||
->newInstance()->meta->foo->toBeArray()
|
->newInstance()->meta->foo->toBeArray()
|
||||||
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
|
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
|
||||||
@ -27,14 +27,14 @@ it('can handle nested methods and properties', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with higher order tests')
|
it('works with higher order tests')
|
||||||
->expect(new HasMethodsAndProperties())
|
->expect(new HasMethodsAndProperties)
|
||||||
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
|
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
|
||||||
->newInstance()->meta->foo->toBeArray
|
->newInstance()->meta->foo->toBeArray
|
||||||
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
|
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
|
||||||
->newInstance()->books()->toBeArray();
|
->newInstance()->books()->toBeArray();
|
||||||
|
|
||||||
it('can start a new higher order expectation using the and syntax', function () {
|
it('can start a new higher order expectation using the and syntax', function () {
|
||||||
expect(new HasMethodsAndProperties())
|
expect(new HasMethodsAndProperties)
|
||||||
->toBeInstanceOf(HasMethodsAndProperties::class)
|
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||||
->meta->toBeArray
|
->meta->toBeArray
|
||||||
->and(['foo' => 'bar'])
|
->and(['foo' => 'bar'])
|
||||||
@ -45,7 +45,7 @@ it('can start a new higher order expectation using the and syntax', function ()
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can start a new higher order expectation using the and syntax in higher order tests')
|
it('can start a new higher order expectation using the and syntax in higher order tests')
|
||||||
->expect(new HasMethodsAndProperties())
|
->expect(new HasMethodsAndProperties)
|
||||||
->toBeInstanceOf(HasMethodsAndProperties::class)
|
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||||
->meta->toBeArray
|
->meta->toBeArray
|
||||||
->and(['foo' => 'bar'])
|
->and(['foo' => 'bar'])
|
||||||
@ -53,7 +53,7 @@ it('can start a new higher order expectation using the and syntax in higher orde
|
|||||||
->foo->toEqual('bar');
|
->foo->toEqual('bar');
|
||||||
|
|
||||||
it('can start a new higher order expectation using the and syntax without nesting expectations', function () {
|
it('can start a new higher order expectation using the and syntax without nesting expectations', function () {
|
||||||
expect(new HasMethodsAndProperties())
|
expect(new HasMethodsAndProperties)
|
||||||
->toBeInstanceOf(HasMethodsAndProperties::class)
|
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||||
->meta
|
->meta
|
||||||
->sequence(
|
->sequence(
|
||||||
@ -101,6 +101,6 @@ class HasMethodsAndProperties
|
|||||||
|
|
||||||
public function newInstance()
|
public function newInstance()
|
||||||
{
|
{
|
||||||
return new static();
|
return new static;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ it('can compose complex expectations', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with objects', function () {
|
it('works with objects', function () {
|
||||||
expect(new HasProperties())
|
expect(new HasProperties)
|
||||||
->name->toEqual('foo')->not->toEqual('world')
|
->name->toEqual('foo')->not->toEqual('world')
|
||||||
->posts->toHaveCount(2)->each(function ($post) {
|
->posts->toHaveCount(2)->each(function ($post) {
|
||||||
$post->is_published->toBeTrue();
|
$post->is_published->toBeTrue();
|
||||||
@ -69,13 +69,13 @@ it('works with objects', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with nested properties', function () {
|
it('works with nested properties', function () {
|
||||||
expect(new HasProperties())
|
expect(new HasProperties)
|
||||||
->nested->foo->bar->toBeString()->toEqual('baz')
|
->nested->foo->bar->toBeString()->toEqual('baz')
|
||||||
->posts->toBeArray()->toHaveCount(2);
|
->posts->toBeArray()->toHaveCount(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with higher order tests')
|
it('works with higher order tests')
|
||||||
->expect(new HasProperties())
|
->expect(new HasProperties)
|
||||||
->nested->foo->bar->toBeString()->toEqual('baz')
|
->nested->foo->bar->toBeString()->toEqual('baz')
|
||||||
->posts->toBeArray()->toHaveCount(2);
|
->posts->toBeArray()->toHaveCount(2);
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class State
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$state = new State();
|
$state = new State;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Overrides toBe to assert two Characters are the same
|
* Overrides toBe to assert two Characters are the same
|
||||||
|
|||||||
@ -5,8 +5,8 @@ use PHPUnit\Framework\ExpectationFailedException;
|
|||||||
expect(true)->toBeTrue()->and(false)->toBeFalse();
|
expect(true)->toBeTrue()->and(false)->toBeFalse();
|
||||||
|
|
||||||
test('strict comparisons', function () {
|
test('strict comparisons', function () {
|
||||||
$nuno = new stdClass();
|
$nuno = new stdClass;
|
||||||
$dries = new stdClass();
|
$dries = new stdClass;
|
||||||
|
|
||||||
expect($nuno)->toBe($nuno)->not->toBe($dries);
|
expect($nuno)->toBe($nuno)->not->toBe($dries);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,8 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
expect(function () {
|
expect(function () {})->toBeCallable();
|
||||||
})->toBeCallable();
|
|
||||||
expect(null)->not->toBeCallable();
|
expect(null)->not->toBeCallable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ test('passes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes with DateTime and DateTimeImmutable', function () {
|
test('passes with DateTime and DateTimeImmutable', function () {
|
||||||
$now = new DateTime();
|
$now = new DateTime;
|
||||||
$past = (new DateTimeImmutable())->modify('-1 day');
|
$past = (new DateTimeImmutable)->modify('-1 day');
|
||||||
|
|
||||||
expect($now)->toBeGreaterThan($past);
|
expect($now)->toBeGreaterThan($past);
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ test('passes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes with DateTime and DateTimeImmutable', function () {
|
test('passes with DateTime and DateTimeImmutable', function () {
|
||||||
$now = new DateTime();
|
$now = new DateTime;
|
||||||
$past = (new DateTimeImmutable())->modify('-1 day');
|
$past = (new DateTimeImmutable)->modify('-1 day');
|
||||||
|
|
||||||
expect($now)->toBeGreaterThanOrEqual($now);
|
expect($now)->toBeGreaterThanOrEqual($now);
|
||||||
|
|
||||||
|
|||||||
@ -3,18 +3,18 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
expect(new Exception())->toBeInstanceOf(Exception::class);
|
expect(new Exception)->toBeInstanceOf(Exception::class);
|
||||||
expect(new Exception())->not->toBeInstanceOf(RuntimeException::class);
|
expect(new Exception)->not->toBeInstanceOf(RuntimeException::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
expect(new Exception())->toBeInstanceOf(RuntimeException::class);
|
expect(new Exception)->toBeInstanceOf(RuntimeException::class);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('failures with custom message', function () {
|
test('failures with custom message', function () {
|
||||||
expect(new Exception())->toBeInstanceOf(RuntimeException::class, 'oh no!');
|
expect(new Exception)->toBeInstanceOf(RuntimeException::class, 'oh no!');
|
||||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
expect(new Exception())->not->toBeInstanceOf(Exception::class);
|
expect(new Exception)->not->toBeInstanceOf(Exception::class);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|||||||
@ -8,8 +8,8 @@ test('passes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes with DateTime and DateTimeImmutable', function () {
|
test('passes with DateTime and DateTimeImmutable', function () {
|
||||||
$now = new DateTime();
|
$now = new DateTime;
|
||||||
$past = (new DateTimeImmutable())->modify('-1 day');
|
$past = (new DateTimeImmutable)->modify('-1 day');
|
||||||
|
|
||||||
expect($past)->toBeLessThan($now);
|
expect($past)->toBeLessThan($now);
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ test('passes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes with DateTime and DateTimeImmutable', function () {
|
test('passes with DateTime and DateTimeImmutable', function () {
|
||||||
$now = new DateTime();
|
$now = new DateTime;
|
||||||
$past = (new DateTimeImmutable())->modify('-1 day');
|
$past = (new DateTimeImmutable)->modify('-1 day');
|
||||||
|
|
||||||
expect($now)->toBeLessThanOrEqual($now);
|
expect($now)->toBeLessThanOrEqual($now);
|
||||||
|
|
||||||
|
|||||||
21
tests/Features/Expect/toBeList.php
Normal file
21
tests/Features/Expect/toBeList.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
|
test('pass', function () {
|
||||||
|
expect([1, 2, 3])->toBeList();
|
||||||
|
expect(['a' => 1, 'b' => 2, 'c' => 3])->not->toBeList();
|
||||||
|
expect('1, 2, 3')->not->toBeList();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('failures', function () {
|
||||||
|
expect(null)->toBeList();
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
|
test('failures with custom message', function () {
|
||||||
|
expect(null)->toBeList('oh no!');
|
||||||
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
|
test('not failures', function () {
|
||||||
|
expect(['a', 'b', 'c'])->not->toBeList();
|
||||||
|
})->throws(ExpectationFailedException::class);
|
||||||
@ -3,7 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->times = [new DateTimeImmutable(), new DateTimeImmutable()];
|
$this->times = [new DateTimeImmutable, new DateTimeImmutable];
|
||||||
});
|
});
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
|
|||||||
@ -4,13 +4,9 @@ use PHPUnit\Framework\ExpectationFailedException;
|
|||||||
|
|
||||||
$object = new class
|
$object = new class
|
||||||
{
|
{
|
||||||
public function foo(): void
|
public function foo(): void {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function bar(): void
|
public function bar(): void {}
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
test('pass', function () use ($object) {
|
test('pass', function () use ($object) {
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass;
|
||||||
$object->name = 'John';
|
$object->name = 'John';
|
||||||
$object->age = 21;
|
$object->age = 21;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ test('pass', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass;
|
||||||
$object->name = 'John';
|
$object->name = 'John';
|
||||||
|
|
||||||
expect($object)
|
expect($object)
|
||||||
@ -28,7 +28,7 @@ test('failures', function () {
|
|||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('failures with custom message', function () {
|
test('failures with custom message', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass;
|
||||||
$object->name = 'John';
|
$object->name = 'John';
|
||||||
|
|
||||||
expect($object)
|
expect($object)
|
||||||
@ -40,7 +40,7 @@ test('failures with custom message', function () {
|
|||||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass;
|
||||||
$object->name = 'John';
|
$object->name = 'John';
|
||||||
$object->age = 21;
|
$object->age = 21;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
$obj = new stdClass();
|
$obj = new stdClass;
|
||||||
$obj->foo = 'bar';
|
$obj->foo = 'bar';
|
||||||
$obj->fooNull = null;
|
$obj->fooNull = null;
|
||||||
|
|
||||||
|
|||||||
@ -4,17 +4,17 @@ use PHPUnit\Framework\Constraint\IsTrue;
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
expect(true)->toMatchConstraint(new IsTrue());
|
expect(true)->toMatchConstraint(new IsTrue);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
expect(false)->toMatchConstraint(new IsTrue());
|
expect(false)->toMatchConstraint(new IsTrue);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('failures with custom message', function () {
|
test('failures with custom message', function () {
|
||||||
expect(false)->toMatchConstraint(new IsTrue(), 'oh no!');
|
expect(false)->toMatchConstraint(new IsTrue, 'oh no!');
|
||||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
expect(true)->not->toMatchConstraint(new IsTrue());
|
expect(true)->not->toMatchConstraint(new IsTrue);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|||||||
@ -18,7 +18,7 @@ test('pass', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('pass with class', function () {
|
test('pass with class', function () {
|
||||||
expect(new class()
|
expect(new class
|
||||||
{
|
{
|
||||||
public $name = 'Nuno';
|
public $name = 'Nuno';
|
||||||
|
|
||||||
|
|||||||
@ -43,9 +43,7 @@ test('pass with `__toString`', function () {
|
|||||||
|
|
||||||
$object = new class($this->snapshotable)
|
$object = new class($this->snapshotable)
|
||||||
{
|
{
|
||||||
public function __construct(protected string $snapshotable)
|
public function __construct(protected string $snapshotable) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
@ -61,9 +59,7 @@ test('pass with `toString`', function () {
|
|||||||
|
|
||||||
$object = new class($this->snapshotable)
|
$object = new class($this->snapshotable)
|
||||||
{
|
{
|
||||||
public function __construct(protected string $snapshotable)
|
public function __construct(protected string $snapshotable) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toString()
|
public function toString()
|
||||||
{
|
{
|
||||||
@ -97,9 +93,7 @@ test('pass with `toArray`', function () {
|
|||||||
|
|
||||||
$object = new class($this->snapshotable)
|
$object = new class($this->snapshotable)
|
||||||
{
|
{
|
||||||
public function __construct(protected string $snapshotable)
|
public function __construct(protected string $snapshotable) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
@ -125,9 +119,7 @@ test('pass with `toSnapshot`', function () {
|
|||||||
|
|
||||||
$object = new class($this->snapshotable)
|
$object = new class($this->snapshotable)
|
||||||
{
|
{
|
||||||
public function __construct(protected string $snapshotable)
|
public function __construct(protected string $snapshotable) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toSnapshot()
|
public function toSnapshot()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,60 +2,52 @@
|
|||||||
|
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
class CustomException extends Exception
|
class CustomException extends Exception {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
test('passes', function () {
|
test('passes', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException;
|
||||||
})->toThrow(RuntimeException::class);
|
})->toThrow(RuntimeException::class);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException;
|
||||||
})->toThrow(Exception::class);
|
})->toThrow(Exception::class);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException;
|
||||||
})->toThrow(function (RuntimeException $e) {
|
})->toThrow(function (RuntimeException $e) {});
|
||||||
});
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException('actual message');
|
throw new RuntimeException('actual message');
|
||||||
})->toThrow(function (Exception $e) {
|
})->toThrow(function (Exception $e) {
|
||||||
expect($e->getMessage())->toBe('actual message');
|
expect($e->getMessage())->toBe('actual message');
|
||||||
});
|
});
|
||||||
expect(function () {
|
expect(function () {})->not->toThrow(Exception::class);
|
||||||
})->not->toThrow(Exception::class);
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException('actual message');
|
throw new RuntimeException('actual message');
|
||||||
})->toThrow('actual message');
|
})->toThrow('actual message');
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new Exception();
|
throw new Exception;
|
||||||
})->not->toThrow(RuntimeException::class);
|
})->not->toThrow(RuntimeException::class);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException('actual message');
|
throw new RuntimeException('actual message');
|
||||||
})->toThrow(RuntimeException::class, 'actual message');
|
})->toThrow(RuntimeException::class, 'actual message');
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException('actual message');
|
throw new RuntimeException('actual message');
|
||||||
})->toThrow(function (RuntimeException $e) {
|
})->toThrow(function (RuntimeException $e) {}, 'actual message');
|
||||||
}, 'actual message');
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new CustomException('foo');
|
throw new CustomException('foo');
|
||||||
})->toThrow(new CustomException('foo'));
|
})->toThrow(new CustomException('foo'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures 1', function () {
|
test('failures 1', function () {
|
||||||
expect(function () {
|
expect(function () {})->toThrow(RuntimeException::class);
|
||||||
})->toThrow(RuntimeException::class);
|
|
||||||
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
|
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
|
||||||
|
|
||||||
test('failures 2', function () {
|
test('failures 2', function () {
|
||||||
expect(function () {
|
expect(function () {})->toThrow(function (RuntimeException $e) {});
|
||||||
})->toThrow(function (RuntimeException $e) {
|
|
||||||
});
|
|
||||||
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
|
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
|
||||||
|
|
||||||
test('failures 3', function () {
|
test('failures 3', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new Exception();
|
throw new Exception;
|
||||||
})->toThrow(function (RuntimeException $e) {
|
})->toThrow(function (RuntimeException $e) {
|
||||||
//
|
//
|
||||||
});
|
});
|
||||||
@ -77,8 +69,7 @@ test('failures 5', function () {
|
|||||||
})->throws(ExpectationFailedException::class, 'Failed asserting that \'actual message\' [ASCII](length: 14) contains "expected message" [ASCII](length: 16).');
|
})->throws(ExpectationFailedException::class, 'Failed asserting that \'actual message\' [ASCII](length: 14) contains "expected message" [ASCII](length: 16).');
|
||||||
|
|
||||||
test('failures 6', function () {
|
test('failures 6', function () {
|
||||||
expect(function () {
|
expect(function () {})->toThrow('actual message');
|
||||||
})->toThrow('actual message');
|
|
||||||
})->throws(ExpectationFailedException::class, 'Exception with message "actual message" not thrown');
|
})->throws(ExpectationFailedException::class, 'Exception with message "actual message" not thrown');
|
||||||
|
|
||||||
test('failures 7', function () {
|
test('failures 7', function () {
|
||||||
@ -101,34 +92,30 @@ test('failures with custom message', function () {
|
|||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException;
|
||||||
})->not->toThrow(RuntimeException::class);
|
})->not->toThrow(RuntimeException::class);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('closure missing parameter', function () {
|
test('closure missing parameter', function () {
|
||||||
expect(function () {
|
expect(function () {})->toThrow(function () {});
|
||||||
})->toThrow(function () {
|
|
||||||
});
|
|
||||||
})->throws(InvalidArgumentException::class, 'The given closure must have a single parameter type-hinted as the class string.');
|
})->throws(InvalidArgumentException::class, 'The given closure must have a single parameter type-hinted as the class string.');
|
||||||
|
|
||||||
test('closure missing type-hint', function () {
|
test('closure missing type-hint', function () {
|
||||||
expect(function () {
|
expect(function () {})->toThrow(function ($e) {});
|
||||||
})->toThrow(function ($e) {
|
|
||||||
});
|
|
||||||
})->throws(InvalidArgumentException::class, 'The given closure\'s parameter must be type-hinted as the class string.');
|
})->throws(InvalidArgumentException::class, 'The given closure\'s parameter must be type-hinted as the class string.');
|
||||||
|
|
||||||
it('can handle a non-defined exception', function () {
|
it('can handle a non-defined exception', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new NonExistingException();
|
throw new NonExistingException;
|
||||||
})->toThrow(NonExistingException::class);
|
})->toThrow(NonExistingException::class);
|
||||||
})->throws(Error::class, 'Class "NonExistingException" not found');
|
})->throws(Error::class, 'Class "NonExistingException" not found');
|
||||||
|
|
||||||
it('can handle a class not found Error', function () {
|
it('can handle a class not found Error', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new NonExistingException();
|
throw new NonExistingException;
|
||||||
})->toThrow('Class "NonExistingException" not found');
|
})->toThrow('Class "NonExistingException" not found');
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new NonExistingException();
|
throw new NonExistingException;
|
||||||
})->toThrow(Error::class, 'Class "NonExistingException" not found');
|
})->toThrow(Error::class, 'Class "NonExistingException" not found');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->unlessObject = new stdClass();
|
$this->unlessObject = new stdClass;
|
||||||
$this->unlessObject->trueValue = true;
|
$this->unlessObject->trueValue = true;
|
||||||
$this->unlessObject->foo = 'foo';
|
$this->unlessObject->foo = 'foo';
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->whenObject = new stdClass();
|
$this->whenObject = new stdClass;
|
||||||
$this->whenObject->trueValue = true;
|
$this->whenObject->trueValue = true;
|
||||||
$this->whenObject->foo = 'foo';
|
$this->whenObject->foo = 'foo';
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ dataset('numbers.array', [
|
|||||||
1, 2, 3, 4, 5, 'ScopedDatasets/ScopedDatasets.php',
|
1, 2, 3, 4, 5, 'ScopedDatasets/ScopedDatasets.php',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use function PHPUnit\Framework\assertFalse;
|
use function PHPUnit\Framework\assertFalse;
|
||||||
|
|
||||||
$foo = new stdClass();
|
$foo = new stdClass;
|
||||||
$foo->beforeAll = false;
|
$foo->beforeAll = false;
|
||||||
$foo->beforeEach = false;
|
$foo->beforeEach = false;
|
||||||
$foo->afterEach = false;
|
$foo->afterEach = false;
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsInvokable;
|
|||||||
|
|
||||||
class InvokableClass
|
class InvokableClass
|
||||||
{
|
{
|
||||||
public function __invoke(): void
|
public function __invoke(): void {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsInvokable;
|
|||||||
|
|
||||||
class ParentInvokableClass
|
class ParentInvokableClass
|
||||||
{
|
{
|
||||||
public function __invoke(): void
|
public function __invoke(): void {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsNotInvokable;
|
|||||||
|
|
||||||
class IsNotInvokableClass
|
class IsNotInvokableClass
|
||||||
{
|
{
|
||||||
public function handle(): void
|
public function handle(): void {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,4 @@ namespace Tests\Fixtures\Arch\ToHaveAttribute\Attributes;
|
|||||||
use Attribute;
|
use Attribute;
|
||||||
|
|
||||||
#[Attribute()]
|
#[Attribute()]
|
||||||
class AsAttribute
|
class AsAttribute {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -7,6 +7,4 @@ namespace Tests\Fixtures\Arch\ToHaveAttribute\HaveAttribute;
|
|||||||
use Tests\Fixtures\Arch\ToHaveAttribute\Attributes\AsAttribute;
|
use Tests\Fixtures\Arch\ToHaveAttribute\Attributes\AsAttribute;
|
||||||
|
|
||||||
#[AsAttribute]
|
#[AsAttribute]
|
||||||
class HaveAttributeClass
|
class HaveAttributeClass {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Arch\ToHaveAttribute\NotHaveAttribute;
|
namespace Tests\Fixtures\Arch\ToHaveAttribute\NotHaveAttribute;
|
||||||
|
|
||||||
class NotHaveAttributeClass
|
class NotHaveAttributeClass {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveConstructor\HasConstructor;
|
|||||||
|
|
||||||
class HasConstructor
|
class HasConstructor
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Arch\ToHaveConstructor\HasNoConstructor;
|
namespace Tests\Fixtures\Arch\ToHaveConstructor\HasNoConstructor;
|
||||||
|
|
||||||
class HasNoConstructor
|
class HasNoConstructor {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveDestructor\HasDestructor;
|
|||||||
|
|
||||||
class HasDestructor
|
class HasDestructor
|
||||||
{
|
{
|
||||||
public function __destruct()
|
public function __destruct() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Arch\ToHaveDestructor\HasNoDestructor;
|
namespace Tests\Fixtures\Arch\ToHaveDestructor\HasNoDestructor;
|
||||||
|
|
||||||
class HasNoDestructor
|
class HasNoDestructor {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasMethod;
|
|||||||
|
|
||||||
class HasMethod
|
class HasMethod
|
||||||
{
|
{
|
||||||
public function foo(): void
|
public function foo(): void {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasMethod;
|
|||||||
|
|
||||||
trait HasMethodTrait
|
trait HasMethodTrait
|
||||||
{
|
{
|
||||||
public function foo(): void
|
public function foo(): void {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasMethod;
|
|||||||
|
|
||||||
class ParentHasMethodClass
|
class ParentHasMethodClass
|
||||||
{
|
{
|
||||||
public function foo(): void
|
public function foo(): void {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasNoMethod;
|
|||||||
|
|
||||||
class HasNoMethodClass
|
class HasNoMethodClass
|
||||||
{
|
{
|
||||||
public function bar(): void
|
public function bar(): void {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Arch\ToHavePrefix\HasNoPrefix;
|
namespace Tests\Fixtures\Arch\ToHavePrefix\HasNoPrefix;
|
||||||
|
|
||||||
class ClassWithout
|
class ClassWithout {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Arch\ToHavePrefix\HasPrefix;
|
namespace Tests\Fixtures\Arch\ToHavePrefix\HasPrefix;
|
||||||
|
|
||||||
class PrefixClassWith
|
class PrefixClassWith {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Arch\ToHaveSuffix\HasNoSuffix;
|
namespace Tests\Fixtures\Arch\ToHaveSuffix\HasNoSuffix;
|
||||||
|
|
||||||
class ClassWithout
|
class ClassWithout {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4,6 +4,4 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Arch\ToHaveSuffix\HasSuffix;
|
namespace Tests\Fixtures\Arch\ToHaveSuffix\HasSuffix;
|
||||||
|
|
||||||
class ClassWithSuffix
|
class ClassWithSuffix {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4,7 +4,5 @@ namespace Tests\Fixtures\Covers;
|
|||||||
|
|
||||||
class CoversClass1
|
class CoversClass1
|
||||||
{
|
{
|
||||||
public function foo()
|
public function foo() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Covers;
|
namespace Tests\Fixtures\Covers;
|
||||||
|
|
||||||
class CoversClass2
|
class CoversClass2 {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Covers;
|
namespace Tests\Fixtures\Covers;
|
||||||
|
|
||||||
class CoversClass3
|
class CoversClass3 {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,6 +2,4 @@
|
|||||||
|
|
||||||
namespace Tests\Fixtures\Covers;
|
namespace Tests\Fixtures\Covers;
|
||||||
|
|
||||||
trait CoversTrait
|
trait CoversTrait {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use Pest\Console\Help;
|
|||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
|
|
||||||
it('outputs the help information when --help is used', function () {
|
it('outputs the help information when --help is used', function () {
|
||||||
$output = new BufferedOutput();
|
$output = new BufferedOutput;
|
||||||
$plugin = new Help($output);
|
$plugin = new Help($output);
|
||||||
|
|
||||||
$plugin();
|
$plugin();
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user