File tree 6 files changed +49
-55
lines changed
6 files changed +49
-55
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 5
5
trait CreatesApplication
6
6
{
7
7
use EnvironmentSetup;
8
+ use MigrateBaselineDatabase;
8
9
9
10
protected $ cache ;
10
11
protected $ testingSqlitePath ;
@@ -22,18 +23,16 @@ protected function cache()
22
23
23
24
public function setUp () : void
24
25
{
26
+ parent ::setUp ();
27
+ $ this ->setUpBaseLineSqlLiteDatabase ();
28
+
25
29
$ databasePath = __DIR__ . "/database " ;
26
30
$ this ->testingSqlitePath = "{$ databasePath }/ " ;
27
31
$ baselinePath = "{$ databasePath }/baseline.sqlite " ;
28
32
$ testingPath = "{$ databasePath }/testing.sqlite " ;
29
33
30
- if (file_exists ($ testingPath )) {
31
- unlink ($ testingPath );
32
- }
33
-
34
- shell_exec ("cp {$ baselinePath } {$ testingPath }" );
35
-
36
- parent ::setUp ();
34
+ ! file_exists ($ testingPath ) ?: unlink ($ testingPath );
35
+ copy ($ baselinePath , $ testingPath );
37
36
38
37
require (__DIR__ . '/routes/web.php ' );
39
38
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace GeneaLabs \LaravelModelCaching \Tests ;
4
+
5
+ use Illuminate \Support \Facades \Artisan ;
6
+
7
+ trait MigrateBaselineDatabase
8
+ {
9
+ private static $ baseLineDatabaseMigrated = false ;
10
+
11
+ public function setUpBaseLineSqlLiteDatabase ()
12
+ {
13
+ if (self ::$ baseLineDatabaseMigrated ) {
14
+ return ;
15
+ }
16
+
17
+ self ::$ baseLineDatabaseMigrated = true ;
18
+ $ file = __DIR__ . '/database/baseline.sqlite ' ;
19
+ $ this ->app ['config ' ]->set ('database.default ' , 'baseline ' );
20
+ $ this ->app ['config ' ]->set ('database.connections.baseline ' , [
21
+ 'driver ' => 'sqlite ' ,
22
+ "url " => null ,
23
+ 'database ' => $ file ,
24
+ 'prefix ' => '' ,
25
+ "foreign_key_constraints " => false ,
26
+ ]);
27
+
28
+ ! file_exists ($ file ) ?: unlink ($ file );
29
+ touch ($ file );
30
+
31
+ $ this ->withFactories (__DIR__ . '/database/factories ' );
32
+ $ this ->loadMigrationsFrom (__DIR__ . '/database/migrations ' );
33
+
34
+ Artisan::call ('db:seed ' , [
35
+ '--class ' => 'DatabaseSeeder ' ,
36
+ '--database ' => 'baseline ' ,
37
+ ]);
38
+
39
+ // Reset default connection to testing
40
+ $ this ->app ['config ' ]->set ('database.default ' , 'testing ' );
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ * .sqlite
You can’t perform that action at this time.
0 commit comments