Compare commits

...

53 Commits

Author SHA1 Message Date
f8c88bd14d chore: requires latest versions of collision and termwind 2024-10-15 16:30:56 +01:00
d454a36a48 removes non reported error 2024-10-15 15:34:49 +01:00
61b6b8c7d9 release: v2.36.0 2024-10-15 15:31:46 +01:00
e8aaa586cb feat: php 8.4 support 2024-10-15 15:31:29 +01:00
9ceb0834ae chore: updates snapshots 2024-08-22 21:07:39 +01:00
86d2191cae chore: refactor TestClosureMustNotBeStatic 2024-08-22 20:59:42 +01:00
748beb17d5 chore: adjusts memory limit 2024-08-22 20:59:42 +01:00
7ba235f61a Merge pull request #1129 from tomb1n0/bugfix/alwaysCallTeardownRegardlessOfExceptions
[Bug] Always call parent teardown even if an exception is thrown
2024-08-22 20:50:59 +01:00
700bd517f4 Merge pull request #1117 from peterfox/bug/catch-static-closures
[Bug] provided explaination for static closures
2024-08-22 20:33:58 +01:00
cbcfa2c5e2 Merge pull request #1100 from faissaloux/fix-use-strict-types
Fix `toUseStrictTypes`
2024-08-22 20:32:21 +01:00
243e45a551 Merge pull request #1097 from arifszn/2.x
[2.x] Modify `Result::exitCode` logic to address warning handling with `--fail-on-warning`
2024-08-22 20:31:34 +01:00
823c3d4b17 chore: updates snapshots 2024-08-20 22:49:23 +01:00
39c9b15bc0 Update visual_snapshot_of_help_command_output.snap 2024-08-20 22:44:39 +01:00
b13acb630d release: 2.35.1 2024-08-20 22:41:50 +01:00
172d94c0ca chore: bumps depedencies 2024-08-20 22:41:07 +01:00
0697555dc2 chore: adjusts sponsors 2024-08-05 10:42:52 +01:00
d0ff2c8ec2 release: 2.35.0 2024-08-02 11:57:29 +01:00
5e41e546a0 chore: style changes 2024-08-02 11:53:24 +01:00
6a8a4f3243 Merge pull request #1194 from dmason30/patch-1
Include method name in toHaveMethod error message
2024-07-20 18:29:37 +01:00
ef29b4f091 Include method name in toHaveMethod error message 2024-07-19 15:30:43 +01:00
ef120125e0 release: 2.34.9 2024-07-11 09:36:26 +01:00
8a9a416133 chore: bumps dependencies 2024-07-11 09:35:43 +01:00
4783334f15 chore: style 2024-07-11 09:35:38 +01:00
e8f122bf47 release: 2.34.8 2024-06-10 23:02:16 +01:00
9fc607a2b8 Fixes wrong stub 2024-06-10 22:52:21 +01:00
b33af71036 Merge pull request #1157 from ExeQue/2.x
[2.x] Added `toBeList` expectation
2024-05-27 13:08:05 +01:00
3c6c89a6ad Added test to toBeList 2024-05-21 08:15:32 +02:00
55f6b5696e Added toBeList expectation 2024-05-21 08:13:20 +02:00
303f4c0113 Adds sponsor 2024-04-19 20:47:46 +01:00
35a1fcd0cf chore: updates readme 2024-04-08 12:28:43 +01:00
adb2fb51df Always call parent teardown even if an exception is thrown 2024-04-08 10:03:55 +01:00
a7a3e4240e release: v2.34.7 2024-04-05 08:44:17 +01:00
e4af33867b chore: bumps dependencies 2024-04-05 08:44:07 +01:00
680111fb1e release: v2.34.6 2024-03-28 11:36:46 +00:00
aa6ff95ea4 chore: bumps dependencies 2024-03-28 11:36:36 +00:00
863a0cc837 release: v2.34.5 2024-03-22 08:44:19 +00:00
126a84a63e chore: bumps dependencies 2024-03-22 08:44:13 +00:00
0ccbe5c8f0 Remove Laravel serialisable closure 2024-03-17 17:23:17 +00:00
a4f8ae1a12 Handles tests where a static closure is provided 2024-03-17 16:48:43 +00:00
6094682158 Add static closure check 2024-03-17 12:04:38 +00:00
d519e40b95 chore: adjusts workflow 2024-03-15 21:14:22 +00:00
6a1161ead8 release: v2.34.4 2024-03-14 19:44:18 +00:00
a1b3547dd6 chore: fixes paratest version 2024-03-14 19:42:03 +00:00
b9e3146a47 release: v2.34.3 2024-03-14 19:40:23 +00:00
ce1607cba9 chore: bumps phpunit 2024-03-14 19:40:16 +00:00
ac07bc1770 chore: override changes 2024-03-14 19:40:03 +00:00
521a41dd10 fix: no duplicate --no-output 2024-03-14 19:39:45 +00:00
1b68b340e8 chore: fixes static analysis 2024-03-14 19:39:31 +00:00
853f6efce6 release: v2.34.2 2024-03-11 18:05:47 +00:00
62a9a78ee2 chore: bumps dependencies 2024-03-11 18:05:37 +00:00
2c3234fb3d fix bool type 2024-02-21 17:09:16 +01:00
1b64fef7ba fix toUseStrictTypes 2024-02-21 16:58:40 +01:00
a136231503 fix: modify Result::exitCode logic to address warning handling with --fail-on-warning 2024-02-20 18:24:37 +06:00
119 changed files with 353 additions and 455 deletions

View File

@ -3,8 +3,6 @@ name: Tests
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
tests:
@ -16,7 +14,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
symfony: ['6.4', '7.0']
php: ['8.1', '8.2', '8.3']
php: ['8.1', '8.2', '8.3', '8.4']
dependency_version: [prefer-lowest, prefer-stable]
exclude:
- php: '8.1'

View File

