Skip to content

Commit 68f2d0d

Browse files
committed
wip
1 parent ac66830 commit 68f2d0d

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

database-testing.md

+19-6
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,31 @@ Laravel provides a variety of helpful tools and assertions to make it easier to
2828
<a name="resetting-the-database-after-each-test"></a>
2929
### Resetting The Database After Each Test
3030

31-
Before proceeding much further, let's discuss how to reset your database after each of your tests so that data from a previous test does not interfere with subsequent tests. Laravel's included `Illuminate\Foundation\Testing\LazilyRefreshDatabase` trait will take care of this for you. This trait is already included on your application's base `TestCase` class so that you may always assume you have a fresh copy of your database during each of your application's "feature" tests:
31+
Before proceeding much further, let's discuss how to reset your database after each of your tests so that data from a previous test does not interfere with subsequent tests. Laravel's included `Illuminate\Foundation\Testing\RefreshDatabase` trait will take care of this for you. Simply use the trait on your test class:
3232

3333
<?php
3434

35-
namespace Tests;
35+
namespace Tests\Feature;
3636

37-
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
38-
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
37+
use Illuminate\Foundation\Testing\RefreshDatabase;
38+
use Illuminate\Foundation\Testing\WithoutMiddleware;
39+
use Tests\TestCase;
3940

40-
abstract class TestCase extends BaseTestCase
41+
class ExampleTest extends TestCase
4142
{
42-
use CreatesApplication, LazilyRefreshDatabase;
43+
use RefreshDatabase;
44+
45+
/**
46+
* A basic functional test example.
47+
*
48+
* @return void
49+
*/
50+
public function test_basic_example()
51+
{
52+
$response = $this->get('/');
53+
54+
// ...
55+
}
4356
}
4457

4558
<a name="defining-model-factories"></a>

0 commit comments

Comments
 (0)