Skip to content

Commit

Permalink
fix: removes process-isolation from --help output
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jan 25, 2024
1 parent 607a490 commit cb1735f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Pest\Support\ExpectationPipeline;
use PHPUnit\Architecture\Elements\ObjectDescription;
use PHPUnit\Framework\ExpectationFailedException;
use ReflectionEnum;

/**
* @template TValue
Expand Down Expand Up @@ -890,9 +891,10 @@ private function toBeBackedEnum(string $backingType): ArchExpectation
{
return Targeted::make(
$this,
fn (ObjectDescription $object): bool => (new \ReflectionEnum($object->name))->isBacked()
&& (string)(new \ReflectionEnum($object->name))->getBackingType() === $backingType,
'to be ' . $backingType . ' backed enum',
fn (ObjectDescription $object): bool => $object->reflectionClass->isEnum()
&& (new ReflectionEnum($object->name))->isBacked() // @phpstan-ignore-line
&& (string) (new ReflectionEnum($object->name))->getBackingType() === $backingType, // @phpstan-ignore-line
'to be '.$backingType.' backed enum',
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
);
}
Expand Down
7 changes: 4 additions & 3 deletions src/Expectations/OppositeExpectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,10 @@ private function toBeBackedEnum(string $backingType): ArchExpectation
{
return Targeted::make(
$this->original,
fn (ObjectDescription $object): bool => (new \ReflectionEnum($object->name))->isBacked()
&& (string)(new \ReflectionEnum($object->name))->getBackingType() !== $backingType,
'not to be ' . $backingType . ' backed enum',
fn (ObjectDescription $object): bool => ! $object->reflectionClass->isEnum()
|| ! (new \ReflectionEnum($object->name))->isBacked() // @phpstan-ignore-line
|| (string) (new \ReflectionEnum($object->name))->getBackingType() !== $backingType, // @phpstan-ignore-line
'not to be '.$backingType.' backed enum',
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')),
);
}
Expand Down
10 changes: 9 additions & 1 deletion tests/.snapshots/success.txt
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@
✓ failures with custom message
✓ not failures

PASS Tests\Features\Expect\toBeIntBackedEnum
✓ enum is backed by int
✓ enum is not backed by int

PASS Tests\Features\Expect\toBeInvokable
✓ class is invokable
✓ opposite class is invokable
Expand Down Expand Up @@ -575,6 +579,10 @@
✓ failures with custom message
✓ not failures

PASS Tests\Features\Expect\toBeStringBackedEnum
✓ enum is backed by string
✓ enum is not backed by string

PASS Tests\Features\Expect\toBeStudlyCase
✓ pass
✓ failures
Expand Down Expand Up @@ -1404,4 +1412,4 @@
WARN Tests\Visual\Version
- visual snapshot of help command output

Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 995 passed (2391 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1003 passed (2407 assertions)
2 changes: 1 addition & 1 deletion tests/Visual/Parallel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

test('parallel', function () use ($run) {
expect($run('--exclude-group=integration'))
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 982 passed (2372 assertions)')
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 990 passed (2388 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();

Expand Down

0 comments on commit cb1735f

Please sign in to comment.