@ -21,6 +21,8 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
### Platinum Sponsors
- **[LaraJobs](https://larajobs.com)**
- **[Brokerchooser](https://brokerchooser.com)**
- **[Forge](https://forge.laravel.com)**
- **[Spatie](https://spatie.be)**
- **[Worksome](https://www.worksome.com/)**
@ -29,10 +31,10 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
- [Akaunting](https://akaunting.com/?ref=pestphp)
- [Codecourse](https://codecourse.com/?ref=pestphp)
- [DocuWriter.ai](https://www.docuwriter.ai/?ref=pestphp)
- [Laracasts](https://laracasts.com/?ref=pestphp)
- [Laradir](https://laradir.com/?ref=pestphp)
- [Localazy](https://localazy.com/?ref=pestphp)
- [Stormlikes](https://www.stormlikes.net/?ref=pestphp)
- [Route4Me](https://www.route4me.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)**.

View File

@ -12,7 +12,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
$bootPest = (static function (): void {
$workerArgv = new ArgvInput();
$workerArgv = new ArgvInput;
$rootPath = dirname(PHPUNIT_COMPOSER_INSTALL, 2);
$testSuite = TestSuite::getInstance($rootPath, $workerArgv->getParameterOption(
@ -20,7 +20,7 @@ $bootPest = (static function (): void {
'tests'
));
$input = new ArgvInput();
$input = new ArgvInput;
$output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true);

View File

@ -19,14 +19,15 @@
"require": {
"php": "^8.1.0",
"brianium/paratest": "^7.3.1",
"nunomaduro/collision": "^7.10.0|^8.1.0",
"nunomaduro/termwind": "^1.15.1|^2.0.0",
"nunomaduro/collision": "^7.11.0|^8.4.0",
"nunomaduro/termwind": "^1.16.0|^2.1.0",
"pestphp/pest-plugin": "^2.1.1",
"pestphp/pest-plugin-arch": "^2.7.0",
"phpunit/phpunit": "^10.5.11"
"phpunit/phpunit": "^10.5.36"
},
"conflict": {
"phpunit/phpunit": ">10.5.11",
"filp/whoops": "<2.16.0",
"phpunit/phpunit": ">10.5.36",
"sebastian/exporter": "<5.1.0",
"webmozart/assert": "<1.11.0"
},
@ -51,9 +52,9 @@
]
},
"require-dev": {
"pestphp/pest-dev-tools": "^2.16.0",
"pestphp/pest-plugin-type-coverage": "^2.8.0",
"symfony/process": "^6.4.0|^7.0.4"
"pestphp/pest-dev-tools": "^2.17.0",
"pestphp/pest-plugin-type-coverage": "^2.8.7",
"symfony/process": "^6.4.0|^7.1.5"
},
"minimum-stability": "dev",
"prefer-stable": true,
@ -73,7 +74,7 @@
"test:refacto": "rector --dry-run",
"test:lint": "pint --test",
"test:type:check": "phpstan analyse --ansi --memory-limit=-1 --debug",
"test:type:coverage": "php bin/pest --type-coverage --min=100",
"test:type:coverage": "php -d memory_limit=-1 bin/pest --type-coverage --min=100",
"test:unit": "php bin/pest --colors=always --exclude-group=integration --compact",
"test:inline": "php bin/pest --colors=always --configuration=phpunit.inline.xml",
"test:parallel": "php bin/pest --colors=always --exclude-group=integration --parallel --processes=3",

View File

@ -59,7 +59,6 @@ use function file_get_contents;
use function file_put_contents;
use function is_array;
use function is_dir;
use function is_file;
use function json_decode;
use function json_encode;
use function Pest\version;
@ -129,13 +128,15 @@ final class DefaultResultCache implements ResultCache
public function load(): void
{
if (! is_file($this->cacheFilename)) {
$contents = @file_get_contents($this->cacheFilename);
if ($contents === false) {
return;
}
$data = json_decode(
file_get_contents($this->cacheFilename),
true
$contents,
true,
);
if ($data === null) {

View File

@ -59,19 +59,14 @@ use function array_map;
*/
final class TestSuiteFilterProcessor
{
private Factory $filterFactory;
public function __construct(Factory $factory = new Factory)
{
$this->filterFactory = $factory;
}
/**
* @throws Event\RuntimeException
* @throws FilterNotConfiguredException
*/
public function process(Configuration $configuration, TestSuite $suite): void
{
$factory = new Factory;
if (! $configuration->hasFilter() &&
! $configuration->hasGroups() &&
! $configuration->hasExcludeGroups() &&
@ -83,21 +78,21 @@ final class TestSuiteFilterProcessor
}
if ($configuration->hasExcludeGroups()) {
$this->filterFactory->addExcludeGroupFilter(
$factory->addExcludeGroupFilter(
$configuration->excludeGroups()
);
}
if (Only::isEnabled()) {
$this->filterFactory->addIncludeGroupFilter(['__pest_only']);
$factory->addIncludeGroupFilter(['__pest_only']);
} elseif ($configuration->hasGroups()) {
$this->filterFactory->addIncludeGroupFilter(
$factory->addIncludeGroupFilter(
$configuration->groups()
);
}
if ($configuration->hasTestsCovering()) {
$this->filterFactory->addIncludeGroupFilter(
$factory->addIncludeGroupFilter(
array_map(
static fn (string $name): string => '__phpunit_covers_'.$name,
$configuration->testsCovering()
@ -106,7 +101,7 @@ final class TestSuiteFilterProcessor
}
if ($configuration->hasTestsUsing()) {
$this->filterFactory->addIncludeGroupFilter(
$factory->addIncludeGroupFilter(
array_map(
static fn (string $name): string => '__phpunit_uses_'.$name,
$configuration->testsUsing()
@ -115,12 +110,12 @@ final class TestSuiteFilterProcessor
}
if ($configuration->hasFilter()) {
$this->filterFactory->addNameFilter(
$factory->addNameFilter(
$configuration->filter()
);
}
$suite->injectFilter($this->filterFactory);
$suite->injectFilter($factory);
Event\Facade::emitter()->testSuiteFiltered(
Event\TestSuite\TestSuiteBuilder::from($suite)

View File

@ -1,6 +1,5 @@
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/ergebnis/phpstan-rules/rules.neon
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
parameters:
@ -12,12 +11,4 @@ parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- "#has a nullable return type declaration.#"
- "#Language construct isset\\(\\) should not be used.#"
- "#is not allowed to extend#"
- "#is concrete, but does not have a Test suffix#"
- "#with a nullable type declaration#"
- "#type mixed is not subtype of native#"
- "# with null as default value#"
- "#has parameter \\$closure with default value.#"
- "#has parameter \\$description with default value.#"

View File

@ -19,11 +19,11 @@ final class BootOverrides implements Bootstrapper
*/
public const FILES = [
'c7b9c8a96006dea314204a8f09a8764e51ce0b9b79aadd58da52e8c328db4870' => 'Runner/Filter/NameFilterIterator.php',
'52b2574e96269aca1bb2d41bbf418c3bcf23dd21d14c66f90789025c309e39df' => 'Runner/ResultCache/DefaultResultCache.php',
'c7c09ab7c9378710b27f761a4b2948196cbbdf2a73e4389bcdca1e7c94fa9c21' => 'Runner/ResultCache/DefaultResultCache.php',
'bc8718c89264f65800beabc23e51c6d3bcff87dfc764a12179ef5dbfde272c8b' => 'Runner/TestSuiteLoader.php',
'f41e48d6cb546772a7de4f8e66b6b7ce894a5318d063eb52e354d206e96c701c' => 'TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php',
'cb7519f2d82893640b694492cf7ec9528da80773cc1d259634181b5d393528b5' => 'TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php',
'6db25ee539e9b12b1fb4e044a0a93410e015bc983ecdd3909cd394fe44ae8c95' => 'TextUI/TestSuiteFilterProcessor.php',
'2f06e4b1a9f3a24145bfc7ea25df4f124117f940a2cde30a04d04d5678006bff' => 'TextUI/TestSuiteFilterProcessor.php',
'ef64a657ed9c0067791483784944107827bf227c7e3200f212b6751876b99e25' => 'Event/Value/ThrowableBuilder.php',
'c78f96e34b98ed01dd8106539d59b8aa8d67f733274118b827c01c5c4111c033' => 'Logging/JUnit/JunitXmlLogger.php',
];

View File

@ -32,8 +32,7 @@ final class BootSubscribers implements Bootstrapper
*/
public function __construct(
private readonly Container $container,
) {
}
) {}
/**
* Boots the list of Subscribers.

View File

@ -234,11 +234,13 @@ trait Testable
$afterEach = ChainableClosure::bound($this->__afterEach, $afterEach);
}
$this->__callClosure($afterEach, func_get_args());
try {
$this->__callClosure($afterEach, func_get_args());
} finally {
parent::tearDown();
parent::tearDown();
TestSuite::getInstance()->test = null;
TestSuite::getInstance()->test = null;
}
}
/**

View File

@ -50,7 +50,7 @@ final class Thanks
$wantsToSupport = false;
if (getenv('PEST_NO_SUPPORT') !== 'true' && $this->input->isInteractive()) {
$wantsToSupport = (new SymfonyQuestionHelper())->ask(
$wantsToSupport = (new SymfonyQuestionHelper)->ask(
new ArrayInput([]),
$this->output,
new ConfirmationQuestion(

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Pest\Exceptions;
use InvalidArgumentException;
use NunoMaduro\Collision\Contracts\RenderlessEditor;
use NunoMaduro\Collision\Contracts\RenderlessTrace;
use Pest\Factories\TestCaseMethodFactory;
use Symfony\Component\Console\Exception\ExceptionInterface;
/**
* @internal
*/
final class TestClosureMustNotBeStatic extends InvalidArgumentException implements ExceptionInterface, RenderlessEditor, RenderlessTrace
{
/**
* Creates a new Exception instance.
*/
public function __construct(TestCaseMethodFactory $method)
{
parent::__construct(
sprintf(
'Test closure must not be static. Please remove the `static` keyword from the `%s` method in `%s`.',
$method->description,
$method->filename
)
);
}
}

View File

@ -421,7 +421,7 @@ final class Expectation
*/
public function any(): Any
{
return new Any();
return new Any;
}
/**
@ -441,7 +441,7 @@ final class Expectation
{
return Targeted::make(
$this,
fn (ObjectDescription $object): bool => str_contains((string) file_get_contents($object->path), 'declare(strict_types=1);'),
fn (ObjectDescription $object): bool => (bool) preg_match('/^<\?php\s+declare\(.*?strict_types\s?=\s?1.*?\);/', (string) file_get_contents($object->path)),
'to use strict types',
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
);
@ -515,7 +515,7 @@ final class Expectation
return Targeted::make(
$this,
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')),
);
}

View File

@ -24,9 +24,7 @@ final class EachExpectation
*
* @param Expectation<TValue> $original
*/
public function __construct(private readonly Expectation $original)
{
}
public function __construct(private readonly Expectation $original) {}
/**
* Creates a new expectation.

View File

@ -36,9 +36,7 @@ final class OppositeExpectation
*
* @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.
@ -84,7 +82,7 @@ final class OppositeExpectation
{
return Targeted::make(
$this->original,
fn (ObjectDescription $object): bool => ! str_contains((string) file_get_contents($object->path), 'declare(strict_types=1);'),
fn (ObjectDescription $object): bool => ! (bool) preg_match('/^<\?php\s+declare\(.*?strict_types\s?=\s?1.*?\);/', (string) file_get_contents($object->path)),
'not to use strict types',
FileLineFinder::where(fn (string $line): bool => str_contains($line, '<?php')),
);

View File

@ -20,7 +20,7 @@ abstract class Attribute
* @param array<int, string> $attributes
* @return array<int, string>
*/
public function __invoke(TestCaseMethodFactory $method, array $attributes): array // @phpstan-ignore-line
public function __invoke(TestCaseMethodFactory $method, array $attributes): array
{
return $attributes;
}

View File

@ -28,8 +28,8 @@ trait HigherOrderable
*/
private function bootHigherOrderable(): void
{
$this->chains = new HigherOrderMessageCollection();
$this->factoryProxies = new HigherOrderMessageCollection();
$this->proxies = new HigherOrderMessageCollection();
$this->chains = new HigherOrderMessageCollection;
$this->factoryProxies = new HigherOrderMessageCollection;
$this->proxies = new HigherOrderMessageCollection;
}
}

View File

@ -9,7 +9,5 @@ namespace Pest\Factories\Covers;
*/
final class CoversClass
{
public function __construct(public string $class)
{
}
public function __construct(public string $class) {}
}

View File

@ -9,7 +9,5 @@ namespace Pest\Factories\Covers;
*/
final class CoversFunction
{
public function __construct(public string $function)
{
}
public function __construct(public string $function) {}
}

View File

@ -7,6 +7,4 @@ namespace Pest\Factories\Covers;
/**
* @internal
*/
final class CoversNothing
{
}
final class CoversNothing {}

View File

@ -11,6 +11,7 @@ use Pest\Contracts\HasPrintableTestCaseName;
use Pest\Exceptions\DatasetMissing;
use Pest\Exceptions\ShouldNotHappen;
use Pest\Exceptions\TestAlreadyExist;
use Pest\Exceptions\TestClosureMustNotBeStatic;
use Pest\Exceptions\TestDescriptionMissing;
use Pest\Factories\Concerns\HigherOrderable;
use Pest\Support\Reflection;
@ -154,7 +155,7 @@ final class TestCaseFactory
foreach ($classAvailableAttributes as $attribute) {
$classAttributes = array_reduce(
$methods,
fn (array $carry, TestCaseMethodFactory $methodFactory): array => (new $attribute())->__invoke($methodFactory, $carry),
fn (array $carry, TestCaseMethodFactory $methodFactory): array => (new $attribute)->__invoke($methodFactory, $carry),
$classAttributes
);
}
@ -193,7 +194,7 @@ final class TestCaseFactory
}
PHP;
eval($classCode); // @phpstan-ignore-line
eval($classCode);
} catch (ParseError $caught) {
throw new RuntimeException(sprintf(
"Unable to create test case for test file at %s. \n %s",
@ -216,6 +217,14 @@ final class TestCaseFactory
throw new TestAlreadyExist($method->filename, $method->description);
}
if (
$method->closure instanceof \Closure &&
(new \ReflectionFunction($method->closure))->isStatic()
) {
throw new TestClosureMustNotBeStatic($method);
}
if (! $method->receivesArguments()) {
if (! $method->closure instanceof \Closure) {
throw ShouldNotHappen::fromMessage('The test closure may not be empty.');

View File

@ -138,11 +138,11 @@ final class TestCaseMethodFactory
$attributes = [];
foreach ($annotationsToUse as $annotation) {
$annotations = (new $annotation())->__invoke($this, $annotations);
$annotations = (new $annotation)->__invoke($this, $annotations);
}
foreach ($attributesToUse as $attribute) {
$attributes = (new $attribute())->__invoke($this, $attributes);
$attributes = (new $attribute)->__invoke($this, $attributes);
}
if ($this->datasets !== [] || $this->repetitions > 1) {

View File

@ -67,7 +67,7 @@ final class Kernel
->add(Container::class, $container);
$kernel = new self(
new Application(),
new Application,
$output,
);

View File

@ -40,7 +40,7 @@ final class KernelDump
*/
public function disable(): void
{
@ob_clean(); // @phpstan-ignore-line
@ob_clean();
if ($this->buffer !== '') {
$this->flush();

View File

@ -36,7 +36,7 @@ final class Converter
public function __construct(
private readonly string $rootPath,
) {
$this->stateGenerator = new StateGenerator();
$this->stateGenerator = new StateGenerator;
}
/**

View File

@ -17,8 +17,7 @@ final class ServiceMessage
public function __construct(
private readonly string $type,
private readonly array $parameters,
) {
}
) {}
public function toString(): string
{

View File

@ -14,9 +14,7 @@ abstract class Subscriber
/**
* Creates a new Subscriber instance.
*/
public function __construct(private readonly TeamCityLogger $logger)
{
}
public function __construct(private readonly TeamCityLogger $logger) {}
/**
* Creates a new TeamCityLogger instance.

View File

@ -7,6 +7,4 @@ namespace Pest\Matchers;
/**
* @internal
*/
final class Any
{
}
final class Any {}

View File

@ -314,7 +314,7 @@ final class Expectation
*
* @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();
@ -467,6 +467,18 @@ final class Expectation
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.
*
@ -642,7 +654,7 @@ final class Expectation
*
* @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')) {
$array = $this->value->toArray();

View File

@ -42,7 +42,7 @@ final class Panic
try {
$output = Container::getInstance()->get(OutputInterface::class);
} catch (Throwable) { // @phpstan-ignore-line
$output = new ConsoleOutput();
$output = new ConsoleOutput;
}
assert($output instanceof OutputInterface);

View File

@ -39,7 +39,7 @@ final class AfterEachCall
) {
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
$this->proxies = new HigherOrderMessageCollection();
$this->proxies = new HigherOrderMessageCollection;
$this->describing = DescribeCall::describing();
}

View File

@ -44,8 +44,8 @@ final class BeforeEachCall
) {
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
$this->testCallProxies = new HigherOrderMessageCollection();
$this->testCaseProxies = new HigherOrderMessageCollection();
$this->testCallProxies = new HigherOrderMessageCollection;
$this->testCaseProxies = new HigherOrderMessageCollection;
$this->describing = DescribeCall::describing();
}

View File

@ -369,7 +369,7 @@ final class TestCall
*/
public function coversNothing(): self
{
$this->testCaseMethod->covers = [new CoversNothing()];
$this->testCaseMethod->covers = [new CoversNothing];
return $this;
}

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string
{
return '2.34.1';
return '2.36.0';
}
function testDirectory(string $file = ''): string

View File

@ -97,7 +97,7 @@ final class Help implements HandlesArguments
*/
private function getContent(): array
{
$helpReflection = new PHPUnitHelp();
$helpReflection = new PHPUnitHelp;
$content = (fn (): array => $this->elements())->call($helpReflection);

View File

@ -41,7 +41,7 @@ final class Parallel implements HandlesArguments
*/
public static function isEnabled(): bool
{
$argv = new ArgvInput();
$argv = new ArgvInput;
if ($argv->hasParameterOption('--parallel')) {
return true;
}
@ -126,7 +126,7 @@ final class Parallel implements HandlesArguments
$arguments
);
$exitCode = $this->paratestCommand()->run(new ArgvInput($filteredArguments), new CleanConsoleOutput());
$exitCode = $this->paratestCommand()->run(new ArgvInput($filteredArguments), new CleanConsoleOutput);
return CallsAddsOutput::execute($exitCode);
}
@ -173,7 +173,7 @@ final class Parallel implements HandlesArguments
*/
private function hasArgumentsThatWouldBeFasterWithoutParallel(): bool
{
$arguments = new ArgvInput();
$arguments = new ArgvInput;
foreach (self::UNSUPPORTED_ARGUMENTS as $unsupportedArgument) {
if ($arguments->hasParameterOption($unsupportedArgument)) {

View File

@ -63,8 +63,7 @@ final class ResultPrinter
{
public function __construct(
private readonly OutputInterface $output,
) {
}
) {}
public function print(string $buffer): void
{
@ -79,9 +78,7 @@ final class ResultPrinter
$this->output->write(OutputFormatter::escape($buffer));
}
public function flush(): void
{
}
public function flush(): void {}
};
$this->compactPrinter = CompactPrinter::default();
@ -172,7 +169,7 @@ final class ResultPrinter
return;
}
$state = (new StateGenerator())->fromPhpUnitTestResult($this->passedTests, $testResult);
$state = (new StateGenerator)->fromPhpUnitTestResult($this->passedTests, $testResult);
$this->compactPrinter->errors($state);
$this->compactPrinter->recap($state, $testResult, $duration, $this->options);

View File

@ -91,13 +91,13 @@ final class WrapperRunner implements RunnerInterface
private readonly OutputInterface $output
) {
$this->printer = new ResultPrinter($output, $options);
$this->timer = new Timer();
$this->timer = new Timer;
$wrapper = realpath(
dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'worker.php',
);
assert($wrapper !== false);
$phpFinder = new PhpExecutableFinder();
$phpFinder = new PhpExecutableFinder;
$phpBin = $phpFinder->find(false);
assert($phpBin !== false);
$parameters = [$phpBin];
@ -110,7 +110,7 @@ final class WrapperRunner implements RunnerInterface
$parameters[] = $wrapper;
$this->parameters = $parameters;
$this->codeCoverageFilterRegistry = new CodeCoverageFilterRegistry();
$this->codeCoverageFilterRegistry = new CodeCoverageFilterRegistry;
}
public function run(): int
@ -357,7 +357,7 @@ final class WrapperRunner implements RunnerInterface
return;
}
$coverageManager = new CodeCoverage();
$coverageManager = new CodeCoverage;
$coverageManager->init(
$this->options->configuration,
$this->codeCoverageFilterRegistry,
@ -389,8 +389,8 @@ final class WrapperRunner implements RunnerInterface
return;
}
$testSuite = (new LogMerger())->merge($this->junitFiles);
(new Writer())->write(
$testSuite = (new LogMerger)->merge($this->junitFiles);
(new Writer)->write(
$testSuite,
$this->options->configuration->logfileJunit(),
);

View File

@ -22,6 +22,10 @@ final class Printer implements HandlesArguments
return $arguments;
}
if (in_array('--no-output', $arguments, true)) {
return $arguments;
}
return $this->pushArgument('--no-output', $arguments);
}
}

View File

@ -21,8 +21,7 @@ final class SnapshotRepository
public function __construct(
readonly private string $testsPath,
readonly private string $snapshotsPath,
) {
}
) {}
/**
* Checks if the snapshot exists.

View File

@ -40,9 +40,20 @@ final class Result
*/
public static function exitCode(Configuration $configuration, TestResult $result): int
{
if ($result->wasSuccessfulIgnoringPhpunitWarnings()
&& ! $result->hasTestTriggeredPhpunitWarningEvents()) {
return self::SUCCESS_EXIT;
if ($result->wasSuccessfulIgnoringPhpunitWarnings()) {
if ($configuration->failOnWarning()) {
$warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents()
+ count($result->warnings())
+ count($result->phpWarnings());
if ($warnings > 0) {
return self::FAILURE_EXIT;
}
}
if (! $result->hasTestTriggeredPhpunitWarningEvents()) {
return self::SUCCESS_EXIT;
}
}
if ($configuration->failOnEmptyTestSuite() && ResultReflection::numberOfTests($result) === 0) {
@ -54,14 +65,6 @@ final class Result
$returnCode = self::FAILURE_EXIT;
}
$warnings = $result->numberOfTestsWithTestTriggeredPhpunitWarningEvents()
+ count($result->warnings())
+ count($result->phpWarnings());
if ($configuration->failOnWarning() && $warnings > 0) {
$returnCode = self::FAILURE_EXIT;
}
if ($configuration->failOnIncomplete() && $result->hasTestMarkedIncompleteEvents()) {
$returnCode = self::FAILURE_EXIT;
}

View File

@ -24,8 +24,7 @@ final class EnsureTeamCityEnabled implements ConfiguredSubscriber
private readonly InputInterface $input,
private readonly OutputInterface $output,
private readonly TestSuite $testSuite,
) {
}
) {}
/**
* Runs the subscriber.

View File

@ -26,7 +26,7 @@ final class Container
public static function getInstance(): self
{
if (! self::$instance instanceof \Pest\Support\Container) {
self::$instance = new self();
self::$instance = new self;
}
return self::$instance;

View File

@ -37,7 +37,7 @@ final class Coverage
*/
public static function isAvailable(): bool
{
$runtime = new Runtime();
$runtime = new Runtime;
if (! $runtime->canCollectCodeCoverage()) {
return false;
@ -67,7 +67,7 @@ final class Coverage
*/
public static function usingXdebug(): bool
{
return (new Runtime())->hasXdebug();
return (new Runtime)->hasXdebug();
}
/**

View File

@ -30,8 +30,7 @@ final class ExpectationPipeline
*/
public function __construct(
private readonly Closure $closure
) {
}
) {}
/**
* Creates a new instance of Expectation Pipeline with given closure.

View File

@ -32,7 +32,7 @@ final class Exporter
public static function default(): self
{
return new self(
new BaseExporter()
new BaseExporter
);
}
@ -47,7 +47,7 @@ final class Exporter
$array = $data;
$itemsCount = 0;
$exporter = self::default();
$context ??= new Context();
$context ??= new Context;
$context->add($data);
@ -64,6 +64,8 @@ final class Exporter
continue;
}
assert(is_array($data));
$result[] = $context->contains($data[$key]) !== false
? '*RECURSION*'
: sprintf('[%s]', $this->shortenedRecursiveExport($data[$key], $context));

View File

@ -16,7 +16,6 @@ final class NullClosure
*/
public static function create(): Closure
{
return Closure::fromCallable(function (): void {
});
return Closure::fromCallable(function (): void {});
}
}

View File

@ -20,7 +20,7 @@ final class StateGenerator
{
public function fromPhpUnitTestResult(int $passedTests, PHPUnitTestResult $testResult): State
{
$state = new State();
$state = new State;
foreach ($testResult->testErroredEvents() as $testResultEvent) {
if ($testResultEvent instanceof Errored) {

View File

@ -76,7 +76,7 @@ final class GitDirtyTestCaseFilter implements TestCaseFilter
$dirtyFiles = array_values($dirtyFiles);
if ($dirtyFiles === []) {
Panic::with(new NoDirtyTestsFound());
Panic::with(new NoDirtyTestsFound);
}
$this->changedFiles = $dirtyFiles;

View File

@ -71,11 +71,11 @@ final class TestSuite
string $rootPath,
public string $testPath,
) {
$this->beforeAll = new BeforeAllRepository();
$this->beforeEach = new BeforeEachRepository();
$this->tests = new TestRepository();
$this->afterEach = new AfterEachRepository();
$this->afterAll = new AfterAllRepository();
$this->beforeAll = new BeforeAllRepository;
$this->beforeEach = new BeforeEachRepository;
$this->tests = new TestRepository;
$this->afterEach = new AfterEachRepository;
$this->afterAll = new AfterAllRepository;
$this->rootPath = (string) realpath($rootPath);
$this->snapshots = new SnapshotRepository(
implode(DIRECTORY_SEPARATOR, [$this->rootPath, $this->testPath]),
@ -101,7 +101,7 @@ final class TestSuite
}
if (! self::$instance instanceof self) {
Panic::with(new InvalidPestCommand());
Panic::with(new InvalidPestCommand);
}
return self::$instance;

View File

@ -6,5 +6,5 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
//
}

View File

@ -1,5 +1,5 @@
Pest Testing Framework 2.34.1.
Pest Testing Framework 2.36.0.
USAGE: pest <file> [options]
@ -59,6 +59,7 @@
--fail-on-warning Signal failure using shell exit code when a warning was triggered
--fail-on-risky Signal failure using shell exit code when a test was considered risky
--fail-on-deprecation Signal failure using shell exit code when a deprecation was triggered
--fail-on-phpunit-deprecation Signal failure using shell exit code when a PHPUnit deprecation was triggered
--fail-on-notice Signal failure using shell exit code when a notice was triggered
--fail-on-skipped Signal failure using shell exit code when a test was skipped
--fail-on-incomplete Signal failure using shell exit code when a test was marked incomplete
@ -78,6 +79,7 @@
--display-incomplete .................. Display details for incomplete tests
--display-skipped ........................ Display details for skipped tests
--display-deprecations . Display details for deprecations triggered by tests
--display-phpunit-deprecations .... Display details for PHPUnit deprecations
--display-errors ............. Display details for errors triggered by tests
--display-notices ........... Display details for notices triggered by tests
--display-warnings ......... Display details for warnings triggered by tests
@ -105,6 +107,8 @@
--coverage-html [dir] Write code coverage report in HTML format to directory
--coverage-php [file] .......... Write serialized code coverage data to file
--coverage-text=[file] Write code coverage report in text format to file [default: standard output]
--only-summary-for-coverage-text Option for code coverage report in text format: only show summary
--show-uncovered-for-coverage-text Option for code coverage report in text format: show uncovered files
--coverage-xml [dir] . Write code coverage report in XML format to directory
--warm-coverage-cache ........................... Warm static analysis cache
--coverage-filter [dir] ........... Include [dir] in code coverage reporting

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.34.1.
Pest Testing Framework 2.36.0.

View File

@ -511,6 +511,12 @@
✓ passes with strings
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeList
✓ pass
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeLowercase
@ -1167,16 +1173,6 @@
PASS Tests\Hooks\BeforeEachTest
✓ global beforeEach execution order
PASS Tests\Overrides\VersionsTest
✓ versions with dataset "Runner/Filter/NameFilterIterator.php"
✓ versions with dataset "Runner/ResultCache/DefaultResultCache.php"
✓ versions with dataset "Runner/TestSuiteLoader.php"
✓ versions with dataset "TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php"
✓ versions with dataset "TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php"
✓ versions with dataset "TextUI/TestSuiteFilterProcessor.php"
✓ versions with dataset "Event/Value/ThrowableBuilder.php"
✓ versions with dataset "Logging/JUnit/JunitXmlLogger.php"
PASS Tests\PHPUnit\CustomAffixes\InvalidTestName
✓ it runs file names like @#$%^&()-_=+.php
@ -1281,26 +1277,6 @@
✓ it can resolve builtin value types
✓ it cannot resolve a parameter without type
PASS Tests\Unit\Support\DatasetInfo
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Datase…rs.php', true)
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Datasets.php', false)
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…rs.php', true)
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…rs.php', false)
✓ it can check if dataset is defined inside a Datasets directory with ('/var/www/project/tests/Featur…ts.php', false)
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Datase…rs.php', false)
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Datasets.php', true)
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…rs.php', false) #1
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…rs.php', false) #2
✓ it can check if dataset is defined inside a Datasets.php file with ('/var/www/project/tests/Featur…ts.php', true)
✓ it computes the dataset scope with ('/var/www/project/tests/Datase…rs.php', '/var/www/project/tests')
✓ it computes the dataset scope with ('/var/www/project/tests/Datasets.php', '/var/www/project/tests')
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Features')
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…rs.php') #1
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…ts.php', '/var/www/project/tests/Features')
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…ollers')
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…rs.php') #2
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…ts.php', '/var/www/project/tests/Featur…ollers')
PASS Tests\Unit\Support\ExceptionTrace
✓ it ensures the given closures reports the correct class name
✓ it ensures the given closures reports the correct class name and suggests the [uses()] function
@ -1375,6 +1351,7 @@
PASS Tests\Unit\TestSuite
✓ it does not allow to add the same test description twice
✓ it does not allow static closures
✓ it alerts users about tests with arguments but no input
✓ it can return an array of all test suite filenames
@ -1418,4 +1395,4 @@
WARN Tests\Visual\Version
- 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, 988 passed (2381 assertions)

View File

@ -1,6 +1,6 @@
<?php
$state = new stdClass();
$state = new stdClass;
beforeEach(function () use ($state) {
$this->state = $state;

View File

@ -1,6 +1,6 @@
<?php
$foo = new \stdClass();
$foo = new \stdClass;
$foo->bar = 0;
beforeAll(function () use ($foo) {

View File

@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));
it('adds coverage if --coverage exist', function () {
$plugin = new CoveragePlugin(new ConsoleOutput());
$plugin = new CoveragePlugin(new ConsoleOutput);
expect($plugin->coverage)->toBeFalse();
$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');
it('adds coverage if --min exist', function () {
$plugin = new CoveragePlugin(new ConsoleOutput());
$plugin = new CoveragePlugin(new ConsoleOutput);
expect($plugin->coverageMin)->toEqual(0.0)
->and($plugin->coverage)->toBeFalse();
@ -35,7 +35,7 @@ it('adds coverage if --min exist', function () {
});
it('generates coverage based on file input', function () {
expect(Coverage::getMissingCoverage(new class()
expect(Coverage::getMissingCoverage(new class
{
public function lineCoverageData(): array
{

View File

@ -10,9 +10,7 @@ use Tests\Fixtures\Covers\CoversTrait;
$runCounter = 0;
function testCoversFunction()
{
}
function testCoversFunction() {}
it('uses the correct PHPUnit attribute for class', function () {
$attributes = (new ReflectionClass($this))->getAttributes();

View File

@ -46,7 +46,7 @@ test('it truncates the description', function () {
// it gets tested by the integration test
})->with([str_repeat('Fooo', 10)]);
$state = new stdClass();
$state = new stdClass;
$state->text = '';
$datasets = [[1], [2]];
@ -119,7 +119,7 @@ class Bar
}
$namedDatasets = [
new Bar(),
new Bar,
];
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();
$counter++;
})->with([
['Name 1', new Plugin(), true],
['Name 1', new Plugin(), true],
['Name 1', new Plugin(), false],
['Name 2', new Plugin(), false],
['Name 2', new Plugin(), true],
['Name 1', new Plugin(), true],
['Name 1', new Plugin, true],
['Name 1', new Plugin, true],
['Name 1', new Plugin, false],
['Name 2', new Plugin, false],
['Name 2', new Plugin, true],
['Name 1', new Plugin, true],
]);
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');
});
$wrapped_generator_state = new stdClass();
$wrapped_generator_state = new stdClass;
$wrapped_generator_state->text = '';
$wrapped_generator_function_datasets = [1, 2, 3, 4];

View File

@ -3,7 +3,7 @@
it('gives access the the underlying expectException', function () {
$this->expectException(InvalidArgumentException::class);
throw new InvalidArgumentException();
throw new InvalidArgumentException;
});
it('catch exceptions', function () {

View File

@ -1,29 +1,29 @@
<?php
it('can access methods', function () {
expect(new HasMethods())
expect(new HasMethods)
->name()->toBeString()->toEqual('Has Methods');
});
it('can access multiple methods', function () {
expect(new HasMethods())
expect(new HasMethods)
->name()->toBeString()->toEqual('Has Methods')
->quantity()->toBeInt()->toEqual(20);
});
it('works with not', function () {
expect(new HasMethods())
expect(new HasMethods)
->name()->not->toEqual('world')->toEqual('Has Methods')
->quantity()->toEqual(20)->not()->toEqual('bar')->not->toBeNull;
});
it('can accept arguments', function () {
expect(new HasMethods())
expect(new HasMethods)
->multiply(5, 4)->toBeInt->toEqual(20);
});
it('works with each', function () {
expect(new HasMethods())
expect(new HasMethods)
->attributes()->toBeArray->each->not()->toBeNull
->attributes()->each(function ($attribute) {
$attribute->not->toBeNull();
@ -31,14 +31,14 @@ it('works with each', function () {
});
it('works inside of each', function () {
expect(new HasMethods())
expect(new HasMethods)
->books()->each(function ($book) {
$book->title->not->toBeNull->cost->toBeGreaterThan(19);
});
});
it('works with sequence', function () {
expect(new HasMethods())
expect(new HasMethods)
->books()->sequence(
function ($book) {
$book->title->toEqual('Foo')->cost->toEqual(20);
@ -50,7 +50,7 @@ it('works with sequence', function () {
});
it('can compose complex expectations', function () {
expect(new HasMethods())
expect(new HasMethods)
->toBeObject()
->name()->toEqual('Has Methods')->not()->toEqual('bar')
->quantity()->not->toEqual('world')->toEqual(20)->toBeInt
@ -68,7 +68,7 @@ it('can compose complex expectations', function () {
});
it('can handle nested method calls', function () {
expect(new HasMethods())
expect(new HasMethods)
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
->newInstance()->name()->toEqual('Has Methods')->not->toBeInt
->name()->toEqual('Has Methods')
@ -76,14 +76,14 @@ it('can handle nested method calls', function () {
});
it('works with higher order tests')
->expect(new HasMethods())
->expect(new HasMethods)
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
->newInstance()->name()->toEqual('Has Methods')->not->toBeArray
->name()->toEqual('Has Methods')
->books()->each->toBeArray;
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
->name->toBe('Has Methods')
->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 () {
expect(new HasMethods())
expect(new HasMethods)
->jsonString()->json()->id->toBe(1)
->jsonString()->json()->name->toBe('Has Methods')->toBeString()
->jsonString()->json()->quantity->toBe(20)->toBeInt();
@ -152,6 +152,6 @@ class HasMethods
public function newInstance()
{
return new static();
return new static;
}
}

View File

@ -1,7 +1,7 @@
<?php
it('can access methods and properties', function () {
expect(new HasMethodsAndProperties())
expect(new HasMethodsAndProperties)
->name->toEqual('Has Methods and Properties')->not()->toEqual('bar')
->multiply(3, 4)->not->toBeString->toEqual(12)
->posts->each(function ($post) {
@ -19,7 +19,7 @@ it('can access 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
->newInstance()->meta->foo->toBeArray()
->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')
->expect(new HasMethodsAndProperties())
->expect(new HasMethodsAndProperties)
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
->newInstance()->meta->foo->toBeArray
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
->newInstance()->books()->toBeArray();
it('can start a new higher order expectation using the and syntax', function () {
expect(new HasMethodsAndProperties())
expect(new HasMethodsAndProperties)
->toBeInstanceOf(HasMethodsAndProperties::class)
->meta->toBeArray
->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')
->expect(new HasMethodsAndProperties())
->expect(new HasMethodsAndProperties)
->toBeInstanceOf(HasMethodsAndProperties::class)
->meta->toBeArray
->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');
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)
->meta
->sequence(
@ -101,6 +101,6 @@ class HasMethodsAndProperties
public function newInstance()
{
return new static();
return new static;
}
}

View File

@ -53,7 +53,7 @@ it('can compose complex expectations', function () {
});
it('works with objects', function () {
expect(new HasProperties())
expect(new HasProperties)
->name->toEqual('foo')->not->toEqual('world')
->posts->toHaveCount(2)->each(function ($post) {
$post->is_published->toBeTrue();
@ -69,13 +69,13 @@ it('works with objects', function () {
});
it('works with nested properties', function () {
expect(new HasProperties())
expect(new HasProperties)
->nested->foo->bar->toBeString()->toEqual('baz')
->posts->toBeArray()->toHaveCount(2);
});
it('works with higher order tests')
->expect(new HasProperties())
->expect(new HasProperties)
->nested->foo->bar->toBeString()->toEqual('baz')
->posts->toBeArray()->toHaveCount(2);

View File

@ -56,7 +56,7 @@ class State
}
}
$state = new State();
$state = new State;
/*
* Overrides toBe to assert two Characters are the same

View File

@ -5,8 +5,8 @@ use PHPUnit\Framework\ExpectationFailedException;
expect(true)->toBeTrue()->and(false)->toBeFalse();
test('strict comparisons', function () {
$nuno = new stdClass();
$dries = new stdClass();
$nuno = new stdClass;
$dries = new stdClass;
expect($nuno)->toBe($nuno)->not->toBe($dries);
});

View File

@ -3,8 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(function () {
})->toBeCallable();
expect(function () {})->toBeCallable();
expect(null)->not->toBeCallable();
});

View File

@ -8,8 +8,8 @@ test('passes', function () {
});
test('passes with DateTime and DateTimeImmutable', function () {
$now = new DateTime();
$past = (new DateTimeImmutable())->modify('-1 day');
$now = new DateTime;
$past = (new DateTimeImmutable)->modify('-1 day');
expect($now)->toBeGreaterThan($past);

View File

@ -8,8 +8,8 @@ test('passes', function () {
});
test('passes with DateTime and DateTimeImmutable', function () {
$now = new DateTime();
$past = (new DateTimeImmutable())->modify('-1 day');
$now = new DateTime;
$past = (new DateTimeImmutable)->modify('-1 day');
expect($now)->toBeGreaterThanOrEqual($now);

View File

@ -3,18 +3,18 @@
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(new Exception())->toBeInstanceOf(Exception::class);
expect(new Exception())->not->toBeInstanceOf(RuntimeException::class);
expect(new Exception)->toBeInstanceOf(Exception::class);
expect(new Exception)->not->toBeInstanceOf(RuntimeException::class);
});
test('failures', function () {
expect(new Exception())->toBeInstanceOf(RuntimeException::class);
expect(new Exception)->toBeInstanceOf(RuntimeException::class);
})->throws(ExpectationFailedException::class);
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!');
test('not failures', function () {
expect(new Exception())->not->toBeInstanceOf(Exception::class);
expect(new Exception)->not->toBeInstanceOf(Exception::class);
})->throws(ExpectationFailedException::class);

View File

@ -8,8 +8,8 @@ test('passes', function () {
});
test('passes with DateTime and DateTimeImmutable', function () {
$now = new DateTime();
$past = (new DateTimeImmutable())->modify('-1 day');
$now = new DateTime;
$past = (new DateTimeImmutable)->modify('-1 day');
expect($past)->toBeLessThan($now);

View File

@ -8,8 +8,8 @@ test('passes', function () {
});
test('passes with DateTime and DateTimeImmutable', function () {
$now = new DateTime();
$past = (new DateTimeImmutable())->modify('-1 day');
$now = new DateTime;
$past = (new DateTimeImmutable)->modify('-1 day');
expect($now)->toBeLessThanOrEqual($now);

View 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);

View File

@ -3,7 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
$this->times = [new DateTimeImmutable(), new DateTimeImmutable()];
$this->times = [new DateTimeImmutable, new DateTimeImmutable];
});
test('pass', function () {

View File

@ -4,13 +4,9 @@ use PHPUnit\Framework\ExpectationFailedException;
$object = new class
{
public function foo(): void
{
}
public function foo(): void {}
public function bar(): void
{
}
public function bar(): void {}
};
test('pass', function () use ($object) {

View File

@ -3,7 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
$object = new stdClass();
$object = new stdClass;
$object->name = 'John';
$object->age = 21;
@ -16,7 +16,7 @@ test('pass', function () {
});
test('failures', function () {
$object = new stdClass();
$object = new stdClass;
$object->name = 'John';
expect($object)
@ -28,7 +28,7 @@ test('failures', function () {
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
$object = new stdClass();
$object = new stdClass;
$object->name = 'John';
expect($object)
@ -40,7 +40,7 @@ test('failures with custom message', function () {
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
$object = new stdClass();
$object = new stdClass;
$object->name = 'John';
$object->age = 21;

View File

@ -2,7 +2,7 @@
use PHPUnit\Framework\ExpectationFailedException;
$obj = new stdClass();
$obj = new stdClass;
$obj->foo = 'bar';
$obj->fooNull = null;

View File

@ -4,17 +4,17 @@ use PHPUnit\Framework\Constraint\IsTrue;
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(true)->toMatchConstraint(new IsTrue());
expect(true)->toMatchConstraint(new IsTrue);
});
test('failures', function () {
expect(false)->toMatchConstraint(new IsTrue());
expect(false)->toMatchConstraint(new IsTrue);
})->throws(ExpectationFailedException::class);
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!');
test('not failures', function () {
expect(true)->not->toMatchConstraint(new IsTrue());
expect(true)->not->toMatchConstraint(new IsTrue);
})->throws(ExpectationFailedException::class);

View File

@ -18,7 +18,7 @@ test('pass', function () {
});
test('pass with class', function () {
expect(new class()
expect(new class
{
public $name = 'Nuno';

View File

@ -43,9 +43,7 @@ test('pass with `__toString`', function () {
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function __construct(protected string $snapshotable) {}
public function __toString()
{
@ -61,9 +59,7 @@ test('pass with `toString`', function () {
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function __construct(protected string $snapshotable) {}
public function toString()
{
@ -97,9 +93,7 @@ test('pass with `toArray`', function () {
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function __construct(protected string $snapshotable) {}
public function toArray()
{
@ -125,9 +119,7 @@ test('pass with `toSnapshot`', function () {
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function __construct(protected string $snapshotable) {}
public function toSnapshot()
{

View File

@ -2,60 +2,52 @@
use PHPUnit\Framework\ExpectationFailedException;
class CustomException extends Exception
{
}
class CustomException extends Exception {}
test('passes', function () {
expect(function () {
throw new RuntimeException();
throw new RuntimeException;
})->toThrow(RuntimeException::class);
expect(function () {
throw new RuntimeException();
throw new RuntimeException;
})->toThrow(Exception::class);
expect(function () {
throw new RuntimeException();
})->toThrow(function (RuntimeException $e) {
});
throw new RuntimeException;
})->toThrow(function (RuntimeException $e) {});
expect(function () {
throw new RuntimeException('actual message');
})->toThrow(function (Exception $e) {
expect($e->getMessage())->toBe('actual message');
});
expect(function () {
})->not->toThrow(Exception::class);
expect(function () {})->not->toThrow(Exception::class);
expect(function () {
throw new RuntimeException('actual message');
})->toThrow('actual message');
expect(function () {
throw new Exception();
throw new Exception;
})->not->toThrow(RuntimeException::class);
expect(function () {
throw new RuntimeException('actual message');
})->toThrow(RuntimeException::class, 'actual message');
expect(function () {
throw new RuntimeException('actual message');
})->toThrow(function (RuntimeException $e) {
}, 'actual message');
})->toThrow(function (RuntimeException $e) {}, 'actual message');
expect(function () {
throw new CustomException('foo');
})->toThrow(new CustomException('foo'));
});
test('failures 1', function () {
expect(function () {
})->toThrow(RuntimeException::class);
expect(function () {})->toThrow(RuntimeException::class);
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
test('failures 2', function () {
expect(function () {
})->toThrow(function (RuntimeException $e) {
});
expect(function () {})->toThrow(function (RuntimeException $e) {});
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
test('failures 3', function () {
expect(function () {
throw new Exception();
throw new Exception;
})->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).');
test('failures 6', function () {
expect(function () {
})->toThrow('actual message');
expect(function () {})->toThrow('actual message');
})->throws(ExpectationFailedException::class, 'Exception with message "actual message" not thrown');
test('failures 7', function () {
@ -101,34 +92,30 @@ test('failures with custom message', function () {
test('not failures', function () {
expect(function () {
throw new RuntimeException();
throw new RuntimeException;
})->not->toThrow(RuntimeException::class);
})->throws(ExpectationFailedException::class);
test('closure missing parameter', function () {
expect(function () {
})->toThrow(function () {
});
expect(function () {})->toThrow(function () {});
})->throws(InvalidArgumentException::class, 'The given closure must have a single parameter type-hinted as the class string.');
test('closure missing type-hint', function () {
expect(function () {
})->toThrow(function ($e) {
});
expect(function () {})->toThrow(function ($e) {});
})->throws(InvalidArgumentException::class, 'The given closure\'s parameter must be type-hinted as the class string.');
it('can handle a non-defined exception', function () {
expect(function () {
throw new NonExistingException();
throw new NonExistingException;
})->toThrow(NonExistingException::class);
})->throws(Error::class, 'Class "NonExistingException" not found');
it('can handle a class not found Error', function () {
expect(function () {
throw new NonExistingException();
throw new NonExistingException;
})->toThrow('Class "NonExistingException" not found');
expect(function () {
throw new NonExistingException();
throw new NonExistingException;
})->toThrow(Error::class, 'Class "NonExistingException" not found');
});

View File

@ -3,7 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
$this->unlessObject = new stdClass();
$this->unlessObject = new stdClass;
$this->unlessObject->trueValue = true;
$this->unlessObject->foo = 'foo';
});

View File

@ -3,7 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
$this->whenObject = new stdClass();
$this->whenObject = new stdClass;
$this->whenObject->trueValue = true;
$this->whenObject->foo = 'foo';
});

View File

@ -1,6 +1,6 @@
<?php
$state = new stdClass();
$state = new stdClass;
$state->text = '';
test('uses dataset', function ($value) use ($state) {
$state->text .= $value;

View File

@ -1,6 +1,6 @@
<?php
$state = new stdClass();
$state = new stdClass;
$state->text = '';
test('uses dataset', function ($value) use ($state) {
$state->text .= $value;

View File

@ -4,7 +4,7 @@ dataset('numbers.array', [
1, 2, 3, 4, 5, 'ScopedDatasets/ScopedDatasets.php',
]);
$state = new stdClass();
$state = new stdClass;
$state->text = '';
test('uses dataset', function ($value) use ($state) {
$state->text .= $value;

View File

@ -1,6 +1,6 @@
<?php
$state = new stdClass();
$state = new stdClass;
$state->text = '';
test('uses dataset', function ($value) use ($state) {
$state->text .= $value;

View File

@ -1,6 +1,6 @@
<?php
$state = new stdClass();
$state = new stdClass;
$state->text = '';
test('uses dataset', function ($value) use ($state) {
$state->text .= $value;

View File

@ -2,7 +2,7 @@
use function PHPUnit\Framework\assertFalse;
$foo = new stdClass();
$foo = new stdClass;
$foo->beforeAll = false;
$foo->beforeEach = false;
$foo->afterEach = false;

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsInvokable;
class InvokableClass
{
public function __invoke(): void
{
}
public function __invoke(): void {}
}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsInvokable;
class ParentInvokableClass
{
public function __invoke(): void
{
}
public function __invoke(): void {}
}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsNotInvokable;
class IsNotInvokableClass
{
public function handle(): void
{
}
public function handle(): void {}
}

View File

@ -7,6 +7,4 @@ namespace Tests\Fixtures\Arch\ToHaveAttribute\Attributes;
use Attribute;
#[Attribute()]
class AsAttribute
{
}
class AsAttribute {}

View File

@ -7,6 +7,4 @@ namespace Tests\Fixtures\Arch\ToHaveAttribute\HaveAttribute;
use Tests\Fixtures\Arch\ToHaveAttribute\Attributes\AsAttribute;
#[AsAttribute]
class HaveAttributeClass
{
}
class HaveAttributeClass {}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHaveAttribute\NotHaveAttribute;
class NotHaveAttributeClass
{
}
class NotHaveAttributeClass {}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveConstructor\HasConstructor;
class HasConstructor
{
public function __construct()
{
}
public function __construct() {}
}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHaveConstructor\HasNoConstructor;
class HasNoConstructor
{
}
class HasNoConstructor {}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveDestructor\HasDestructor;
class HasDestructor
{
public function __destruct()
{
}
public function __destruct() {}
}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHaveDestructor\HasNoDestructor;
class HasNoDestructor
{
}
class HasNoDestructor {}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasMethod;
class HasMethod
{
public function foo(): void
{
}
public function foo(): void {}
}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasMethod;
trait HasMethodTrait
{
public function foo(): void
{
}
public function foo(): void {}
}

Some files were not shown because too many files have changed in this diff Show More