pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: toOnlyUse not working as documented in the Pest Docs

Open spont4e opened this issue 1 year ago • 2 comments

What Happened

When I used either the toOnlyUse examples even directly copied from the docs, it returns this exception.

How to Reproduce

  1. Install a fresh laravel app with pest
  2. Replace Feature\ExampleTest with the following basically clipped from the docs
<?php

test('models')
    ->expect('App\Models')
    ->toOnlyUse('Illuminate\Database');

Exception stacktrace

ErrorException: Attempt to read property "stmts" on null
at vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:254
at vendor/pestphp/pest-plugin-arch/src/Blueprint.php:235
at vendor/pestphp/pest-plugin-arch/src/Blueprint.php:148
at vendor/pestphp/pest-plugin-arch/src/Expectations/ToOnlyUse.php:37
at vendor/pestphp/pest-plugin-arch/src/SingleArchExpectation.php:156
at vendor/pestphp/pest-plugin-arch/src/SingleArchExpectation.php:140
at vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:174

  Tests:    1 failed (1 assertions)
  Duration: 1.76s


Process finished with exit code 2

Sample Repository

No response

Pest Version

2.19.2

PHP Version

8.2.10

Operation System

Linux

Notes

No response

spont4e avatar Oct 02 '23 14:10 spont4e

Hey, @spont4e . Thanks for your report.

I was able to reproduce that. I will investigate the issue. Feel free to open a PR fixing this issue.

devajmeireles avatar Oct 10 '23 13:10 devajmeireles