-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathTestCaseDatabase.php
44 lines (34 loc) · 1.13 KB
/
TestCaseDatabase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests;
use Rebing\GraphQL\Tests\Support\Traits\SqlAssertionTrait;
abstract class TestCaseDatabase extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->loadMigrationsFrom(__DIR__ . '/Support/database/migrations');
$this->withFactories(__DIR__ . '/Support/database/factories');
// This takes care of refreshing the database between tests
// as we are using the in-memory SQLite db we do not need RefreshDatabase
$this->artisan('migrate');
}
protected function setUpTraits()
{
$uses = parent::setUpTraits();
if (isset($uses[SqlAssertionTrait::class])) {
$this->setupTraitForSqlAssertion();
}
return $uses;
}
protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);
$app['config']->set('database.default', 'sqlite');
$app['config']->set('database.connections.sqlite', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
}
}