File tree 2 files changed +39
-0
lines changed
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 18
18
* FileLocator with Cache
19
19
*
20
20
* There is no FileLocator interface, so this extends FileLocator.
21
+ *
22
+ * @see \CodeIgniter\Autoloader\FileLocatorCachedTest
21
23
*/
22
24
final class FileLocatorCached extends FileLocator
23
25
{
@@ -80,6 +82,14 @@ private function saveCache(): void
80
82
}
81
83
}
82
84
85
+ /**
86
+ * Delete cache data
87
+ */
88
+ public function deleteCache (): void
89
+ {
90
+ $ this ->cacheHandler ->delete ($ this ->cacheKey );
91
+ }
92
+
83
93
protected function getNamespaces ()
84
94
{
85
95
if (isset ($ this ->cache ['getNamespaces ' ])) {
Original file line number Diff line number Diff line change 22
22
*/
23
23
final class FileLocatorCachedTest extends FileLocatorTest
24
24
{
25
+ private FileVarExportHandler $ handler ;
25
26
private FileLocator $ locator ;
26
27
28
+ public static function tearDownAfterClass (): void
29
+ {
30
+ parent ::tearDownAfterClass ();
31
+
32
+ // Delete cache file.
33
+ $ autoloader = new Autoloader ();
34
+ $ handler = new FileVarExportHandler ();
35
+ $ fileLocator = new FileLocator ($ autoloader );
36
+ $ locator = new FileLocatorCached ($ fileLocator , $ handler );
37
+ $ locator ->deleteCache ();
38
+ }
39
+
27
40
protected function setUp (): void
28
41
{
29
42
parent ::setUp ();
@@ -51,4 +64,20 @@ protected function setUp(): void
51
64
$ fileLocator = new FileLocator ($ autoloader );
52
65
$ this ->locator = new FileLocatorCached ($ fileLocator , $ this ->handler );
53
66
}
67
+
68
+ protected function tearDown (): void
69
+ {
70
+ $ this ->locator ->__destruct ();
71
+
72
+ parent ::tearDown ();
73
+ }
74
+
75
+ public function testDeleteCache ()
76
+ {
77
+ $ this ->assertNotSame ([], $ this ->handler ->get ('FileLocatorCache ' ));
78
+
79
+ $ this ->locator ->deleteCache ();
80
+
81
+ $ this ->assertFalse ($ this ->handler ->get ('FileLocatorCache ' ));
82
+ }
54
83
}
You can’t perform that action at this time.
0 commit comments