mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
chore: style changes
This commit is contained in:
@ -12,7 +12,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
|||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
$bootPest = (static function (): void {
|
$bootPest = (static function (): void {
|
||||||
$workerArgv = new ArgvInput();
|
$workerArgv = new ArgvInput;
|
||||||
|
|
||||||
$rootPath = dirname(PHPUNIT_COMPOSER_INSTALL, 2);
|
$rootPath = dirname(PHPUNIT_COMPOSER_INSTALL, 2);
|
||||||
$testSuite = TestSuite::getInstance($rootPath, $workerArgv->getParameterOption(
|
$testSuite = TestSuite::getInstance($rootPath, $workerArgv->getParameterOption(
|
||||||
@ -20,7 +20,7 @@ $bootPest = (static function (): void {
|
|||||||
'tests'
|
'tests'
|
||||||
));
|
));
|
||||||
|
|
||||||
$input = new ArgvInput();
|
$input = new ArgvInput;
|
||||||
|
|
||||||
$output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true);
|
$output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true);
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ final class Thanks
|
|||||||
$wantsToSupport = false;
|
$wantsToSupport = false;
|
||||||
|
|
||||||
if (getenv('PEST_NO_SUPPORT') !== 'true' && $this->input->isInteractive()) {
|
if (getenv('PEST_NO_SUPPORT') !== 'true' && $this->input->isInteractive()) {
|
||||||
$wantsToSupport = (new SymfonyQuestionHelper())->ask(
|
$wantsToSupport = (new SymfonyQuestionHelper)->ask(
|
||||||
new ArrayInput([]),
|
new ArrayInput([]),
|
||||||
$this->output,
|
$this->output,
|
||||||
new ConfirmationQuestion(
|
new ConfirmationQuestion(
|
||||||
|
|||||||
@ -421,7 +421,7 @@ final class Expectation
|
|||||||
*/
|
*/
|
||||||
public function any(): Any
|
public function any(): Any
|
||||||
{
|
{
|
||||||
return new Any();
|
return new Any;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -28,8 +28,8 @@ trait HigherOrderable
|
|||||||
*/
|
*/
|
||||||
private function bootHigherOrderable(): void
|
private function bootHigherOrderable(): void
|
||||||
{
|
{
|
||||||
$this->chains = new HigherOrderMessageCollection();
|
$this->chains = new HigherOrderMessageCollection;
|
||||||
$this->factoryProxies = new HigherOrderMessageCollection();
|
$this->factoryProxies = new HigherOrderMessageCollection;
|
||||||
$this->proxies = new HigherOrderMessageCollection();
|
$this->proxies = new HigherOrderMessageCollection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,7 +154,7 @@ final class TestCaseFactory
|
|||||||
foreach ($classAvailableAttributes as $attribute) {
|
foreach ($classAvailableAttributes as $attribute) {
|
||||||
$classAttributes = array_reduce(
|
$classAttributes = array_reduce(
|
||||||
$methods,
|
$methods,
|
||||||
fn (array $carry, TestCaseMethodFactory $methodFactory): array => (new $attribute())->__invoke($methodFactory, $carry),
|
fn (array $carry, TestCaseMethodFactory $methodFactory): array => (new $attribute)->__invoke($methodFactory, $carry),
|
||||||
$classAttributes
|
$classAttributes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,11 +138,11 @@ final class TestCaseMethodFactory
|
|||||||
$attributes = [];
|
$attributes = [];
|
||||||
|
|
||||||
foreach ($annotationsToUse as $annotation) {
|
foreach ($annotationsToUse as $annotation) {
|
||||||
$annotations = (new $annotation())->__invoke($this, $annotations);
|
$annotations = (new $annotation)->__invoke($this, $annotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($attributesToUse as $attribute) {
|
foreach ($attributesToUse as $attribute) {
|
||||||
$attributes = (new $attribute())->__invoke($this, $attributes);
|
$attributes = (new $attribute)->__invoke($this, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->datasets !== [] || $this->repetitions > 1) {
|
if ($this->datasets !== [] || $this->repetitions > 1) {
|
||||||
|
|||||||
@ -67,7 +67,7 @@ final class Kernel
|
|||||||
->add(Container::class, $container);
|
->add(Container::class, $container);
|
||||||
|
|
||||||
$kernel = new self(
|
$kernel = new self(
|
||||||
new Application(),
|
new Application,
|
||||||
$output,
|
$output,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ final class Converter
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly string $rootPath,
|
private readonly string $rootPath,
|
||||||
) {
|
) {
|
||||||
$this->stateGenerator = new StateGenerator();
|
$this->stateGenerator = new StateGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -314,7 +314,7 @@ final class Expectation
|
|||||||
*
|
*
|
||||||
* @return self<TValue>
|
* @return self<TValue>
|
||||||
*/
|
*/
|
||||||
public function toHaveProperty(string $name, mixed $value = new Any(), string $message = ''): self
|
public function toHaveProperty(string $name, mixed $value = new Any, string $message = ''): self
|
||||||
{
|
{
|
||||||
$this->toBeObject();
|
$this->toBeObject();
|
||||||
|
|
||||||
@ -654,7 +654,7 @@ final class Expectation
|
|||||||
*
|
*
|
||||||
* @return self<TValue>
|
* @return self<TValue>
|
||||||
*/
|
*/
|
||||||
public function toHaveKey(string|int $key, mixed $value = new Any(), string $message = ''): self
|
public function toHaveKey(string|int $key, mixed $value = new Any, string $message = ''): self
|
||||||
{
|
{
|
||||||
if (is_object($this->value) && method_exists($this->value, 'toArray')) {
|
if (is_object($this->value) && method_exists($this->value, 'toArray')) {
|
||||||
$array = $this->value->toArray();
|
$array = $this->value->toArray();
|
||||||
|
|||||||
@ -42,7 +42,7 @@ final class Panic
|
|||||||
try {
|
try {
|
||||||
$output = Container::getInstance()->get(OutputInterface::class);
|
$output = Container::getInstance()->get(OutputInterface::class);
|
||||||
} catch (Throwable) { // @phpstan-ignore-line
|
} catch (Throwable) { // @phpstan-ignore-line
|
||||||
$output = new ConsoleOutput();
|
$output = new ConsoleOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert($output instanceof OutputInterface);
|
assert($output instanceof OutputInterface);
|
||||||
|
|||||||
@ -39,7 +39,7 @@ final class AfterEachCall
|
|||||||
) {
|
) {
|
||||||
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
||||||
|
|
||||||
$this->proxies = new HigherOrderMessageCollection();
|
$this->proxies = new HigherOrderMessageCollection;
|
||||||
|
|
||||||
$this->describing = DescribeCall::describing();
|
$this->describing = DescribeCall::describing();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,8 +44,8 @@ final class BeforeEachCall
|
|||||||
) {
|
) {
|
||||||
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
$this->closure = $closure instanceof Closure ? $closure : NullClosure::create();
|
||||||
|
|
||||||
$this->testCallProxies = new HigherOrderMessageCollection();
|
$this->testCallProxies = new HigherOrderMessageCollection;
|
||||||
$this->testCaseProxies = new HigherOrderMessageCollection();
|
$this->testCaseProxies = new HigherOrderMessageCollection;
|
||||||
|
|
||||||
$this->describing = DescribeCall::describing();
|
$this->describing = DescribeCall::describing();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -369,7 +369,7 @@ final class TestCall
|
|||||||
*/
|
*/
|
||||||
public function coversNothing(): self
|
public function coversNothing(): self
|
||||||
{
|
{
|
||||||
$this->testCaseMethod->covers = [new CoversNothing()];
|
$this->testCaseMethod->covers = [new CoversNothing];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,7 +97,7 @@ final class Help implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
private function getContent(): array
|
private function getContent(): array
|
||||||
{
|
{
|
||||||
$helpReflection = new PHPUnitHelp();
|
$helpReflection = new PHPUnitHelp;
|
||||||
|
|
||||||
$content = (fn (): array => $this->elements())->call($helpReflection);
|
$content = (fn (): array => $this->elements())->call($helpReflection);
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ final class Parallel implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
public static function isEnabled(): bool
|
public static function isEnabled(): bool
|
||||||
{
|
{
|
||||||
$argv = new ArgvInput();
|
$argv = new ArgvInput;
|
||||||
if ($argv->hasParameterOption('--parallel')) {
|
if ($argv->hasParameterOption('--parallel')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ final class Parallel implements HandlesArguments
|
|||||||
$arguments
|
$arguments
|
||||||
);
|
);
|
||||||
|
|
||||||
$exitCode = $this->paratestCommand()->run(new ArgvInput($filteredArguments), new CleanConsoleOutput());
|
$exitCode = $this->paratestCommand()->run(new ArgvInput($filteredArguments), new CleanConsoleOutput);
|
||||||
|
|
||||||
return CallsAddsOutput::execute($exitCode);
|
return CallsAddsOutput::execute($exitCode);
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ final class Parallel implements HandlesArguments
|
|||||||
*/
|
*/
|
||||||
private function hasArgumentsThatWouldBeFasterWithoutParallel(): bool
|
private function hasArgumentsThatWouldBeFasterWithoutParallel(): bool
|
||||||
{
|
{
|
||||||
$arguments = new ArgvInput();
|
$arguments = new ArgvInput;
|
||||||
|
|
||||||
foreach (self::UNSUPPORTED_ARGUMENTS as $unsupportedArgument) {
|
foreach (self::UNSUPPORTED_ARGUMENTS as $unsupportedArgument) {
|
||||||
if ($arguments->hasParameterOption($unsupportedArgument)) {
|
if ($arguments->hasParameterOption($unsupportedArgument)) {
|
||||||
|
|||||||
@ -169,7 +169,7 @@ final class ResultPrinter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$state = (new StateGenerator())->fromPhpUnitTestResult($this->passedTests, $testResult);
|
$state = (new StateGenerator)->fromPhpUnitTestResult($this->passedTests, $testResult);
|
||||||
|
|
||||||
$this->compactPrinter->errors($state);
|
$this->compactPrinter->errors($state);
|
||||||
$this->compactPrinter->recap($state, $testResult, $duration, $this->options);
|
$this->compactPrinter->recap($state, $testResult, $duration, $this->options);
|
||||||
|
|||||||
@ -91,13 +91,13 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
private readonly OutputInterface $output
|
private readonly OutputInterface $output
|
||||||
) {
|
) {
|
||||||
$this->printer = new ResultPrinter($output, $options);
|
$this->printer = new ResultPrinter($output, $options);
|
||||||
$this->timer = new Timer();
|
$this->timer = new Timer;
|
||||||
|
|
||||||
$wrapper = realpath(
|
$wrapper = realpath(
|
||||||
dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'worker.php',
|
dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'worker.php',
|
||||||
);
|
);
|
||||||
assert($wrapper !== false);
|
assert($wrapper !== false);
|
||||||
$phpFinder = new PhpExecutableFinder();
|
$phpFinder = new PhpExecutableFinder;
|
||||||
$phpBin = $phpFinder->find(false);
|
$phpBin = $phpFinder->find(false);
|
||||||
assert($phpBin !== false);
|
assert($phpBin !== false);
|
||||||
$parameters = [$phpBin];
|
$parameters = [$phpBin];
|
||||||
@ -110,7 +110,7 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
$parameters[] = $wrapper;
|
$parameters[] = $wrapper;
|
||||||
|
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
$this->codeCoverageFilterRegistry = new CodeCoverageFilterRegistry();
|
$this->codeCoverageFilterRegistry = new CodeCoverageFilterRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(): int
|
public function run(): int
|
||||||
@ -357,7 +357,7 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$coverageManager = new CodeCoverage();
|
$coverageManager = new CodeCoverage;
|
||||||
$coverageManager->init(
|
$coverageManager->init(
|
||||||
$this->options->configuration,
|
$this->options->configuration,
|
||||||
$this->codeCoverageFilterRegistry,
|
$this->codeCoverageFilterRegistry,
|
||||||
@ -389,8 +389,8 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$testSuite = (new LogMerger())->merge($this->junitFiles);
|
$testSuite = (new LogMerger)->merge($this->junitFiles);
|
||||||
(new Writer())->write(
|
(new Writer)->write(
|
||||||
$testSuite,
|
$testSuite,
|
||||||
$this->options->configuration->logfileJunit(),
|
$this->options->configuration->logfileJunit(),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -26,7 +26,7 @@ final class Container
|
|||||||
public static function getInstance(): self
|
public static function getInstance(): self
|
||||||
{
|
{
|
||||||
if (! self::$instance instanceof \Pest\Support\Container) {
|
if (! self::$instance instanceof \Pest\Support\Container) {
|
||||||
self::$instance = new self();
|
self::$instance = new self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ final class Coverage
|
|||||||
*/
|
*/
|
||||||
public static function isAvailable(): bool
|
public static function isAvailable(): bool
|
||||||
{
|
{
|
||||||
$runtime = new Runtime();
|
$runtime = new Runtime;
|
||||||
|
|
||||||
if (! $runtime->canCollectCodeCoverage()) {
|
if (! $runtime->canCollectCodeCoverage()) {
|
||||||
return false;
|
return false;
|
||||||
@ -67,7 +67,7 @@ final class Coverage
|
|||||||
*/
|
*/
|
||||||
public static function usingXdebug(): bool
|
public static function usingXdebug(): bool
|
||||||
{
|
{
|
||||||
return (new Runtime())->hasXdebug();
|
return (new Runtime)->hasXdebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -32,7 +32,7 @@ final class Exporter
|
|||||||
public static function default(): self
|
public static function default(): self
|
||||||
{
|
{
|
||||||
return new self(
|
return new self(
|
||||||
new BaseExporter()
|
new BaseExporter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ final class Exporter
|
|||||||
$array = $data;
|
$array = $data;
|
||||||
$itemsCount = 0;
|
$itemsCount = 0;
|
||||||
$exporter = self::default();
|
$exporter = self::default();
|
||||||
$context ??= new Context();
|
$context ??= new Context;
|
||||||
|
|
||||||
$context->add($data);
|
$context->add($data);
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ final class StateGenerator
|
|||||||
{
|
{
|
||||||
public function fromPhpUnitTestResult(int $passedTests, PHPUnitTestResult $testResult): State
|
public function fromPhpUnitTestResult(int $passedTests, PHPUnitTestResult $testResult): State
|
||||||
{
|
{
|
||||||
$state = new State();
|
$state = new State;
|
||||||
|
|
||||||
foreach ($testResult->testErroredEvents() as $testResultEvent) {
|
foreach ($testResult->testErroredEvents() as $testResultEvent) {
|
||||||
if ($testResultEvent instanceof Errored) {
|
if ($testResultEvent instanceof Errored) {
|
||||||
|
|||||||
@ -76,7 +76,7 @@ final class GitDirtyTestCaseFilter implements TestCaseFilter
|
|||||||
$dirtyFiles = array_values($dirtyFiles);
|
$dirtyFiles = array_values($dirtyFiles);
|
||||||
|
|
||||||
if ($dirtyFiles === []) {
|
if ($dirtyFiles === []) {
|
||||||
Panic::with(new NoDirtyTestsFound());
|
Panic::with(new NoDirtyTestsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->changedFiles = $dirtyFiles;
|
$this->changedFiles = $dirtyFiles;
|
||||||
|
|||||||
@ -71,11 +71,11 @@ final class TestSuite
|
|||||||
string $rootPath,
|
string $rootPath,
|
||||||
public string $testPath,
|
public string $testPath,
|
||||||
) {
|
) {
|
||||||
$this->beforeAll = new BeforeAllRepository();
|
$this->beforeAll = new BeforeAllRepository;
|
||||||
$this->beforeEach = new BeforeEachRepository();
|
$this->beforeEach = new BeforeEachRepository;
|
||||||
$this->tests = new TestRepository();
|
$this->tests = new TestRepository;
|
||||||
$this->afterEach = new AfterEachRepository();
|
$this->afterEach = new AfterEachRepository;
|
||||||
$this->afterAll = new AfterAllRepository();
|
$this->afterAll = new AfterAllRepository;
|
||||||
$this->rootPath = (string) realpath($rootPath);
|
$this->rootPath = (string) realpath($rootPath);
|
||||||
$this->snapshots = new SnapshotRepository(
|
$this->snapshots = new SnapshotRepository(
|
||||||
implode(DIRECTORY_SEPARATOR, [$this->rootPath, $this->testPath]),
|
implode(DIRECTORY_SEPARATOR, [$this->rootPath, $this->testPath]),
|
||||||
@ -101,7 +101,7 @@ final class TestSuite
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! self::$instance instanceof self) {
|
if (! self::$instance instanceof self) {
|
||||||
Panic::with(new InvalidPestCommand());
|
Panic::with(new InvalidPestCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
|
|
||||||
beforeEach(function () use ($state) {
|
beforeEach(function () use ($state) {
|
||||||
$this->state = $state;
|
$this->state = $state;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$foo = new \stdClass();
|
$foo = new \stdClass;
|
||||||
$foo->bar = 0;
|
$foo->bar = 0;
|
||||||
|
|
||||||
beforeAll(function () use ($foo) {
|
beforeAll(function () use ($foo) {
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
|||||||
it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));
|
it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));
|
||||||
|
|
||||||
it('adds coverage if --coverage exist', function () {
|
it('adds coverage if --coverage exist', function () {
|
||||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
$plugin = new CoveragePlugin(new ConsoleOutput);
|
||||||
|
|
||||||
expect($plugin->coverage)->toBeFalse();
|
expect($plugin->coverage)->toBeFalse();
|
||||||
$arguments = $plugin->handleArguments([]);
|
$arguments = $plugin->handleArguments([]);
|
||||||
@ -20,7 +20,7 @@ it('adds coverage if --coverage exist', function () {
|
|||||||
})->skip(! \Pest\Support\Coverage::isAvailable() || ! function_exists('xdebug_info') || ! in_array('coverage', xdebug_info('mode'), true), 'Coverage is not available');
|
})->skip(! \Pest\Support\Coverage::isAvailable() || ! function_exists('xdebug_info') || ! in_array('coverage', xdebug_info('mode'), true), 'Coverage is not available');
|
||||||
|
|
||||||
it('adds coverage if --min exist', function () {
|
it('adds coverage if --min exist', function () {
|
||||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
$plugin = new CoveragePlugin(new ConsoleOutput);
|
||||||
expect($plugin->coverageMin)->toEqual(0.0)
|
expect($plugin->coverageMin)->toEqual(0.0)
|
||||||
->and($plugin->coverage)->toBeFalse();
|
->and($plugin->coverage)->toBeFalse();
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ it('adds coverage if --min exist', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('generates coverage based on file input', function () {
|
it('generates coverage based on file input', function () {
|
||||||
expect(Coverage::getMissingCoverage(new class()
|
expect(Coverage::getMissingCoverage(new class
|
||||||
{
|
{
|
||||||
public function lineCoverageData(): array
|
public function lineCoverageData(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@ -46,7 +46,7 @@ test('it truncates the description', function () {
|
|||||||
// it gets tested by the integration test
|
// it gets tested by the integration test
|
||||||
})->with([str_repeat('Fooo', 10)]);
|
})->with([str_repeat('Fooo', 10)]);
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
|
|
||||||
$datasets = [[1], [2]];
|
$datasets = [[1], [2]];
|
||||||
@ -119,7 +119,7 @@ class Bar
|
|||||||
}
|
}
|
||||||
|
|
||||||
$namedDatasets = [
|
$namedDatasets = [
|
||||||
new Bar(),
|
new Bar,
|
||||||
];
|
];
|
||||||
|
|
||||||
test('lazy named datasets', function ($text) {
|
test('lazy named datasets', function ($text) {
|
||||||
@ -132,12 +132,12 @@ it('creates unique test case names', function (string $name, Plugin $plugin, boo
|
|||||||
expect(true)->toBeTrue();
|
expect(true)->toBeTrue();
|
||||||
$counter++;
|
$counter++;
|
||||||
})->with([
|
})->with([
|
||||||
['Name 1', new Plugin(), true],
|
['Name 1', new Plugin, true],
|
||||||
['Name 1', new Plugin(), true],
|
['Name 1', new Plugin, true],
|
||||||
['Name 1', new Plugin(), false],
|
['Name 1', new Plugin, false],
|
||||||
['Name 2', new Plugin(), false],
|
['Name 2', new Plugin, false],
|
||||||
['Name 2', new Plugin(), true],
|
['Name 2', new Plugin, true],
|
||||||
['Name 1', new Plugin(), true],
|
['Name 1', new Plugin, true],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
it('creates unique test case names - count', function () use (&$counter) {
|
it('creates unique test case names - count', function () use (&$counter) {
|
||||||
@ -230,7 +230,7 @@ test('more than two datasets did the job right', function () use ($state) {
|
|||||||
expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246');
|
expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246');
|
||||||
});
|
});
|
||||||
|
|
||||||
$wrapped_generator_state = new stdClass();
|
$wrapped_generator_state = new stdClass;
|
||||||
$wrapped_generator_state->text = '';
|
$wrapped_generator_state->text = '';
|
||||||
$wrapped_generator_function_datasets = [1, 2, 3, 4];
|
$wrapped_generator_function_datasets = [1, 2, 3, 4];
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
it('gives access the the underlying expectException', function () {
|
it('gives access the the underlying expectException', function () {
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
throw new InvalidArgumentException();
|
throw new InvalidArgumentException;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('catch exceptions', function () {
|
it('catch exceptions', function () {
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
it('can access methods', function () {
|
it('can access methods', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->name()->toBeString()->toEqual('Has Methods');
|
->name()->toBeString()->toEqual('Has Methods');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can access multiple methods', function () {
|
it('can access multiple methods', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->name()->toBeString()->toEqual('Has Methods')
|
->name()->toBeString()->toEqual('Has Methods')
|
||||||
->quantity()->toBeInt()->toEqual(20);
|
->quantity()->toBeInt()->toEqual(20);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with not', function () {
|
it('works with not', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->name()->not->toEqual('world')->toEqual('Has Methods')
|
->name()->not->toEqual('world')->toEqual('Has Methods')
|
||||||
->quantity()->toEqual(20)->not()->toEqual('bar')->not->toBeNull;
|
->quantity()->toEqual(20)->not()->toEqual('bar')->not->toBeNull;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can accept arguments', function () {
|
it('can accept arguments', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->multiply(5, 4)->toBeInt->toEqual(20);
|
->multiply(5, 4)->toBeInt->toEqual(20);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with each', function () {
|
it('works with each', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->attributes()->toBeArray->each->not()->toBeNull
|
->attributes()->toBeArray->each->not()->toBeNull
|
||||||
->attributes()->each(function ($attribute) {
|
->attributes()->each(function ($attribute) {
|
||||||
$attribute->not->toBeNull();
|
$attribute->not->toBeNull();
|
||||||
@ -31,14 +31,14 @@ it('works with each', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works inside of each', function () {
|
it('works inside of each', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->books()->each(function ($book) {
|
->books()->each(function ($book) {
|
||||||
$book->title->not->toBeNull->cost->toBeGreaterThan(19);
|
$book->title->not->toBeNull->cost->toBeGreaterThan(19);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with sequence', function () {
|
it('works with sequence', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->books()->sequence(
|
->books()->sequence(
|
||||||
function ($book) {
|
function ($book) {
|
||||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||||
@ -50,7 +50,7 @@ it('works with sequence', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can compose complex expectations', function () {
|
it('can compose complex expectations', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->toBeObject()
|
->toBeObject()
|
||||||
->name()->toEqual('Has Methods')->not()->toEqual('bar')
|
->name()->toEqual('Has Methods')->not()->toEqual('bar')
|
||||||
->quantity()->not->toEqual('world')->toEqual(20)->toBeInt
|
->quantity()->not->toEqual('world')->toEqual(20)->toBeInt
|
||||||
@ -68,7 +68,7 @@ it('can compose complex expectations', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can handle nested method calls', function () {
|
it('can handle nested method calls', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
|
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
|
||||||
->newInstance()->name()->toEqual('Has Methods')->not->toBeInt
|
->newInstance()->name()->toEqual('Has Methods')->not->toBeInt
|
||||||
->name()->toEqual('Has Methods')
|
->name()->toEqual('Has Methods')
|
||||||
@ -76,14 +76,14 @@ it('can handle nested method calls', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with higher order tests')
|
it('works with higher order tests')
|
||||||
->expect(new HasMethods())
|
->expect(new HasMethods)
|
||||||
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
|
->newInstance()->newInstance()->name()->toEqual('Has Methods')->toBeString()
|
||||||
->newInstance()->name()->toEqual('Has Methods')->not->toBeArray
|
->newInstance()->name()->toEqual('Has Methods')->not->toBeArray
|
||||||
->name()->toEqual('Has Methods')
|
->name()->toEqual('Has Methods')
|
||||||
->books()->each->toBeArray;
|
->books()->each->toBeArray;
|
||||||
|
|
||||||
it('can use the scoped method to lock into the given level for expectations', function () {
|
it('can use the scoped method to lock into the given level for expectations', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->attributes()->scoped(fn ($attributes) => $attributes
|
->attributes()->scoped(fn ($attributes) => $attributes
|
||||||
->name->toBe('Has Methods')
|
->name->toBe('Has Methods')
|
||||||
->quantity->toBe(20)
|
->quantity->toBe(20)
|
||||||
@ -100,7 +100,7 @@ it('can use the scoped method to lock into the given level for expectations', fu
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works consistently with the json expectation method', function () {
|
it('works consistently with the json expectation method', function () {
|
||||||
expect(new HasMethods())
|
expect(new HasMethods)
|
||||||
->jsonString()->json()->id->toBe(1)
|
->jsonString()->json()->id->toBe(1)
|
||||||
->jsonString()->json()->name->toBe('Has Methods')->toBeString()
|
->jsonString()->json()->name->toBe('Has Methods')->toBeString()
|
||||||
->jsonString()->json()->quantity->toBe(20)->toBeInt();
|
->jsonString()->json()->quantity->toBe(20)->toBeInt();
|
||||||
@ -152,6 +152,6 @@ class HasMethods
|
|||||||
|
|
||||||
public function newInstance()
|
public function newInstance()
|
||||||
{
|
{
|
||||||
return new static();
|
return new static;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
it('can access methods and properties', function () {
|
it('can access methods and properties', function () {
|
||||||
expect(new HasMethodsAndProperties())
|
expect(new HasMethodsAndProperties)
|
||||||
->name->toEqual('Has Methods and Properties')->not()->toEqual('bar')
|
->name->toEqual('Has Methods and Properties')->not()->toEqual('bar')
|
||||||
->multiply(3, 4)->not->toBeString->toEqual(12)
|
->multiply(3, 4)->not->toBeString->toEqual(12)
|
||||||
->posts->each(function ($post) {
|
->posts->each(function ($post) {
|
||||||
@ -19,7 +19,7 @@ it('can access methods and properties', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can handle nested methods and properties', function () {
|
it('can handle nested methods and properties', function () {
|
||||||
expect(new HasMethodsAndProperties())
|
expect(new HasMethodsAndProperties)
|
||||||
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
|
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
|
||||||
->newInstance()->meta->foo->toBeArray()
|
->newInstance()->meta->foo->toBeArray()
|
||||||
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
|
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
|
||||||
@ -27,14 +27,14 @@ it('can handle nested methods and properties', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with higher order tests')
|
it('works with higher order tests')
|
||||||
->expect(new HasMethodsAndProperties())
|
->expect(new HasMethodsAndProperties)
|
||||||
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
|
->meta->foo->bar->toBeString()->toEqual('baz')->not->toBeInt
|
||||||
->newInstance()->meta->foo->toBeArray
|
->newInstance()->meta->foo->toBeArray
|
||||||
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
|
->newInstance()->multiply(2, 2)->toEqual(4)->not->toEqual(5)
|
||||||
->newInstance()->books()->toBeArray();
|
->newInstance()->books()->toBeArray();
|
||||||
|
|
||||||
it('can start a new higher order expectation using the and syntax', function () {
|
it('can start a new higher order expectation using the and syntax', function () {
|
||||||
expect(new HasMethodsAndProperties())
|
expect(new HasMethodsAndProperties)
|
||||||
->toBeInstanceOf(HasMethodsAndProperties::class)
|
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||||
->meta->toBeArray
|
->meta->toBeArray
|
||||||
->and(['foo' => 'bar'])
|
->and(['foo' => 'bar'])
|
||||||
@ -45,7 +45,7 @@ it('can start a new higher order expectation using the and syntax', function ()
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can start a new higher order expectation using the and syntax in higher order tests')
|
it('can start a new higher order expectation using the and syntax in higher order tests')
|
||||||
->expect(new HasMethodsAndProperties())
|
->expect(new HasMethodsAndProperties)
|
||||||
->toBeInstanceOf(HasMethodsAndProperties::class)
|
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||||
->meta->toBeArray
|
->meta->toBeArray
|
||||||
->and(['foo' => 'bar'])
|
->and(['foo' => 'bar'])
|
||||||
@ -53,7 +53,7 @@ it('can start a new higher order expectation using the and syntax in higher orde
|
|||||||
->foo->toEqual('bar');
|
->foo->toEqual('bar');
|
||||||
|
|
||||||
it('can start a new higher order expectation using the and syntax without nesting expectations', function () {
|
it('can start a new higher order expectation using the and syntax without nesting expectations', function () {
|
||||||
expect(new HasMethodsAndProperties())
|
expect(new HasMethodsAndProperties)
|
||||||
->toBeInstanceOf(HasMethodsAndProperties::class)
|
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||||
->meta
|
->meta
|
||||||
->sequence(
|
->sequence(
|
||||||
@ -101,6 +101,6 @@ class HasMethodsAndProperties
|
|||||||
|
|
||||||
public function newInstance()
|
public function newInstance()
|
||||||
{
|
{
|
||||||
return new static();
|
return new static;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ it('can compose complex expectations', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with objects', function () {
|
it('works with objects', function () {
|
||||||
expect(new HasProperties())
|
expect(new HasProperties)
|
||||||
->name->toEqual('foo')->not->toEqual('world')
|
->name->toEqual('foo')->not->toEqual('world')
|
||||||
->posts->toHaveCount(2)->each(function ($post) {
|
->posts->toHaveCount(2)->each(function ($post) {
|
||||||
$post->is_published->toBeTrue();
|
$post->is_published->toBeTrue();
|
||||||
@ -69,13 +69,13 @@ it('works with objects', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('works with nested properties', function () {
|
it('works with nested properties', function () {
|
||||||
expect(new HasProperties())
|
expect(new HasProperties)
|
||||||
->nested->foo->bar->toBeString()->toEqual('baz')
|
->nested->foo->bar->toBeString()->toEqual('baz')
|
||||||
->posts->toBeArray()->toHaveCount(2);
|
->posts->toBeArray()->toHaveCount(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with higher order tests')
|
it('works with higher order tests')
|
||||||
->expect(new HasProperties())
|
->expect(new HasProperties)
|
||||||
->nested->foo->bar->toBeString()->toEqual('baz')
|
->nested->foo->bar->toBeString()->toEqual('baz')
|
||||||
->posts->toBeArray()->toHaveCount(2);
|
->posts->toBeArray()->toHaveCount(2);
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class State
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$state = new State();
|
$state = new State;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Overrides toBe to assert two Characters are the same
|
* Overrides toBe to assert two Characters are the same
|
||||||
|
|||||||
@ -5,8 +5,8 @@ use PHPUnit\Framework\ExpectationFailedException;
|
|||||||
expect(true)->toBeTrue()->and(false)->toBeFalse();
|
expect(true)->toBeTrue()->and(false)->toBeFalse();
|
||||||
|
|
||||||
test('strict comparisons', function () {
|
test('strict comparisons', function () {
|
||||||
$nuno = new stdClass();
|
$nuno = new stdClass;
|
||||||
$dries = new stdClass();
|
$dries = new stdClass;
|
||||||
|
|
||||||
expect($nuno)->toBe($nuno)->not->toBe($dries);
|
expect($nuno)->toBe($nuno)->not->toBe($dries);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,8 +8,8 @@ test('passes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes with DateTime and DateTimeImmutable', function () {
|
test('passes with DateTime and DateTimeImmutable', function () {
|
||||||
$now = new DateTime();
|
$now = new DateTime;
|
||||||
$past = (new DateTimeImmutable())->modify('-1 day');
|
$past = (new DateTimeImmutable)->modify('-1 day');
|
||||||
|
|
||||||
expect($now)->toBeGreaterThan($past);
|
expect($now)->toBeGreaterThan($past);
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ test('passes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes with DateTime and DateTimeImmutable', function () {
|
test('passes with DateTime and DateTimeImmutable', function () {
|
||||||
$now = new DateTime();
|
$now = new DateTime;
|
||||||
$past = (new DateTimeImmutable())->modify('-1 day');
|
$past = (new DateTimeImmutable)->modify('-1 day');
|
||||||
|
|
||||||
expect($now)->toBeGreaterThanOrEqual($now);
|
expect($now)->toBeGreaterThanOrEqual($now);
|
||||||
|
|
||||||
|
|||||||
@ -3,18 +3,18 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
expect(new Exception())->toBeInstanceOf(Exception::class);
|
expect(new Exception)->toBeInstanceOf(Exception::class);
|
||||||
expect(new Exception())->not->toBeInstanceOf(RuntimeException::class);
|
expect(new Exception)->not->toBeInstanceOf(RuntimeException::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
expect(new Exception())->toBeInstanceOf(RuntimeException::class);
|
expect(new Exception)->toBeInstanceOf(RuntimeException::class);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('failures with custom message', function () {
|
test('failures with custom message', function () {
|
||||||
expect(new Exception())->toBeInstanceOf(RuntimeException::class, 'oh no!');
|
expect(new Exception)->toBeInstanceOf(RuntimeException::class, 'oh no!');
|
||||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
expect(new Exception())->not->toBeInstanceOf(Exception::class);
|
expect(new Exception)->not->toBeInstanceOf(Exception::class);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|||||||
@ -8,8 +8,8 @@ test('passes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes with DateTime and DateTimeImmutable', function () {
|
test('passes with DateTime and DateTimeImmutable', function () {
|
||||||
$now = new DateTime();
|
$now = new DateTime;
|
||||||
$past = (new DateTimeImmutable())->modify('-1 day');
|
$past = (new DateTimeImmutable)->modify('-1 day');
|
||||||
|
|
||||||
expect($past)->toBeLessThan($now);
|
expect($past)->toBeLessThan($now);
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ test('passes', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('passes with DateTime and DateTimeImmutable', function () {
|
test('passes with DateTime and DateTimeImmutable', function () {
|
||||||
$now = new DateTime();
|
$now = new DateTime;
|
||||||
$past = (new DateTimeImmutable())->modify('-1 day');
|
$past = (new DateTimeImmutable)->modify('-1 day');
|
||||||
|
|
||||||
expect($now)->toBeLessThanOrEqual($now);
|
expect($now)->toBeLessThanOrEqual($now);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->times = [new DateTimeImmutable(), new DateTimeImmutable()];
|
$this->times = [new DateTimeImmutable, new DateTimeImmutable];
|
||||||
});
|
});
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass;
|
||||||
$object->name = 'John';
|
$object->name = 'John';
|
||||||
$object->age = 21;
|
$object->age = 21;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ test('pass', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass;
|
||||||
$object->name = 'John';
|
$object->name = 'John';
|
||||||
|
|
||||||
expect($object)
|
expect($object)
|
||||||
@ -28,7 +28,7 @@ test('failures', function () {
|
|||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('failures with custom message', function () {
|
test('failures with custom message', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass;
|
||||||
$object->name = 'John';
|
$object->name = 'John';
|
||||||
|
|
||||||
expect($object)
|
expect($object)
|
||||||
@ -40,7 +40,7 @@ test('failures with custom message', function () {
|
|||||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass;
|
||||||
$object->name = 'John';
|
$object->name = 'John';
|
||||||
$object->age = 21;
|
$object->age = 21;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
$obj = new stdClass();
|
$obj = new stdClass;
|
||||||
$obj->foo = 'bar';
|
$obj->foo = 'bar';
|
||||||
$obj->fooNull = null;
|
$obj->fooNull = null;
|
||||||
|
|
||||||
|
|||||||
@ -4,17 +4,17 @@ use PHPUnit\Framework\Constraint\IsTrue;
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
expect(true)->toMatchConstraint(new IsTrue());
|
expect(true)->toMatchConstraint(new IsTrue);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
expect(false)->toMatchConstraint(new IsTrue());
|
expect(false)->toMatchConstraint(new IsTrue);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('failures with custom message', function () {
|
test('failures with custom message', function () {
|
||||||
expect(false)->toMatchConstraint(new IsTrue(), 'oh no!');
|
expect(false)->toMatchConstraint(new IsTrue, 'oh no!');
|
||||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
expect(true)->not->toMatchConstraint(new IsTrue());
|
expect(true)->not->toMatchConstraint(new IsTrue);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|||||||
@ -18,7 +18,7 @@ test('pass', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('pass with class', function () {
|
test('pass with class', function () {
|
||||||
expect(new class()
|
expect(new class
|
||||||
{
|
{
|
||||||
public $name = 'Nuno';
|
public $name = 'Nuno';
|
||||||
|
|
||||||
|
|||||||
@ -6,13 +6,13 @@ class CustomException extends Exception {}
|
|||||||
|
|
||||||
test('passes', function () {
|
test('passes', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException;
|
||||||
})->toThrow(RuntimeException::class);
|
})->toThrow(RuntimeException::class);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException;
|
||||||
})->toThrow(Exception::class);
|
})->toThrow(Exception::class);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException;
|
||||||
})->toThrow(function (RuntimeException $e) {});
|
})->toThrow(function (RuntimeException $e) {});
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException('actual message');
|
throw new RuntimeException('actual message');
|
||||||
@ -24,7 +24,7 @@ test('passes', function () {
|
|||||||
throw new RuntimeException('actual message');
|
throw new RuntimeException('actual message');
|
||||||
})->toThrow('actual message');
|
})->toThrow('actual message');
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new Exception();
|
throw new Exception;
|
||||||
})->not->toThrow(RuntimeException::class);
|
})->not->toThrow(RuntimeException::class);
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException('actual message');
|
throw new RuntimeException('actual message');
|
||||||
@ -47,7 +47,7 @@ test('failures 2', function () {
|
|||||||
|
|
||||||
test('failures 3', function () {
|
test('failures 3', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new Exception();
|
throw new Exception;
|
||||||
})->toThrow(function (RuntimeException $e) {
|
})->toThrow(function (RuntimeException $e) {
|
||||||
//
|
//
|
||||||
});
|
});
|
||||||
@ -92,7 +92,7 @@ test('failures with custom message', function () {
|
|||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException;
|
||||||
})->not->toThrow(RuntimeException::class);
|
})->not->toThrow(RuntimeException::class);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
@ -106,16 +106,16 @@ test('closure missing type-hint', function () {
|
|||||||
|
|
||||||
it('can handle a non-defined exception', function () {
|
it('can handle a non-defined exception', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new NonExistingException();
|
throw new NonExistingException;
|
||||||
})->toThrow(NonExistingException::class);
|
})->toThrow(NonExistingException::class);
|
||||||
})->throws(Error::class, 'Class "NonExistingException" not found');
|
})->throws(Error::class, 'Class "NonExistingException" not found');
|
||||||
|
|
||||||
it('can handle a class not found Error', function () {
|
it('can handle a class not found Error', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new NonExistingException();
|
throw new NonExistingException;
|
||||||
})->toThrow('Class "NonExistingException" not found');
|
})->toThrow('Class "NonExistingException" not found');
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
throw new NonExistingException();
|
throw new NonExistingException;
|
||||||
})->toThrow(Error::class, 'Class "NonExistingException" not found');
|
})->toThrow(Error::class, 'Class "NonExistingException" not found');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->unlessObject = new stdClass();
|
$this->unlessObject = new stdClass;
|
||||||
$this->unlessObject->trueValue = true;
|
$this->unlessObject->trueValue = true;
|
||||||
$this->unlessObject->foo = 'foo';
|
$this->unlessObject->foo = 'foo';
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->whenObject = new stdClass();
|
$this->whenObject = new stdClass;
|
||||||
$this->whenObject->trueValue = true;
|
$this->whenObject->trueValue = true;
|
||||||
$this->whenObject->foo = 'foo';
|
$this->whenObject->foo = 'foo';
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ dataset('numbers.array', [
|
|||||||
1, 2, 3, 4, 5, 'ScopedDatasets/ScopedDatasets.php',
|
1, 2, 3, 4, 5, 'ScopedDatasets/ScopedDatasets.php',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$state = new stdClass();
|
$state = new stdClass;
|
||||||
$state->text = '';
|
$state->text = '';
|
||||||
test('uses dataset', function ($value) use ($state) {
|
test('uses dataset', function ($value) use ($state) {
|
||||||
$state->text .= $value;
|
$state->text .= $value;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use function PHPUnit\Framework\assertFalse;
|
use function PHPUnit\Framework\assertFalse;
|
||||||
|
|
||||||
$foo = new stdClass();
|
$foo = new stdClass;
|
||||||
$foo->beforeAll = false;
|
$foo->beforeAll = false;
|
||||||
$foo->beforeEach = false;
|
$foo->beforeEach = false;
|
||||||
$foo->afterEach = false;
|
$foo->afterEach = false;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use Pest\Console\Help;
|
|||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
|
|
||||||
it('outputs the help information when --help is used', function () {
|
it('outputs the help information when --help is used', function () {
|
||||||
$output = new BufferedOutput();
|
$output = new BufferedOutput;
|
||||||
$plugin = new Help($output);
|
$plugin = new Help($output);
|
||||||
|
|
||||||
$plugin();
|
$plugin();
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use Pest\Plugins\Environment;
|
|||||||
test('environment is set to CI when --ci option is used', function () {
|
test('environment is set to CI when --ci option is used', function () {
|
||||||
$previousName = Environment::name();
|
$previousName = Environment::name();
|
||||||
|
|
||||||
$plugin = new Environment();
|
$plugin = new Environment;
|
||||||
|
|
||||||
$plugin->handleArguments(['foo', '--ci', 'bar']);
|
$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 () {
|
test('environment is set to Local when --ci option is not used', function () {
|
||||||
$plugin = new Environment();
|
$plugin = new Environment;
|
||||||
|
|
||||||
$plugin->handleArguments(['foo', 'bar', 'baz']);
|
$plugin->handleArguments(['foo', 'bar', 'baz']);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
use Pest\Plugins\Retry;
|
use Pest\Plugins\Retry;
|
||||||
|
|
||||||
it('orders by defects and stop on defects if when --retry is used ', function () {
|
it('orders by defects and stop on defects if when --retry is used ', function () {
|
||||||
$retry = new Retry();
|
$retry = new Retry;
|
||||||
|
|
||||||
$arguments = $retry->handleArguments(['--retry']);
|
$arguments = $retry->handleArguments(['--retry']);
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use Pest\TestSuite;
|
|||||||
uses()->group('container');
|
uses()->group('container');
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->container = new Container();
|
$this->container = new Container;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('exists')
|
it('exists')
|
||||||
|
|||||||
@ -9,7 +9,7 @@ it('gets file name from closure', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('gets property values', function () {
|
it('gets property values', function () {
|
||||||
$class = new class()
|
$class = new class
|
||||||
{
|
{
|
||||||
private $foo = 'bar';
|
private $foo = 'bar';
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user