This commit is contained in:
Nuno Maduro
2024-07-24 21:54:52 +01:00
parent 101e26749a
commit 45cce6ce93
57 changed files with 131 additions and 131 deletions

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

@ -65,7 +65,7 @@ final class Configuration
*/
public function theme(): Configuration\Theme
{
return new Configuration\Theme();
return new Configuration\Theme;
}
/**
@ -73,6 +73,6 @@ final class Configuration
*/
public function context(): Configuration\Context
{
return new Configuration\Context();
return new Configuration\Context;
}
}

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

@ -424,7 +424,7 @@ final class Expectation
*/
public function any(): Any
{
return new Any();
return new Any;
}
/**

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

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

View File

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

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();
@ -654,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

@ -47,8 +47,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

@ -97,7 +97,7 @@ final class TestCall
$closure->call($this);
};
new AfterEachCall($this->testSuite, $this->filename, $when->bindTo(new \stdClass()));
new AfterEachCall($this->testSuite, $this->filename, $when->bindTo(new \stdClass));
return $this;
}

View File

@ -53,7 +53,7 @@ final class Configuration implements HandlesArguments, Terminable
unlink($path);
}
$doc = new DOMDocument();
$doc = new DOMDocument;
$doc->load(self::BASE_PHPUNIT_FILE);
$contents = $doc->saveXML();

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;
@ -127,7 +127,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);
}
@ -174,7 +174,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

@ -169,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

@ -106,13 +106,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];
@ -125,7 +125,7 @@ final class WrapperRunner implements RunnerInterface
$parameters[] = $wrapper;
$this->parameters = $parameters;
$this->codeCoverageFilterRegistry = new CodeCoverageFilterRegistry();
$this->codeCoverageFilterRegistry = new CodeCoverageFilterRegistry;
}
public function run(): int
@ -372,7 +372,7 @@ final class WrapperRunner implements RunnerInterface
return;
}
$coverageManager = new CodeCoverage();
$coverageManager = new CodeCoverage;
$coverageManager->init(
$this->options->configuration,
$this->codeCoverageFilterRegistry,
@ -404,8 +404,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

@ -29,7 +29,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

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

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

@ -85,7 +85,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

@ -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

@ -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]];
@ -130,7 +130,7 @@ class Bar
}
$namedDatasets = [
new Bar(),
new Bar,
];
test('lazy named datasets', function ($text) {
@ -143,12 +143,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) {
@ -241,7 +241,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

@ -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

@ -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

@ -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

@ -6,13 +6,13 @@ 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();
throw new RuntimeException;
})->toThrow(function (RuntimeException $e) {});
expect(function () {
throw new RuntimeException('actual message');
@ -24,7 +24,7 @@ test('passes', 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');
@ -47,7 +47,7 @@ test('failures 2', function () {
test('failures 3', function () {
expect(function () {
throw new Exception();
throw new Exception;
})->toThrow(function (RuntimeException $e) {
//
});
@ -92,7 +92,7 @@ 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);
@ -106,16 +106,16 @@ test('closure missing type-hint', function () {
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

@ -4,7 +4,7 @@ use Pest\Console\Help;
use Symfony\Component\Console\Output\BufferedOutput;
it('outputs the help information when --help is used', function () {
$output = new BufferedOutput();
$output = new BufferedOutput;
$plugin = new Help($output);
$plugin();

View File

@ -5,7 +5,7 @@ use Pest\Plugins\Environment;
test('environment is set to CI when --ci option is used', function () {
$previousName = Environment::name();
$plugin = new Environment();
$plugin = new Environment;
$plugin->handleArguments(['foo', '--ci', 'bar']);
@ -15,7 +15,7 @@ test('environment is set to CI when --ci option is used', function () {
});
test('environment is set to Local when --ci option is not used', function () {
$plugin = new Environment();
$plugin = new Environment;
$plugin->handleArguments(['foo', 'bar', 'baz']);

View File

@ -3,7 +3,7 @@
use Pest\Plugins\Retry;
it('orders by defects and stop on defects if when --retry is used ', function () {
$retry = new Retry();
$retry = new Retry;
$arguments = $retry->handleArguments(['--retry']);

View File

@ -7,7 +7,7 @@ use Pest\TestSuite;
uses()->group('container');
beforeEach(function () {
$this->container = new Container();
$this->container = new Container;
});
it('exists')

View File

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