Why php artisan make: test PostTest --unit command creates a new test extends not from Tests\TestCase, but from PHPUnit\Framework\TestCase? Laravel 8

107 views Asked by At

The test environment is enabled in the

Tests\TestCase

class via the

createApplication()

method, but not in the

PHPUnit\Framework\TestCase

class.

So why then when the artisan creates a new test that extends from

PHPUnit\Framework\TestCase

class?

1

There are 1 answers

0
webgrig On

I figured it all out!

When create a unitest with

php artisan make:test MyTest --unit

command.

Such tests should not affect the database. Therefore, it is not necessary to change the environment for such tests.

And so the test class extends from the

PHPUnit\Framework\TestCase

class.

But if create a test without the --unit flag

Then the test class extends from the

Tests\TestCase

class, which leads to automatic execution of the

createApplication()

method and a change in the environment.