2
2
3
3
namespace Tests ;
4
4
5
- use Illuminate \Support \Facades \File ;
6
5
use Tests \Models \DefineHeadersModel ;
7
6
use Tests \Models \InferredIdModel ;
8
7
use Tests \Models \TestModel ;
@@ -24,11 +23,22 @@ public function setUp(): void
24
23
config (['sushi.cache-path ' => $ this ->cachePath = __DIR__ .'/cache ' ]);
25
24
}
26
25
26
+ public function tearDown (): void
27
+ {
28
+ $ this ->clearCacheDirectory ();
29
+ parent ::tearDown ();
30
+ }
31
+
32
+ private function clearCacheDirectory ()
33
+ {
34
+ array_map ('unlink ' , glob (config ('sushi.cache-path ' ).'/* ' ));
35
+ }
36
+
27
37
/** @test */
28
38
public function can_read_from_google_sheets ()
29
39
{
30
- File:: cleanDirectory ( config ( ' sushi.cache-path ' ) );
31
- $ this ->assertFileNotExists ('tests/cache/sushi-tests-models-test-model.sqlite ' );
40
+ $ this -> clearCacheDirectory ( );
41
+ $ this ->assertFileDoesNotExist ('tests/cache/sushi-tests-models-test-model.sqlite ' );
32
42
$ sheet = new TestModel ();
33
43
$ this ->assertIsArray ($ sheet ->getRows ());
34
44
}
@@ -78,7 +88,7 @@ public function can_invalidate_cache()
78
88
$ sheet = TestModel::find (1 );
79
89
$ this ->assertFileExists ('tests/cache/sushi-tests-models-test-model.sqlite ' );
80
90
$ sheet ->invalidateCache ();
81
- $ this ->assertFileNotExists ('tests/cache/sushi-tests-models-test-model.sqlite ' );
91
+ $ this ->assertFileDoesNotExist ('tests/cache/sushi-tests-models-test-model.sqlite ' );
82
92
$ sheet = TestModel::find (2 );
83
93
$ this ->assertEquals ('Justine ' , $ sheet ->name );
84
94
}
@@ -90,6 +100,6 @@ public function can_invalidate_cache_by_request()
90
100
$ this ->assertFileExists ('tests/cache/sushi-tests-models-test-model.sqlite ' );
91
101
$ response = $ this ->get ('/eloquent_sheets_forget/ ' .$ sheet ->cacheName );
92
102
$ response ->assertSuccessful ();
93
- $ this ->assertFileNotExists ('tests/cache/sushi-tests-test-model.sqlite ' );
103
+ $ this ->assertFileDoesNotExist ('tests/cache/sushi-tests-test-model.sqlite ' );
94
104
}
95
105
}
0 commit comments