Browse Source

Update TestCases to use RefreshDatabase testing Trait

pull/3/head
Nafies Luthfi 8 years ago
parent
commit
de3d24700e
  1. 4
      tests/Feature/ManageUserFamiliesTest.php
  2. 4
      tests/Feature/UsersProfileTest.php
  3. 16
      tests/TestCase.php
  4. 4
      tests/Unit/PersonRelationsTest.php
  5. 4
      tests/Unit/Policies/UserPolicyTest.php
  6. 4
      tests/Unit/UserTest.php

4
tests/Feature/ManageUserFamiliesTest.php

@ -3,12 +3,12 @@
namespace Tests\Feature; namespace Tests\Feature;
use App\User; use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase; use Tests\TestCase;
class ManageUserFamiliesTest extends TestCase class ManageUserFamiliesTest extends TestCase
{ {
use DatabaseMigrations;
use RefreshDatabase;
/** @test */ /** @test */
public function user_can_update_their_father() public function user_can_update_their_father()

4
tests/Feature/UsersProfileTest.php

@ -3,12 +3,12 @@
namespace Tests\Feature; namespace Tests\Feature;
use App\User; use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase; use Tests\TestCase;
class UsersProfileTest extends TestCase class UsersProfileTest extends TestCase
{ {
use DatabaseMigrations;
use RefreshDatabase;
/** @test */ /** @test */
public function user_can_view_other_users_profile() public function user_can_view_other_users_profile()

16
tests/TestCase.php

@ -3,6 +3,7 @@
namespace Tests; namespace Tests;
use App\User; use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase; use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase abstract class TestCase extends BaseTestCase
@ -18,4 +19,19 @@ abstract class TestCase extends BaseTestCase
return $user; 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();
}
}
} }

4
tests/Unit/PersonRelationsTest.php

@ -3,12 +3,12 @@
namespace Tests\Unit; namespace Tests\Unit;
use App\User; use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase; use Tests\TestCase;
class PersonRelationsTest extends TestCase class PersonRelationsTest extends TestCase
{ {
use DatabaseMigrations;
use RefreshDatabase;
/** @test */ /** @test */
public function create_user_model_with_factory() public function create_user_model_with_factory()

4
tests/Unit/Policies/UserPolicyTest.php

@ -3,12 +3,12 @@
namespace Tests\Unit\Policies; namespace Tests\Unit\Policies;
use App\User; use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase; use Tests\TestCase;
class UserPolicyTest extends TestCase class UserPolicyTest extends TestCase
{ {
use DatabaseMigrations;
use RefreshDatabase;
/** @test */ /** @test */
public function admin_can_edit_users_profile() public function admin_can_edit_users_profile()

4
tests/Unit/UserTest.php

@ -3,12 +3,12 @@
namespace Tests\Unit; namespace Tests\Unit;
use App\User; use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase; use Tests\TestCase;
class UserTest extends TestCase class UserTest extends TestCase
{ {
use DatabaseMigrations;
use RefreshDatabase;
/** @test */ /** @test */
public function user_have_profile_link() public function user_have_profile_link()

Loading…
Cancel
Save