Migrates to Pint

This commit is contained in:
Nuno Maduro
2022-09-16 10:45:53 +01:00
parent 579b975318
commit e9564febaf
94 changed files with 413 additions and 471 deletions

View File

@ -47,5 +47,11 @@ jobs:
- name: Install Dependencies
run: composer update --prefer-stable --no-interaction --no-progress --ansi
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress --debug --ansi
- name: Types
run: composer test:types
- name: Style
run: composer test:lint
- name: Recfato
run: composer test:refacto

View File

@ -34,11 +34,11 @@ jobs:
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress --ansi
- name: Unit Tests
run: php bin/pest --colors=always --exclude-group=integration
run: composer test:unit
- name: Unit Tests
run: php bin/pest --colors=always --exclude-group=integration ${{ matrix.parallel }}
run: test:parallel
if: ${{ false }} # 2.x-dev is under development
- name: Integration Tests
run: php bin/pest --colors=always --group=integration -v
run: composer test:integration

View File

@ -1,31 +0,0 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . DIRECTORY_SEPARATOR . 'tests')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'bin')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'overrides')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'stubs')
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')
->append(['.php-cs-fixer.dist.php']);
$rules = [
'@Symfony' => true,
'phpdoc_no_empty_return' => false,
'array_syntax' => ['syntax' => 'short'],
'yoda_style' => false,
'binary_operator_spaces' => [
'operators' => [
'=>' => 'align',
'=' => 'align',
],
],
'concat_space' => ['spacing' => 'one'],
'not_operator_with_space' => false,
];
$rules['increment_style'] = ['style' => 'post'];
return (new PhpCsFixer\Config())
->setUsingCache(true)
->setRules($rules)
->setFinder($finder);

View File

