Generating new test with --unit flag is not importing the correct TestCase Class
Why laravel is using the use PHPUnit\Framework\TestCase; when generating unit test instead of using the use Tests\TestCase; when running php artisan make:test ExampleTest --unit command?
I just got an error with undefined method withoutExceptionHandling() and found out that it is not importing the correct class. It was working before, but not in laravel v9. Any reason why?
@jonjie It is importing the correct class. Unit tests extend the PHPUnit test case because you should be able to run a unit test without the framework, a database, or any other external service. If you need to interact with any of these, then it’s not a unit test.
@Jonjie ok, well there you go then... there will be dissenting opinions on whether this is a true Unit test; I would argue it is not because you are not isolating the "unit". But I also understand that this type of test would be better than no test at all, so go for it if it works for you.
If you want the framework conveniences, the you must CreateApplication (which the Tests\TestCase class does, but PHPUnit\Framework\TestCase doe not.