diff --git a/composer.json b/composer.json index 7ef9486e..159f053e 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ }, "require-dev": { "pestphp/pest-dev-tools": "^4.1.0", - "pestphp/pest-plugin-browser": "^4.3.0", + "pestphp/pest-plugin-browser": "^4.3.1", "pestphp/pest-plugin-type-coverage": "^4.0.4", "psy/psysh": "^0.12.22" }, diff --git a/src/Expectation.php b/src/Expectation.php index 5d7666cb..908f5954 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -684,23 +684,19 @@ final class Expectation $realPath = realpath($object->path); - foreach (Composer::userNamespaces() as $directory => $namespace) { + foreach (Composer::userNamespacesWithDirectories() as $directory => $namespace) { if (str_starts_with($realPath, $directory)) { $relativePath = substr($realPath, strlen($directory) + 1); $relativePath = explode('.', $relativePath)[0]; - $classFromPath = $namespace . '\\' . str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath); + $classFromPath = $namespace.'\\'.str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath); - if ($classFromPath === $object->reflectionClass->getName()) { - return true; - } - - return false; + return $classFromPath === $object->reflectionClass->getName(); } } return false; }, - "to be cased correctly", + 'to be cased correctly', FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class')), ); } diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 49efa6bb..a994dcc0 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -448,6 +448,10 @@ ✓ failures with custom message ✓ not failures + PASS Tests\Features\Expect\toBeCasedCorrectly + ✓ pass + ✓ failure + PASS Tests\Features\Expect\toBeDigits ✓ pass ✓ failures @@ -1034,6 +1038,10 @@ ✓ pass ✓ failures ✓ not failures + ✓ trait inheritance - direct usage + ✓ trait inheritance - inherited usage + ✓ trait inheritance - negative case + ✓ nested trait inheritance PASS Tests\Features\Expect\unless ✓ it pass @@ -1801,4 +1809,4 @@ ✓ pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value') - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 39 todos, 35 skipped, 1203 passed (2835 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 39 todos, 35 skipped, 1209 passed (2842 assertions) \ No newline at end of file diff --git a/tests/Fixtures/Arch/ToUseTrait/HasInheritedTrait/ChildClassExtendingParent.php b/tests/Fixtures/Arch/ToUseTrait/HasInheritedTrait/ChildClassExtendingParent.php index df7ce9ec..c4672451 100644 --- a/tests/Fixtures/Arch/ToUseTrait/HasInheritedTrait/ChildClassExtendingParent.php +++ b/tests/Fixtures/Arch/ToUseTrait/HasInheritedTrait/ChildClassExtendingParent.php @@ -6,6 +6,4 @@ namespace Tests\Fixtures\Arch\ToUseTrait\HasInheritedTrait; use Tests\Fixtures\Arch\ToUseTrait\HasTrait\ParentClassWithTrait; -class ChildClassExtendingParent extends ParentClassWithTrait -{ -} \ No newline at end of file +class ChildClassExtendingParent extends ParentClassWithTrait {} diff --git a/tests/Fixtures/Arch/ToUseTrait/HasNestedTrait/NestedTrait.php b/tests/Fixtures/Arch/ToUseTrait/HasNestedTrait/NestedTrait.php index 61352270..370e01b7 100644 --- a/tests/Fixtures/Arch/ToUseTrait/HasNestedTrait/NestedTrait.php +++ b/tests/Fixtures/Arch/ToUseTrait/HasNestedTrait/NestedTrait.php @@ -10,4 +10,4 @@ trait NestedTrait { return 'nested'; } -} \ No newline at end of file +} diff --git a/tests/Fixtures/Arch/ToUseTrait/HasTrait/ParentClassWithTrait.php b/tests/Fixtures/Arch/ToUseTrait/HasTrait/ParentClassWithTrait.php index f2d24171..81163ba6 100644 --- a/tests/Fixtures/Arch/ToUseTrait/HasTrait/ParentClassWithTrait.php +++ b/tests/Fixtures/Arch/ToUseTrait/HasTrait/ParentClassWithTrait.php @@ -7,4 +7,4 @@ namespace Tests\Fixtures\Arch\ToUseTrait\HasTrait; class ParentClassWithTrait { use TestTraitForInheritance; -} \ No newline at end of file +} diff --git a/tests/Fixtures/Arch/ToUseTrait/HasTrait/TestTraitForInheritance.php b/tests/Fixtures/Arch/ToUseTrait/HasTrait/TestTraitForInheritance.php index 0dc95376..4386a06b 100644 --- a/tests/Fixtures/Arch/ToUseTrait/HasTrait/TestTraitForInheritance.php +++ b/tests/Fixtures/Arch/ToUseTrait/HasTrait/TestTraitForInheritance.php @@ -14,4 +14,4 @@ trait TestTraitForInheritance { return 'test'; } -} \ No newline at end of file +} diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 9824a405..68b3ee1f 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -16,7 +16,7 @@ $run = function () { test('parallel', function () use ($run) { expect($run('--exclude-group=integration')) - ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 3 notices, 39 todos, 26 skipped, 1190 passed (2802 assertions)') + ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 3 notices, 39 todos, 26 skipped, 1196 passed (2809 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();