@ -51,7 +51,13 @@
"illuminate/console": "^9.30.1",
"illuminate/support": "^9.30.1",
"laravel/dusk": "^6.25.1",
"pestphp/pest-dev-tools": "dev-master"
"ergebnis/phpstan-rules": "^1.0.0",
"laravel/pint": "^1.2.0",
"phpstan/phpstan": "^1.8.5",
"phpstan/phpstan-strict-rules": "^1.4.3",
"symfony/var-dumper": "^6.2.0",
"thecodingmachine/phpstan-strict-rules": "^1.0.0",
"rector/rector": "^0.14.2"
},
"minimum-stability": "dev",
"prefer-stable": true,
@ -66,8 +72,10 @@
"bin/pest"
],
"scripts": {
"lint": "PHP_CS_FIXER_IGNORE_ENV=true php-cs-fixer fix -v",
"test:lint": "PHP_CS_FIXER_IGNORE_ENV=true php-cs-fixer fix -v --dry-run",
"lint": "pint --test",
"refactor": "rector",
"test:lint": "pint --test",
"test:refactor": "rector --dry-run",
"test:types": "phpstan analyse --ansi --memory-limit=-1 --debug",
"test:unit": "php bin/pest --colors=always --exclude-group=integration",
"test:parallel": "exit 1",
@ -77,7 +85,8 @@
"@test:lint",
"@test:types",
"@test:unit",
"@test:integration"
"@test:integration",
"@test:refactor"
]
},
"extra": {

View File

@ -37,22 +37,16 @@
namespace PHPUnit\Runner\Filter;
use function end;
use Exception;
use function implode;
use Pest\Contracts\HasPrintableTestCaseName;
use PHPUnit\Framework\SelfDescribing;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestSuite;
use function preg_match;
use RecursiveFilterIterator;
use RecursiveIterator;
use function sprintf;
use function str_replace;
@ -62,7 +56,9 @@ use function str_replace;
final class NameFilterIterator extends RecursiveFilterIterator
{
private ?string $filter = null;
private ?int $filterMin = null;
private ?int $filterMax = null;
/**

View File

@ -43,14 +43,12 @@ use function array_values;
use function basename;
use function class_exists;
use function get_declared_classes;
use Pest\Contracts\HasPrintableTestCaseName;
use Pest\TestCases\IgnorableTest;
use Pest\TestSuite;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionException;
use function substr;
/**
@ -116,7 +114,7 @@ final class TestSuiteLoader
}
}
if (!$testCaseFound) {
if (! $testCaseFound) {
foreach (self::$loadedClasses as $loadedClass) {
if (is_subclass_of($loadedClass, TestCase::class)) {
$suiteClassName = $loadedClass;
@ -126,7 +124,7 @@ final class TestSuiteLoader
}
}
if (!class_exists($suiteClassName, false)) {
if (! class_exists($suiteClassName, false)) {
return $this->exceptionFor($suiteClassName, $suiteClassFile);
}
@ -138,7 +136,7 @@ final class TestSuiteLoader
}
// @codeCoverageIgnoreEnd
if ($class->isSubclassOf(TestCase::class) && !$class->isAbstract()) {
if ($class->isSubclassOf(TestCase::class) && ! $class->isAbstract()) {
return $class;
}
@ -151,7 +149,7 @@ final class TestSuiteLoader
}
// @codeCoverageIgnoreEnd
if (!$method->isAbstract() && $method->isPublic() && $method->isStatic()) {
if (! $method->isAbstract() && $method->isPublic() && $method->isStatic()) {
return $class;
}
}

28
rector.php Normal file
View File

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/bin',
__DIR__.'/src',
]);
$rectorConfig->rules([
InlineConstructorDefaultToPropertyRector::class,
]);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::TYPE_DECLARATION,
SetList::PRIVATIZATION,
]);
};

View File

@ -5,9 +5,7 @@ declare(strict_types=1);
namespace Pest\Bootstrappers;
use Pest\Support\Str;
use function Pest\testDirectory;
use Pest\TestSuite;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
@ -38,12 +36,12 @@ final class BootFiles
public function __invoke(): void
{
$rootPath = TestSuite::getInstance()->rootPath;
$testsPath = $rootPath . DIRECTORY_SEPARATOR . testDirectory();
$testsPath = $rootPath.DIRECTORY_SEPARATOR.testDirectory();
foreach (self::STRUCTURE as $filename) {
$filename = sprintf('%s%s%s', $testsPath, DIRECTORY_SEPARATOR, $filename);
if (!file_exists($filename)) {
if (! file_exists($filename)) {
continue;
}

View File

@ -17,7 +17,6 @@ trait Expectable
* Creates a new Expectation.
*
* @param TValue $value
*
* @return Expectation<TValue>
*/
public function expect(mixed $value): Expectation

View File

@ -18,7 +18,6 @@ trait Retrievable
*
* @param array<string, TRetrievableValue>|object $value
* @param TRetrievableValue|null $default
*
* @return TRetrievableValue|null
*/
private function retrieve(string $key, mixed $value, mixed $default = null): mixed

View File

@ -79,7 +79,7 @@ trait Testable
*/
public function __addBeforeAll(?Closure $hook): void
{
if (!$hook) {
if (! $hook) {
return;
}
@ -93,7 +93,7 @@ trait Testable
*/
public function __addAfterAll(?Closure $hook): void
{
if (!$hook) {
if (! $hook) {
return;
}
@ -123,7 +123,7 @@ trait Testable
*/
private function __addHook(string $property, ?Closure $hook): void
{
if (!$hook) {
if (! $hook) {
return;
}
@ -222,7 +222,7 @@ trait Testable
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
if ($this->dataName()) {
self::$__description = $method->description . ' with ' . $this->dataName();
self::$__description = $method->description.' with '.$this->dataName();
} else {
self::$__description = $method->description;
}
@ -231,7 +231,7 @@ trait Testable
return $arguments;
}
if (!$arguments[0] instanceof Closure) {
if (! $arguments[0] instanceof Closure) {
return $arguments;
}
@ -244,7 +244,7 @@ trait Testable
$boundDatasetResult = $this->__callClosure($arguments[0], []);
if (count($testParameterTypes) === 1 || !is_array($boundDatasetResult)) {
if (count($testParameterTypes) === 1 || ! is_array($boundDatasetResult)) {
return [$boundDatasetResult];
}

View File

@ -45,7 +45,7 @@ final class ConfigLoader
$suiteDirectory = $this->config->xpath('/phpunit/testsuites/testsuite/directory');
// @phpstan-ignore-next-line
if (!$suiteDirectory || count($suiteDirectory) === 0) {
if (! $suiteDirectory || count($suiteDirectory) === 0) {
return self::DEFAULT_TESTS_PATH;
}
@ -71,9 +71,9 @@ final class ConfigLoader
public function getConfigurationFilePath(): string|false
{
$candidates = [
$this->rootPath . '/phpunit.xml',
$this->rootPath . '/phpunit.dist.xml',
$this->rootPath . '/phpunit.xml.dist',
$this->rootPath.'/phpunit.xml',
$this->rootPath.'/phpunit.dist.xml',
$this->rootPath.'/phpunit.xml.dist',
];
foreach ($candidates as $candidate) {

View File

@ -13,7 +13,6 @@ interface HandlesArguments
* Adds arguments before of the Test Suite execution.
*
* @param array<int, string> $arguments
*
* @return array<int, string>
*/
public function handleArguments(array $arguments): array;

View File

@ -51,7 +51,6 @@ final class Expectation
* @template TAndValue
*
* @param TAndValue $value
*
* @return self<TAndValue>
*/
public function and(mixed $value): Expectation
@ -66,7 +65,7 @@ final class Expectation
*/
public function json(): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -139,7 +138,7 @@ final class Expectation
*/
public function each(callable $callback = null): EachExpectation
{
if (!is_iterable($this->value)) {
if (! is_iterable($this->value)) {
throw new BadMethodCallException('Expectation value is not iterable.');
}
@ -158,12 +157,11 @@ final class Expectation
* @template TSequenceValue
*
* @param (callable(self<TValue>, self<string|int>): void)|TSequenceValue ...$callbacks
*
* @return self<TValue>
*/
public function sequence(mixed ...$callbacks): Expectation
{
if (!is_iterable($this->value)) {
if (! is_iterable($this->value)) {
throw new BadMethodCallException('Expectation value is not iterable.');
}
@ -203,7 +201,6 @@ final class Expectation
*
* @param (callable(): TMatchSubject)|TMatchSubject $subject
* @param array<TMatchSubject, (callable(self<TValue>): mixed)|TValue> $expressions
*
* @return self<TValue>
*/
public function match(mixed $subject, array $expressions): Expectation
@ -242,7 +239,6 @@ final class Expectation
*
* @param (callable(): bool)|bool $condition
* @param callable(Expectation<TValue>): mixed $callback
*
* @return self<TValue>
*/
public function unless(callable|bool $condition, callable $callback): Expectation
@ -253,7 +249,7 @@ final class Expectation
return $condition;
};
return $this->when(!$condition(), $callback);
return $this->when(! $condition(), $callback);
}
/**
@ -261,7 +257,6 @@ final class Expectation
*
* @param (callable(): bool)|bool $condition
* @param callable(self<TValue>): mixed $callback
*
* @return self<TValue>
*/
public function when(callable|bool $condition, callable $callback): Expectation
@ -283,12 +278,11 @@ final class Expectation
* Dynamically calls methods on the class or creates a new higher order expectation.
*
* @param array<int, mixed> $parameters
*
* @return Expectation<TValue>|HigherOrderExpectation<Expectation<TValue>, TValue>
*/
public function __call(string $method, array $parameters): Expectation|HigherOrderExpectation
{
if (!self::hasMethod($method)) {
if (! self::hasMethod($method)) {
/* @phpstan-ignore-next-line */
return new HigherOrderExpectation($this, $this->value->$method(...$parameters));
}
@ -331,7 +325,7 @@ final class Expectation
*/
public function __get(string $name)
{
if (!self::hasMethod($name)) {
if (! self::hasMethod($name)) {
/* @phpstan-ignore-next-line */
return new HigherOrderExpectation($this, $this->retrieve($name, $this->value));
}

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Pest\Expectations;
use function expect;
use Pest\Expectation;
/**
@ -34,7 +33,6 @@ final class EachExpectation
* @template TAndValue
*
* @param TAndValue $value
*
* @return Expectation<TAndValue>
*/
public function and(mixed $value): Expectation
@ -58,7 +56,6 @@ final class EachExpectation
* Dynamically calls methods on the class with the given arguments on each item.
*
* @param array<int|string, mixed> $arguments
*
* @return self<TValue>
*/
public function __call(string $name, array $arguments): EachExpectation

View File

@ -47,7 +47,7 @@ final class HigherOrderExpectation
*/
public function not(): HigherOrderExpectation
{
$this->opposite = !$this->opposite;
$this->opposite = ! $this->opposite;
return $this;
}
@ -58,7 +58,6 @@ final class HigherOrderExpectation
* @template TExpectValue
*
* @param TExpectValue $value
*
* @return Expectation<TExpectValue>
*/
public function expect(mixed $value): Expectation
@ -72,7 +71,6 @@ final class HigherOrderExpectation
* @template TExpectValue
*
* @param TExpectValue $value
*
* @return Expectation<TExpectValue>
*/
public function and(mixed $value): Expectation
@ -85,7 +83,6 @@ final class HigherOrderExpectation
* the HigherOrderExpectation chain.
*
* @param Closure(Expectation<TValue>): void $expectation
*
* @return HigherOrderExpectation<TOriginalValue, TOriginalValue>
*/
public function scoped(Closure $expectation): self
@ -109,12 +106,11 @@ final class HigherOrderExpectation
* Dynamically calls methods on the class with the given arguments.
*
* @param array<int, mixed> $arguments
*
* @return self<TOriginalValue, mixed>|self<TOriginalValue, TValue>
*/
public function __call(string $name, array $arguments): self
{
if (!$this->expectationHasMethod($name)) {
if (! $this->expectationHasMethod($name)) {
/* @phpstan-ignore-next-line */
return new self($this->original, $this->getValue()->$name(...$arguments));
}
@ -133,7 +129,7 @@ final class HigherOrderExpectation
return $this->not();
}
if (!$this->expectationHasMethod($name)) {
if (! $this->expectationHasMethod($name)) {
/** @var array<string, mixed>|object $value */
$value = $this->getValue();
@ -166,7 +162,6 @@ final class HigherOrderExpectation
* Performs the given assertion with the current expectation.
*
* @param array<int, mixed> $arguments
*
* @return self<TOriginalValue, TValue>
*/
private function performAssertion(string $name, array $arguments): self

View File

@ -31,7 +31,6 @@ final class OppositeExpectation
* Asserts that the value array not has the provided $keys.
*
* @param array<int, int|string|array<int-string, mixed>> $keys
*
* @return Expectation<TValue>
*/
public function toHaveKeys(array $keys): Expectation
@ -39,7 +38,7 @@ final class OppositeExpectation
foreach ($keys as $k => $key) {
try {
if (is_array($key)) {
$this->toHaveKeys(array_keys(Arr::dot($key, $k . '.')));
$this->toHaveKeys(array_keys(Arr::dot($key, $k.'.')));
} else {
$this->original->toHaveKey($key);
}
@ -57,7 +56,6 @@ final class OppositeExpectation
* Handle dynamic method calls into the original expectation.
*
* @param array<int, mixed> $arguments
*
* @return Expectation<TValue>|Expectation<mixed>|never
*/
public function __call(string $name, array $arguments): Expectation
@ -92,7 +90,6 @@ final class OppositeExpectation
* Creates a new expectation failed exception with a nice readable message.
*
* @param array<int, mixed> $arguments
*
* @return never
*/
private function throwExpectationFailedException(string $name, array $arguments = []): void

View File

@ -16,7 +16,6 @@ final class CoversNothing
* Adds annotations regarding the "depends" feature.
*
* @param array<int, string> $annotations
*
* @return array<int, string>
*/
public function __invoke(TestCaseMethodFactory $method, array $annotations): array

View File

@ -16,7 +16,6 @@ final class Depends
* Adds annotations regarding the "depends" feature.
*
* @param array<int, string> $annotations
*
* @return array<int, string>
*/
public function __invoke(TestCaseMethodFactory $method, array $annotations): array

View File

@ -15,7 +15,6 @@ final class Groups
* Adds annotations regarding the "groups" feature.
*
* @param array<int, string> $annotations
*
* @return array<int, string>
*/
public function __invoke(TestCaseMethodFactory $method, array $annotations): array

View File

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

View File

@ -24,7 +24,6 @@ final class Covers extends Attribute
* Adds attributes regarding the "covers" feature.
*
* @param array<int, string> $attributes
*
* @return array<int, string>
*/
public function __invoke(TestCaseMethodFactory $method, array $attributes): array
@ -33,7 +32,7 @@ final class Covers extends Attribute
if ($covering instanceof CoversClass) {
// Prepend a backslash for FQN classes
if (str_contains($covering->class, '\\')) {
$covering->class = '\\' . $covering->class;
$covering->class = '\\'.$covering->class;
}
$attributes[] = "#[\PHPUnit\Framework\Attributes\CoversClass({$covering->class}::class)]";

View File

@ -120,7 +120,7 @@ final class TestCaseFactory
$filename = str_replace('\\\\', '\\', addslashes((string) realpath($filename)));
$rootPath = TestSuite::getInstance()->rootPath;
$relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename);
$relativePath = str_replace($rootPath.DIRECTORY_SEPARATOR, '', $filename);
$basename = basename($relativePath, '.php');
@ -130,7 +130,7 @@ final class TestCaseFactory
$basename = substr($basename, 0, $dotPos);
}
$relativePath = dirname(ucfirst($relativePath)) . DIRECTORY_SEPARATOR . $basename;
$relativePath = dirname(ucfirst($relativePath)).DIRECTORY_SEPARATOR.$basename;
$relativePath = str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath);
@ -141,7 +141,7 @@ final class TestCaseFactory
// Limit to A-Z, a-z, 0-9, '_', '-'.
$relativePath = (string) preg_replace('/[^A-Za-z0-9\\\\]/', '', $relativePath);
$classFQN = 'P\\' . $relativePath;
$classFQN = 'P\\'.$relativePath;
if (class_exists($classFQN)) {
return;
@ -158,12 +158,12 @@ final class TestCaseFactory
$baseClass = sprintf('\%s', $this->class);
if ('' === trim($className)) {
$className = 'InvalidTestName' . Str::random();
$className = 'InvalidTestName'.Str::random();
$classFQN .= $className;
}
$classAvailableAttributes = array_filter(self::$attributes, fn (string $attribute) => $attribute::ABOVE_CLASS);
$methodAvailableAttributes = array_filter(self::$attributes, fn (string $attribute) => !$attribute::ABOVE_CLASS);
$methodAvailableAttributes = array_filter(self::$attributes, fn (string $attribute) => ! $attribute::ABOVE_CLASS);
$classAttributes = [];
@ -225,7 +225,7 @@ final class TestCaseFactory
throw new TestAlreadyExist($method->filename, $method->description);
}
if (!$method->receivesArguments()) {
if (! $method->receivesArguments()) {
if ($method->closure === null) {
throw ShouldNotHappen::fromMessage('The test closure may not be empty.');
}

View File

@ -123,7 +123,7 @@ final class TestCaseMethodFactory
$methodName = Str::evaluable($this->description);
if (Retry::$retrying && !TestSuite::getInstance()->retryTempRepository->exists(sprintf('%s::%s', $classFQN, $methodName))) {
if (Retry::$retrying && ! TestSuite::getInstance()->retryTempRepository->exists(sprintf('%s::%s', $classFQN, $methodName))) {
return '';
}
@ -141,7 +141,7 @@ final class TestCaseMethodFactory
}
if (count($this->datasets) > 0) {
$dataProviderName = $methodName . '_dataset';
$dataProviderName = $methodName.'_dataset';
$annotations[] = "@dataProvider $dataProviderName";
$datasetsCode = $this->buildDatasetForEvaluation($methodName, $dataProviderName);
}

View File

@ -13,14 +13,13 @@ use Pest\Support\HigherOrderTapProxy;
use Pest\TestSuite;
use PHPUnit\Framework\TestCase;
if (!function_exists('expect')) {
if (! function_exists('expect')) {
/**
* Creates a new expectation.
*
* @template TValue
*
* @param TValue $value
*
* @return Expectation<TValue>
*/
function expect(mixed $value = null): Expectation
@ -29,7 +28,7 @@ if (!function_exists('expect')) {
}
}
if (!function_exists('beforeAll')) {
if (! function_exists('beforeAll')) {
/**
* Runs the given closure before all tests in the current file.
*/
@ -39,7 +38,7 @@ if (!function_exists('beforeAll')) {
}
}
if (!function_exists('beforeEach')) {
if (! function_exists('beforeEach')) {
/**
* Runs the given closure before each test in the current file.
*
@ -53,7 +52,7 @@ if (!function_exists('beforeEach')) {
}
}
if (!function_exists('dataset')) {
if (! function_exists('dataset')) {
/**
* Registers the given dataset.
*
@ -65,7 +64,7 @@ if (!function_exists('dataset')) {
}
}
if (!function_exists('uses')) {
if (! function_exists('uses')) {
/**
* The uses function binds the given
* arguments to test closures.
@ -80,7 +79,7 @@ if (!function_exists('uses')) {
}
}
if (!function_exists('test')) {
if (! function_exists('test')) {
/**
* Adds the given closure as a test. The first argument
* is the test description; the second argument is
@ -100,7 +99,7 @@ if (!function_exists('test')) {
}
}
if (!function_exists('it')) {
if (! function_exists('it')) {
/**
* Adds the given closure as a test. The first argument
* is the test description; the second argument is
@ -119,7 +118,7 @@ if (!function_exists('it')) {
}
}
if (!function_exists('todo')) {
if (! function_exists('todo')) {
/**
* Adds the given todo test. Internally, this test
* is marked as incomplete. Yet, Collision, Pest's
@ -136,7 +135,7 @@ if (!function_exists('todo')) {
}
}
if (!function_exists('afterEach')) {
if (! function_exists('afterEach')) {
/**
* Runs the given closure after each test in the current file.
*
@ -150,7 +149,7 @@ if (!function_exists('afterEach')) {
}
}
if (!function_exists('afterAll')) {
if (! function_exists('afterAll')) {
/**
* Runs the given closure after all tests in the current file.
*/

View File

@ -90,7 +90,7 @@ final class Kernel
$returnCode = self::FAILURE_EXIT;
if ($result->wasSuccessfulIgnoringPhpunitWarnings()
&& !$result->hasTestTriggeredPhpunitWarningEvents()) {
&& ! $result->hasTestTriggeredPhpunitWarningEvents()) {
$returnCode = self::SUCCESS_EXIT;
}

View File

@ -8,9 +8,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Pest\Exceptions\InvalidConsoleArgument;
use function Pest\testDirectory;
use Pest\TestSuite;
/**
@ -53,7 +51,7 @@ final class PestDatasetCommand extends Command
throw new InvalidConsoleArgument(sprintf('%s already exist', $target));
}
if (!File::exists(dirname($relativePath))) {
if (! File::exists(dirname($relativePath))) {
File::makeDirectory(dirname($relativePath));
}

View File

@ -8,9 +8,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Pest\Console\Thanks;
use Pest\Exceptions\InvalidConsoleArgument;
use function Pest\testDirectory;
use Pest\TestSuite;
/**
@ -56,7 +54,7 @@ final class PestInstallCommand extends Command
$this->output->success('`tests/Pest.php` created successfully.');
if (!(bool) $this->option('no-interaction')) {
if (! (bool) $this->option('no-interaction')) {
(new Thanks($this->output))();
}
}

View File

@ -8,9 +8,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Pest\Exceptions\InvalidConsoleArgument;
use Pest\Support\Str;
use function Pest\testDirectory;
use Pest\TestSuite;
/**
@ -54,11 +52,11 @@ final class PestTestCommand extends Command
/* @phpstan-ignore-next-line */
$target = base_path($relativePath);
if (!File::isDirectory(dirname($target))) {
if (! File::isDirectory(dirname($target))) {
File::makeDirectory(dirname($target), 0777, true, true);
}
if (File::exists($target) && !(bool) $this->option('force')) {
if (File::exists($target) && ! (bool) $this->option('force')) {
throw new InvalidConsoleArgument(sprintf('%s already exist', $target));
}

View File

@ -180,7 +180,7 @@ final class Expectation
// @phpstan-ignore-next-line
Assert::assertStringContainsString((string) $needle, $this->value);
} else {
if (!is_iterable($this->value)) {
if (! is_iterable($this->value)) {
InvalidExpectationValue::expected('iterable');
}
Assert::assertContains($needle, $this->value);
@ -194,12 +194,11 @@ final class Expectation
* Asserts that the value starts with $expected.
*
* @param non-empty-string $expected
*
*@return Expectation<TValue>
*/
public function toStartWith(string $expected): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -212,12 +211,11 @@ final class Expectation
* Asserts that the value ends with $expected.
*
* @param non-empty-string $expected
*
*@return Expectation<TValue>
*/
public function toEndWith(string $expected): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -265,7 +263,7 @@ final class Expectation
*/
public function toHaveCount(int $count): Expectation
{
if (!is_countable($this->value) && !is_iterable($this->value)) {
if (! is_countable($this->value) && ! is_iterable($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -298,7 +296,6 @@ final class Expectation
* Asserts that the value contains the provided properties $names.
*
* @param iterable<array-key, string> $names
*
*@return Expectation<TValue>
*/
public function toHaveProperties(iterable $names): Expectation
@ -357,7 +354,6 @@ final class Expectation
* Asserts that the value is one of the given values.
*
* @param iterable<int|string, mixed> $values
*
* @return Expectation<TValue>
*/
public function toBeIn(iterable $values): Expectation
@ -383,7 +379,6 @@ final class Expectation
* Asserts that the value is an instance of $class.
*
* @param class-string $class
*
* @return Expectation<TValue>
*/
public function toBeInstanceOf(string $class): Expectation
@ -596,14 +591,13 @@ final class Expectation
* Asserts that the value array has the provided $keys.
*
* @param array<int, int|string|array<int-string, mixed>> $keys
*
* @return Expectation<TValue>
*/
public function toHaveKeys(array $keys): Expectation
{
foreach ($keys as $k => $key) {
if (is_array($key)) {
$this->toHaveKeys(array_keys(Arr::dot($key, $k . '.')));
$this->toHaveKeys(array_keys(Arr::dot($key, $k.'.')));
} else {
$this->toHaveKey($key);
}
@ -619,7 +613,7 @@ final class Expectation
*/
public function toBeDirectory(): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -635,7 +629,7 @@ final class Expectation
*/
public function toBeReadableDirectory(): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -651,7 +645,7 @@ final class Expectation
*/
public function toBeWritableDirectory(): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -667,7 +661,7 @@ final class Expectation
*/
public function toBeFile(): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -683,7 +677,7 @@ final class Expectation
*/
public function toBeReadableFile(): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
@ -699,7 +693,7 @@ final class Expectation
*/
public function toBeWritableFile(): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
Assert::assertFileIsWritable($this->value);
@ -711,7 +705,6 @@ final class Expectation
* Asserts that the value array matches the given array subset.
*
* @param iterable<int|string, mixed> $array
*
* @return Expectation<TValue>
*/
public function toMatchArray(iterable $array): Expectation
@ -744,13 +737,12 @@ final class Expectation
* of the properties of an given object.
*
* @param iterable<string, mixed> $object
*
* @return Expectation<TValue>
*/
public function toMatchObject(iterable $object): Expectation
{
foreach ((array) $object as $property => $value) {
if (!is_object($this->value) && !is_string($this->value)) {
if (! is_object($this->value) && ! is_string($this->value)) {
InvalidExpectationValue::expected('object|string');
}
@ -779,7 +771,7 @@ final class Expectation
*/
public function toMatch(string $expression): Expectation
{
if (!is_string($this->value)) {
if (! is_string($this->value)) {
InvalidExpectationValue::expected('string');
}
Assert::assertMatchesRegularExpression($expression, $this->value);
@ -801,12 +793,11 @@ final class Expectation
/**
* @param class-string $class
*
* @return Expectation<TValue>
*/
public function toContainOnlyInstancesOf(string $class): Expectation
{
if (!is_iterable($this->value)) {
if (! is_iterable($this->value)) {
InvalidExpectationValue::expected('iterable');
}
@ -819,7 +810,6 @@ final class Expectation
* Asserts that executing value throws an exception.
*
* @param (Closure(Throwable): mixed)|string $exception
*
* @return Expectation<TValue>
*/
public function toThrow(callable|string $exception, string $exceptionMessage = null): Expectation
@ -834,7 +824,7 @@ final class Expectation
throw new InvalidArgumentException('The given closure must have a single parameter type-hinted as the class string.');
}
if (!($type = $parameters[0]->getType()) instanceof ReflectionNamedType) {
if (! ($type = $parameters[0]->getType()) instanceof ReflectionNamedType) {
throw new InvalidArgumentException('The given closure\'s parameter must be type-hinted as the class string.');
}
@ -844,7 +834,7 @@ final class Expectation
try {
($this->value)();
} catch (Throwable $e) {
if (!class_exists($exception)) {
if (! class_exists($exception)) {
if ($e instanceof Error && $e->getMessage() === "Class \"$exception\" not found") {
throw $e;
}
@ -864,7 +854,7 @@ final class Expectation
return $this;
}
if (!class_exists($exception)) {
if (! class_exists($exception)) {
throw new ExpectationFailedException("Exception with message \"$exception\" not thrown.");
}

View File

@ -181,7 +181,7 @@ final class TestCall
$isClass = class_exists($classOrFunction);
$isMethod = function_exists($classOrFunction);
if (!$isClass && !$isMethod) {
if (! $isClass && ! $isMethod) {
throw new InvalidArgumentException(sprintf('No class or method named "%s" has been found.', $classOrFunction));
}

View File

@ -11,5 +11,5 @@ function version(): string
function testDirectory(string $file = ''): string
{
return TestSuite::getInstance()->testPath . '/' . $file;
return TestSuite::getInstance()->testPath.'/'.$file;
}

View File

@ -23,7 +23,7 @@ final class Plugin
public static function uses(string ...$traits): void
{
self::$callables[] = function () use ($traits): void {
uses(...$traits)->in(TestSuite::getInstance()->rootPath . DIRECTORY_SEPARATOR . testDirectory());
uses(...$traits)->in(TestSuite::getInstance()->rootPath.DIRECTORY_SEPARATOR.testDirectory());
};
}
}

View File

@ -18,7 +18,6 @@ final class HandleArguments
* Transform the input arguments by passing it to the relevant plugins.
*
* @param array<int, string> $argv
*
* @return array<int, string>
*/
public function __invoke(array $argv): array

View File

@ -23,7 +23,6 @@ trait HandleArguments
* Adds the given argument and value to the list of arguments.
*
* @param array<int, string> $arguments
*
* @return array<int, string>
*/
public function pushArgument(string $argument, array $arguments): array
@ -37,7 +36,6 @@ trait HandleArguments
* Pops the given argument from the arguments.
*
* @param array<int, string> $arguments
*
* @return array<int, string>
*/
public function popArgument(string $argument, array $arguments): array

View File

@ -93,7 +93,7 @@ final class Coverage implements AddsOutput, HandlesArguments
public function addOutput(int $exitCode): int
{
if ($exitCode === 0 && $this->coverage) {
if (!\Pest\Support\Coverage::isAvailable()) {
if (! \Pest\Support\Coverage::isAvailable()) {
$this->output->writeln(
"\n <fg=white;bg=red;options=bold> ERROR </> No code coverage driver is available.</>",
);

View File

@ -43,7 +43,7 @@ final class Init implements HandlesArguments
*/
public function handleArguments(array $arguments): array
{
if (!array_key_exists(1, $arguments) || $arguments[1] !== self::INIT_OPTION) {
if (! array_key_exists(1, $arguments) || $arguments[1] !== self::INIT_OPTION) {
return $arguments;
}
@ -58,8 +58,8 @@ final class Init implements HandlesArguments
{
$testsBaseDir = "{$this->testSuite->rootPath}/tests";
if (!is_dir($testsBaseDir)) {
if (!mkdir($testsBaseDir) && !is_dir($testsBaseDir)) {
if (! is_dir($testsBaseDir)) {
if (! mkdir($testsBaseDir) && ! is_dir($testsBaseDir)) {
$this->output->writeln(sprintf(
"\n <fg=white;bg=red;options=bold> ERROR </> Directory `%s` was not created.</>",
$testsBaseDir
@ -74,7 +74,7 @@ final class Init implements HandlesArguments
}
foreach (self::STUBS as $from => $to) {
$fromPath = __DIR__ . "/../../stubs/init/{$from}";
$fromPath = __DIR__."/../../stubs/init/{$from}";
$toPath = "{$this->testSuite->rootPath}/{$to}";
if (file_exists($toPath)) {
@ -86,16 +86,16 @@ final class Init implements HandlesArguments
continue;
}
if ($from === 'phpunit.xml' && file_exists($toPath . '.dist')) {
if ($from === 'phpunit.xml' && file_exists($toPath.'.dist')) {
$this->output->writeln(sprintf(
' <fg=black;bg=yellow;options=bold> INFO </> File `%s` already exists, skipped.</>',
$to . '.dist'
$to.'.dist'
));
continue;
}
if (!copy($fromPath, $toPath)) {
if (! copy($fromPath, $toPath)) {
$this->output->writeln(sprintf(
'<fg=black;bg=red>[WARNING] Failed to copy stub `%s` to `%s`</>',
$from,

View File

@ -18,7 +18,7 @@ final class Printer implements HandlesArguments
*/
public function handleArguments(array $arguments): array
{
if (!array_key_exists('COLLISION_PRINTER', $_SERVER)) {
if (! array_key_exists('COLLISION_PRINTER', $_SERVER)) {
return $arguments;
}

View File

@ -5,9 +5,7 @@ declare(strict_types=1);
namespace Pest\Plugins;
use Pest\Contracts\Plugins\HandlesArguments;
use function Pest\version;
use Symfony\Component\Console\Output\OutputInterface;
/**

View File

@ -9,9 +9,7 @@ use Pest\Exceptions\DatasetAlreadyExist;
use Pest\Exceptions\DatasetDoesNotExist;
use Pest\Exceptions\ShouldNotHappen;
use SebastianBergmann\Exporter\Exporter;
use function sprintf;
use Traversable;
/**
@ -54,12 +52,12 @@ final class DatasetsRepository
*/
public static function with(string $filename, string $description, array $with): void
{
self::$withs[$filename . '>>>' . $description] = $with;
self::$withs[$filename.'>>>'.$description] = $with;
}
public static function has(string $filename, string $description): bool
{
return array_key_exists($filename . '>>>' . $description, self::$withs);
return array_key_exists($filename.'>>>'.$description, self::$withs);
}
/**
@ -69,7 +67,7 @@ final class DatasetsRepository
*/
public static function get(string $filename, string $description): Closure|iterable
{
$dataset = self::$withs[$filename . '>>>' . $description];
$dataset = self::$withs[$filename.'>>>'.$description];
$dataset = self::resolve($description, $dataset);
@ -84,7 +82,6 @@ final class DatasetsRepository
* Resolves the current dataset to an array value.
*
* @param array<Closure|iterable<int|string, mixed>|string> $dataset
*
* @return array<string, mixed>|null
*/
public static function resolve(string $description, array $dataset): array|null
@ -137,7 +134,6 @@ final class DatasetsRepository
/**
* @param array<Closure|iterable<int|string, mixed>|string> $datasets
*
* @return array<array<mixed>>
*/
private static function processDatasets(array $datasets): array
@ -148,7 +144,7 @@ final class DatasetsRepository
$processedDataset = [];
if (is_string($data)) {
if (!array_key_exists($data, self::$datasets)) {
if (! array_key_exists($data, self::$datasets)) {
throw new DatasetDoesNotExist($data);
}
@ -180,7 +176,6 @@ final class DatasetsRepository
/**
* @param array<array<mixed>> $combinations
*
* @return array<array<array<mixed>>>
*/
private static function getDatasetsCombinations(array $combinations): array

View File

@ -9,7 +9,7 @@ namespace Pest\Repositories;
*/
final class TempRepository
{
private const FOLDER = __DIR__ . '/../../.temp';
private const FOLDER = __DIR__.'/../../.temp';
/**
* Creates a new Temp Repository instance.
@ -35,7 +35,7 @@ final class TempRepository
*/
public function boot(): void
{
@unlink(self::FOLDER . '/' . $this->filename . '.json'); // @phpstan-ignore-line
@unlink(self::FOLDER.'/'.$this->filename.'.json'); // @phpstan-ignore-line
$this->save([]);
}
@ -55,7 +55,7 @@ final class TempRepository
*/
private function all(): array
{
$contents = file_get_contents(self::FOLDER . '/' . $this->filename . '.json');
$contents = file_get_contents(self::FOLDER.'/'.$this->filename.'.json');
assert(is_string($contents));
@ -73,6 +73,6 @@ final class TempRepository
{
$contents = json_encode($elements);
file_put_contents(self::FOLDER . '/' . $this->filename . '.json', $contents);
file_put_contents(self::FOLDER.'/'.$this->filename.'.json', $contents);
}
}

View File

@ -62,7 +62,7 @@ final class TestRepository
public function use(array $classOrTraits, array $groups, array $paths, array $hooks): void
{
foreach ($classOrTraits as $classOrTrait) {
if (!class_exists($classOrTrait) && !trait_exists($classOrTrait)) {
if (! class_exists($classOrTrait) && ! trait_exists($classOrTrait)) {
throw new TestCaseClassOrTraitNotFound($classOrTrait);
}
}
@ -90,7 +90,7 @@ final class TestRepository
*/
public function set(TestCaseMethodFactory $method): void
{
if (!array_key_exists($method->filename, $this->testCases)) {
if (! array_key_exists($method->filename, $this->testCases)) {
$this->testCases[$method->filename] = new TestCaseFactory($method->filename);
}
@ -112,12 +112,12 @@ final class TestRepository
*/
private function make(TestCaseFactory $testCase): void
{
$startsWith = static fn (string $target, string $directory): bool => Str::startsWith($target, $directory . DIRECTORY_SEPARATOR);
$startsWith = static fn (string $target, string $directory): bool => Str::startsWith($target, $directory.DIRECTORY_SEPARATOR);
foreach ($this->uses as $path => $uses) {
[$classOrTraits, $groups, $hooks] = $uses;
if ((!is_dir($path) && $testCase->filename === $path) || (is_dir($path) && $startsWith($testCase->filename, $path))) {
if ((! is_dir($path) && $testCase->filename === $path) || (is_dir($path) && $startsWith($testCase->filename, $path))) {
foreach ($classOrTraits as $class) {
/** @var string $class */
if (class_exists($class)) {

View File

@ -46,7 +46,7 @@ final class Arr
return $array[$key];
}
if (!str_contains($key, '.')) {
if (! str_contains($key, '.')) {
return $array[$key] ?? $default;
}
@ -65,7 +65,6 @@ final class Arr
* Flatten a multi-dimensional associative array with dots.
*
* @param array<array-key, mixed> $array
*
* @return array<int|string, mixed>
*/
public static function dot(array $array, string $prepend = ''): array
@ -74,9 +73,9 @@ final class Arr
foreach ($array as $key => $value) {
if (is_array($value) && count($value) > 0) {
$results = array_merge($results, static::dot($value, $prepend . $key . '.'));
$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
} else {
$results[$prepend . $value] = $value;
$results[$prepend.$value] = $value;
}
}

View File

@ -18,7 +18,7 @@ final class ChainableClosure
public static function from(Closure $closure, Closure $next): Closure
{
return function () use ($closure, $next): void {
if (!is_object($this)) { // @phpstan-ignore-line
if (! is_object($this)) { // @phpstan-ignore-line
throw ShouldNotHappen::fromMessage('$this not bound to chainable closure.');
}

View File

@ -36,12 +36,11 @@ final class Container
* Gets a dependency from the container.
*
* @param class-string $id
*
* @return mixed
*/
public function get(string $id)
{
if (!array_key_exists($id, $this->instances)) {
if (! array_key_exists($id, $this->instances)) {
$this->instances[$id] = $this->build($id);
}

View File

@ -11,7 +11,6 @@ use SebastianBergmann\CodeCoverage\Node\File;
use SebastianBergmann\Environment\Runtime;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Terminal;
use function Termwind\render;
use function Termwind\renderUsing;
@ -54,7 +53,7 @@ final class Coverage
*/
public static function report(OutputInterface $output): float
{
if (!file_exists($reportPath = self::getPath())) {
if (! file_exists($reportPath = self::getPath())) {
if (self::usingXdebug()) {
$output->writeln(
" <fg=black;bg=yellow;options=bold> WARN </> Unable to get coverage using Xdebug. Did you set <href=https://xdebug.org/docs/code_coverage#mode>Xdebug's coverage mode</>?</>",
@ -80,7 +79,7 @@ final class Coverage
$report = $codeCoverage->getReport();
foreach ($report->getIterator() as $file) {
if (!$file instanceof File) {
if (! $file instanceof File) {
continue;
}
$dirname = dirname($file->id());
@ -106,7 +105,7 @@ final class Coverage
? '100.0'
: number_format($file->percentageOfExecutedLines()->asFloat(), 1, '.', '');
$takenSize = strlen($rawName . $percentage) + 2 + $linesExecutedTakenSize; // adding 3 space and percent sign
$takenSize = strlen($rawName.$percentage) + 2 + $linesExecutedTakenSize; // adding 3 space and percent sign
$percentage = sprintf(
'<fg=%s>%s</>',
@ -147,7 +146,6 @@ final class Coverage
* ```
*
* @param File $file
*
* @return array<int, string>
*/
public static function getMissingCoverage($file): array

View File

@ -44,7 +44,7 @@ final class ExceptionTrace
*/
public static function removePestReferences(Throwable $t): void
{
if (!property_exists($t, 'serializableTrace')) {
if (! property_exists($t, 'serializableTrace')) {
return;
}

View File

@ -26,7 +26,6 @@ final class HigherOrderCallables
* Create a new expectation. Callable values will be executed prior to returning the new expectation.
*
* @param (Closure():TValue)|TValue $value
*
* @return Expectation<TValue>
*/
public function expect(mixed $value): Expectation
@ -43,7 +42,6 @@ final class HigherOrderCallables
* Create a new expectation. Callable values will be executed prior to returning the new expectation.
*
* @param callable|TValue $value
*
* @return Expectation<(callable(): mixed)|TValue>
*/
public function and(mixed $value)

View File

@ -61,7 +61,6 @@ final class HigherOrderTapProxy
* Dynamically pass method calls to the target.
*
* @param array<int, mixed> $arguments
*
* @return mixed
*/
public function __call(string $methodName, array $arguments)

View File

@ -33,7 +33,7 @@ abstract class Printer implements \PHPUnit\Util\Printer
$this->isPhpStream = str_starts_with($out, 'php://');
if (!$this->isPhpStream && !Filesystem::createDirectory(dirname($out))) {
if (! $this->isPhpStream && ! Filesystem::createDirectory(dirname($out))) {
throw new Exception(sprintf('Directory "%s" was not created', dirname($out)));
}

View File

@ -23,7 +23,6 @@ final class Reflection
* Calls the given method with args on the given object.
*
* @param array<int, mixed> $args
*
* @return mixed
*/
public static function call(object $object, string $method, array $args = [])
@ -53,7 +52,6 @@ final class Reflection
* Bind a callable to the TestCase and return the result.
*
* @param array<int, mixed> $args
*
* @return mixed
*/
public static function bindCallable(callable $callable, array $args = [])
@ -104,7 +102,7 @@ final class Reflection
} catch (ReflectionException $reflectionException) {
$reflectionClass = $reflectionClass->getParentClass();
if (!$reflectionClass instanceof ReflectionClass) {
if (! $reflectionClass instanceof ReflectionClass) {
throw new ShouldNotHappen($reflectionException);
}
}
@ -137,7 +135,7 @@ final class Reflection
} catch (ReflectionException $reflectionException) {
$reflectionClass = $reflectionClass->getParentClass();
if (!$reflectionClass instanceof ReflectionClass) {
if (! $reflectionClass instanceof ReflectionClass) {
throw new ShouldNotHappen($reflectionException);
}
}
@ -156,7 +154,7 @@ final class Reflection
{
$type = $parameter->getType();
if (!$type instanceof ReflectionNamedType || $type->isBuiltin()) {
if (! $type instanceof ReflectionNamedType || $type->isBuiltin()) {
return null;
}

View File

@ -1,6 +1,6 @@
<?php
$file = __DIR__ . DIRECTORY_SEPARATOR . 'after-all-test';
$file = __DIR__.DIRECTORY_SEPARATOR.'after-all-test';
beforeAll(function () use ($file) {
@unlink($file);

View File

@ -35,7 +35,8 @@ 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
{
return [

View File

@ -148,7 +148,7 @@ $datasets_a = [[1], [2]];
$datasets_b = [[3], [4]];
test('lazy multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) {
$state->text .= $text_a . $text_b;
$state->text .= $text_a.$text_b;
expect($datasets_a)->toContain([$text_a]);
expect($datasets_b)->toContain([$text_b]);
})->with($datasets_a, $datasets_b);
@ -160,7 +160,7 @@ test('lazy multiple datasets did the job right', function () use ($state) {
$state->text = '';
test('eager multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) {
$state->text .= $text_a . $text_b;
$state->text .= $text_a.$text_b;
expect($datasets_a)->toContain([$text_a]);
expect($datasets_b)->toContain([$text_b]);
})->with(function () use ($datasets_a) {
@ -174,7 +174,7 @@ test('eager multiple datasets did the job right', function () use ($state) {
});
test('lazy registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) {
$state->text .= $text_a . $text_b;
$state->text .= $text_a.$text_b;
expect($datasets)->toContain([$text_a]);
expect($datasets)->toContain([$text_b]);
})->with('numbers.array')->with('numbers.array');
@ -184,7 +184,7 @@ test('lazy registered multiple datasets did the job right', function () use ($st
});
test('eager registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) {
$state->text .= $text_a . $text_b;
$state->text .= $text_a.$text_b;
expect($datasets)->toContain([$text_a]);
expect($datasets)->toContain([$text_b]);
})->with('numbers.array')->with('numbers.closure');
@ -194,7 +194,7 @@ test('eager registered multiple datasets did the job right', function () use ($s
});
test('eager wrapped registered multiple datasets', function ($text_a, $text_b) use ($state, $datasets) {
$state->text .= $text_a . $text_b;
$state->text .= $text_a.$text_b;
expect($datasets)->toContain([$text_a]);
expect($datasets)->toContain([$text_b]);
})->with('numbers.closure.wrapped')->with('numbers.closure');
@ -204,7 +204,7 @@ test('eager wrapped registered multiple datasets did the job right', function ()
});
test('named multiple datasets', function ($text_a, $text_b) use ($state, $datasets_a, $datasets_b) {
$state->text .= $text_a . $text_b;
$state->text .= $text_a.$text_b;
expect($datasets_a)->toContain([$text_a]);
expect($datasets_b)->toContain([$text_b]);
})->with([
@ -220,7 +220,7 @@ test('named multiple datasets did the job right', function () use ($state) {
});
test('more than two datasets', function ($text_a, $text_b, $text_c) use ($state, $datasets_a, $datasets_b) {
$state->text .= $text_a . $text_b . $text_c;
$state->text .= $text_a.$text_b.$text_c;
expect($datasets_a)->toContain([$text_a]);
expect($datasets_b)->toContain([$text_b]);
expect([5, 6])->toContain($text_c);

View File

@ -3,7 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
touch($this->tempFile = sys_get_temp_dir().'/fake.file');
});
afterEach(function () {

View File

@ -3,7 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
touch($this->tempFile = sys_get_temp_dir().'/fake.file');
});
afterEach(function () {

View File

@ -3,7 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
touch($this->tempFile = sys_get_temp_dir() . '/fake.file');
touch($this->tempFile = sys_get_temp_dir().'/fake.file');
});
afterEach(function () {

View File

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

View File

@ -38,13 +38,13 @@ test('passes', function () {
test('failures 1', function () {
expect(function () {
})->toThrow(RuntimeException::class);
})->throws(ExpectationFailedException::class, 'Exception "' . RuntimeException::class . '" not thrown.');
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
test('failures 2', function () {
expect(function () {
})->toThrow(function (RuntimeException $e) {
});
})->throws(ExpectationFailedException::class, 'Exception "' . RuntimeException::class . '" not thrown.');
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
test('failures 3', function () {
expect(function () {

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Tests\CustomTestCase;
use function PHPUnit\Framework\assertTrue;
use PHPUnit\Framework\TestCase;
abstract class CustomTestCase extends TestCase

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Tests\CustomTestCase;
use function PHPUnit\Framework\assertTrue;
use PHPUnit\Framework\TestCase;
class ExecutedTest extends TestCase

View File

@ -1,9 +1,7 @@
<?php
use Pest\Plugins\Version;
use function Pest\version;
use Symfony\Component\Console\Output\BufferedOutput;
it('outputs the version when --version is used', function () {
@ -11,7 +9,7 @@ it('outputs the version when --version is used', function () {
$plugin = new Version($output);
$plugin->handleArguments(['foo', '--version']);
expect($output->fetch())->toContain('Pest ' . version());
expect($output->fetch())->toContain('Pest '.version());
});
it('do not outputs version when --version is not used', function () {

View File

@ -10,7 +10,8 @@ it('gets file name from closure', function () {
});
it('gets property values', function () {
$class = new class() {
$class = new class()
{
private $foo = 'bar';
};

View File

@ -4,7 +4,7 @@ use Pest\Console\Help;
use Symfony\Component\Console\Output\BufferedOutput;
test('visual snapshot of help command output', function () {
$snapshot = __DIR__ . '/../.snapshots/help-command.txt';
$snapshot = __DIR__.'/../.snapshots/help-command.txt';
if (getenv('REBUILD_SNAPSHOTS')) {
$outputBuffer = new BufferedOutput();

View File

@ -6,11 +6,11 @@ use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
beforeEach(function () {
file_put_contents(__DIR__ . '/junit.html', '');
file_put_contents(__DIR__.'/junit.html', '');
});
it('is can successfully call all public methods', function () {
$junit = new JUnit(__DIR__ . '/junit.html');
$junit = new JUnit(__DIR__.'/junit.html');
$junit->startTestSuite(new TestSuite());
$junit->startTest($this);
$junit->addError($this, new Exception(), 0);
@ -25,5 +25,5 @@ it('is can successfully call all public methods', function () {
})->skip('Not supported yet.');
afterEach(function () {
unlink(__DIR__ . '/junit.html');
unlink(__DIR__.'/junit.html');
});

View File

@ -31,12 +31,12 @@ test('visual snapshot of test suite on success', function () {
$outputContent = preg_replace('/Time\: \s+\d+\.\d+s\s+/m', '', $output());
file_put_contents($snapshot, $outputContent);
} elseif (!getenv('EXCLUDE')) {
} elseif (! getenv('EXCLUDE')) {
$output = explode("\n", $output());
array_pop($output);
array_pop($output);
expect(implode("\n", $output))->toContain(file_get_contents($snapshot));
}
})->skip(!getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
})->skip(! getenv('REBUILD_SNAPSHOTS') && getenv('EXCLUDE'))
->skip(PHP_OS_FAMILY === 'Windows');

View File

@ -8,11 +8,11 @@ use PHPUnit\Framework\Warning;
use PHPUnit\TextUI\DefaultResultPrinter;
beforeEach(function () {
file_put_contents(__DIR__ . '/output.txt', '');
file_put_contents(__DIR__.'/output.txt', '');
});
it('is can successfully call all public methods', function () {
$teamCity = new TeamCity(__DIR__ . '/output.txt', false, DefaultResultPrinter::COLOR_ALWAYS);
$teamCity = new TeamCity(__DIR__.'/output.txt', false, DefaultResultPrinter::COLOR_ALWAYS);
expect($teamCity::isPestTest($this))->toBeTrue();
$teamCity->startTestSuite(new TestSuite());
$teamCity->startTest($this);
@ -28,5 +28,5 @@ it('is can successfully call all public methods', function () {
})->skip('Not supported yet.');
afterEach(function () {
unlink(__DIR__ . '/output.txt');
unlink(__DIR__.'/output.txt');
});