diff --git a/tests/Feature/ManageUserFamiliesTest.php b/tests/Feature/ManageUserFamiliesTest.php index 5acc318..f8e2aa1 100644 --- a/tests/Feature/ManageUserFamiliesTest.php +++ b/tests/Feature/ManageUserFamiliesTest.php @@ -3,12 +3,12 @@ namespace Tests\Feature; use App\User; -use Illuminate\Foundation\Testing\DatabaseMigrations; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class ManageUserFamiliesTest extends TestCase { - use DatabaseMigrations; + use RefreshDatabase; /** @test */ public function user_can_update_their_father() diff --git a/tests/Feature/UsersProfileTest.php b/tests/Feature/UsersProfileTest.php index 85b6a03..7502db3 100644 --- a/tests/Feature/UsersProfileTest.php +++ b/tests/Feature/UsersProfileTest.php @@ -3,12 +3,12 @@ namespace Tests\Feature; use App\User; -use Illuminate\Foundation\Testing\DatabaseMigrations; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class UsersProfileTest extends TestCase { - use DatabaseMigrations; + use RefreshDatabase; /** @test */ public function user_can_view_other_users_profile() diff --git a/tests/TestCase.php b/tests/TestCase.php index 01e045b..15a2c3a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,6 +3,7 @@ namespace Tests; use App\User; +use Illuminate\Foundation\Testing\RefreshDatabase; use Laravel\BrowserKitTesting\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase @@ -18,4 +19,19 @@ abstract class TestCase extends BaseTestCase return $user; } + + /** + * Boot the testing helper traits. + * + * @return void + */ + protected function setUpTraits() + { + parent::setUpTraits(); + $uses = array_flip(class_uses_recursive(static::class)); + + if (isset($uses[RefreshDatabase::class])) { + $this->refreshDatabase(); + } + } } diff --git a/tests/Unit/PersonRelationsTest.php b/tests/Unit/PersonRelationsTest.php index 5087da0..03cf1f3 100644 --- a/tests/Unit/PersonRelationsTest.php +++ b/tests/Unit/PersonRelationsTest.php @@ -3,12 +3,12 @@ namespace Tests\Unit; use App\User; -use Illuminate\Foundation\Testing\DatabaseMigrations; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class PersonRelationsTest extends TestCase { - use DatabaseMigrations; + use RefreshDatabase; /** @test */ public function create_user_model_with_factory() diff --git a/tests/Unit/Policies/UserPolicyTest.php b/tests/Unit/Policies/UserPolicyTest.php index d050f4b..8a92d5e 100644 --- a/tests/Unit/Policies/UserPolicyTest.php +++ b/tests/Unit/Policies/UserPolicyTest.php @@ -3,12 +3,12 @@ namespace Tests\Unit\Policies; use App\User; -use Illuminate\Foundation\Testing\DatabaseMigrations; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class UserPolicyTest extends TestCase { - use DatabaseMigrations; + use RefreshDatabase; /** @test */ public function admin_can_edit_users_profile() diff --git a/tests/Unit/UserTest.php b/tests/Unit/UserTest.php index defd3e7..cc4e0ac 100644 --- a/tests/Unit/UserTest.php +++ b/tests/Unit/UserTest.php @@ -3,12 +3,12 @@ namespace Tests\Unit; use App\User; -use Illuminate\Foundation\Testing\DatabaseMigrations; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class UserTest extends TestCase { - use DatabaseMigrations; + use RefreshDatabase; /** @test */ public function user_have_profile_link()