File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminated \Testing \Asserts \DatabaseAsserts ;
4+
5+ class DatabaseAssertsTest extends TestCase
6+ {
7+ use DatabaseAsserts;
8+
9+ protected function setUp ()
10+ {
11+ parent ::setUp ();
12+
13+ $ this ->setUpDatabase ();
14+ $ this ->setUpFactories ();
15+ $ this ->loadMigrations ();
16+ $ this ->seedDatabase ();
17+ }
18+
19+ protected function setUpDatabase ()
20+ {
21+ config (['database.default ' => 'testing ' ]);
22+ }
23+
24+ private function setUpFactories ()
25+ {
26+ $ this ->withFactories (__DIR__ . '/../fixture/database/factories ' );
27+ }
28+
29+ private function loadMigrations ()
30+ {
31+ $ this ->loadMigrationsFrom ([
32+ '--database ' => 'testing ' ,
33+ '--realpath ' => __DIR__ . '/../fixture/database/migrations ' ,
34+ ]);
35+ }
36+
37+ private function seedDatabase ()
38+ {
39+ factory (Post::class)->create (['title ' => 'First Post! ' ]);
40+ factory (Post::class)->create (['title ' => 'Second Post! ' ]);
41+ factory (Post::class)->create (['title ' => 'Third Post! ' ]);
42+ }
43+
44+ /** @test */
45+ public function it_has_see_in_database_many_assertion ()
46+ {
47+ $ this ->seeInDatabaseMany ('posts ' , [
48+ ['title ' => 'First Post! ' ],
49+ ['title ' => 'Second Post! ' ],
50+ ['title ' => 'Third Post! ' ],
51+ ]);
52+ }
53+ }
You can’t perform that action at this time.
0 commit comments