Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit 699b1f8

Browse files
committed
Call reload:db and setup database connection in test.
1 parent 7ab3c92 commit 699b1f8

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tests/CreatesApplication.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,41 @@
66

77
trait CreatesApplication
88
{
9+
/**
10+
* Setup the test environment.
11+
*/
12+
public function setUp()
13+
{
14+
parent::setUp();
15+
16+
$this->artisan('reload:db');
17+
}
18+
19+
/**
20+
* Define environment setup.
21+
*
22+
* @param \Illuminate\Foundation\Application $app
23+
* @return void
24+
*/
25+
protected function getEnvironmentSetUp($app)
26+
{
27+
// Setup default database to use sqlite :memory:
28+
$app['config']->set('database.default', 'testbench');
29+
$app['config']->set('database.connections.testbench', [
30+
'driver' => 'sqlite',
31+
'database' => ':memory:',
32+
'prefix' => '',
33+
]);
34+
}
35+
936
/**
1037
* Creates the application.
1138
*
1239
* @return \Illuminate\Foundation\Application
1340
*/
1441
public function createApplication()
1542
{
16-
$app = require __DIR__.'/../bootstrap/app.php';
43+
$app = require __DIR__ . '/../bootstrap/app.php';
1744

1845
$app->make(Kernel::class)->bootstrap();
1946

0 commit comments

Comments
 (0)