Skip to content

Commit a456d60

Browse files
committed
ITT: Database assertions tests added.
1 parent dce6923 commit a456d60

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
}

0 commit comments

Comments
 (0)