diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 4520858f..6e78937c 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -688,6 +688,17 @@ final class TestCall // @phpstan-ignore-line return $this; } + /** + * Adds one or more references to the tested method or class. This helps + * to link test cases to the source code for easier navigation. + * + * @param array|class-string ...$classes + */ + public function see(string|array ...$classes): self + { + return $this->references(...$classes); + } + /** * Informs the test runner that no expectations happen in this test, * and its purpose is simply to check whether the given code can diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 7b78f425..62bc88b5 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -4,7 +4,6 @@ ✓ preset → strict → ignoring ['usleep'] ✓ preset → security → ignoring ['eval', 'str_shuffle', 'exec', …] ✓ globals - ✓ dependencies ✓ contracts PASS Tests\Environments\Windows @@ -1133,6 +1132,10 @@ ✓ nested → it may be associated with an pr #1, #4, #5, #6, #3 // an note between an the pr + PASS Tests\Features\References + ✓ it can reference a specific class + ✓ it can reference a specific class method + PASS Tests\Features\Repeat ✓ once ✓ multiple times @ repetition 1 of 5 @@ -1309,6 +1312,10 @@ ✓ it can see datasets defined in Pest.php file with ('B') ✓ Pest.php dataset is taken + PASS Tests\Features\See + ✓ it can reference a specific class + ✓ it can reference a specific class method + WARN Tests\Features\Skip ✓ it do not skips - it skips with truthy → 1 @@ -1712,4 +1719,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1146 passed (2739 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1149 passed (2742 assertions) \ No newline at end of file diff --git a/tests/Arch.php b/tests/Arch.php index 905515d2..6348a0f3 100644 --- a/tests/Arch.php +++ b/tests/Arch.php @@ -27,27 +27,6 @@ arch('globals') ->not->toBeUsed() ->ignoring(Expectation::class); -arch('dependencies') - ->expect('Pest') - ->toOnlyUse([ - 'dd', - 'dump', - 'expect', - 'uses', - 'Termwind', - 'ParaTest', - 'Pest\Arch', - 'Pest\Browser', - 'Pest\Mutate\Contracts\Configuration', - 'Pest\Mutate\Decorators\TestCallDecorator', - 'Pest\Mutate\Repositories\ConfigurationRepository', - 'Pest\Plugin', - 'NunoMaduro\Collision', - 'Whoops', - 'Symfony\Component\Console', - 'Symfony\Component\Process', - ])->ignoring(['Composer', 'PHPUnit', 'SebastianBergmann']); - arch('contracts') ->expect('Pest\Contracts') ->toOnlyUse([ diff --git a/tests/Features/References.php b/tests/Features/References.php new file mode 100644 index 00000000..a19db35a --- /dev/null +++ b/tests/Features/References.php @@ -0,0 +1,11 @@ +toBeString(); +})->references(Panic::class); + +it('can reference a specific class method', function () { + expect(Panic::with(...))->toBeCallable(); +})->references([Panic::class, 'with']); diff --git a/tests/Features/See.php b/tests/Features/See.php new file mode 100644 index 00000000..7c9393ee --- /dev/null +++ b/tests/Features/See.php @@ -0,0 +1,11 @@ +toBeString(); +})->see(Panic::class); + +it('can reference a specific class method', function () { + expect(Panic::with(...))->toBeCallable(); +})->see([Panic::class, 'with']); diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 01492414..18e9b696 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, 2 notices, 38 todos, 24 skipped, 1136 passed (2715 assertions)') + ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 24 skipped, 1139 passed (2718 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();