File tree Expand file tree Collapse file tree 7 files changed +52
-55
lines changed Expand file tree Collapse file tree 7 files changed +52
-55
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 55trait CreatesApplication
66{
77 use EnvironmentSetup;
8+ use MigrateBaselineDatabase;
89
910 protected $ cache ;
1011 protected $ testingSqlitePath ;
@@ -22,18 +23,16 @@ protected function cache()
2223
2324 public function setUp () : void
2425 {
26+ parent ::setUp ();
27+ $ this ->setUpBaseLineSqlLiteDatabase ();
28+
2529 $ databasePath = __DIR__ . "/database " ;
2630 $ this ->testingSqlitePath = "{$ databasePath }/ " ;
2731 $ baselinePath = "{$ databasePath }/baseline.sqlite " ;
2832 $ testingPath = "{$ databasePath }/testing.sqlite " ;
2933
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 );
3736
3837 require (__DIR__ . '/routes/web.php ' );
3938
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ public function testDetachRelationFlushesCache()
5656 'resources ' => [$ beforeStore ->id ],
5757 ]);
5858
59+ $ this ->response ->dump ();
5960 $ this ->response ->assertStatus (200 );
6061
6162 $ store = Store::with (['books ' ])->all ()->first ();
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+ # Created by .ignore support plugin (hsz.mobi)
2+ ! /baseline.sqlite
3+ ! /testing.sqlite
You can’t perform that action at this time.
0 commit comments