0

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?

webgrig
  • 49
  • 1
  • 8

1 Answers1

0

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.

webgrig
  • 49
  • 1
  • 8