File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1818 * FileLocator with Cache
1919 *
2020 * There is no FileLocator interface, so this extends FileLocator.
21+ *
22+ * @see \CodeIgniter\Autoloader\FileLocatorCachedTest
2123 */
2224final class FileLocatorCached extends FileLocator
2325{
@@ -80,6 +82,14 @@ private function saveCache(): void
8082 }
8183 }
8284
85+ /**
86+ * Delete cache data
87+ */
88+ public function deleteCache (): void
89+ {
90+ $ this ->cacheHandler ->delete ($ this ->cacheKey );
91+ }
92+
8393 protected function getNamespaces ()
8494 {
8595 if (isset ($ this ->cache ['getNamespaces ' ])) {
Original file line number Diff line number Diff line change 2222 */
2323final class FileLocatorCachedTest extends FileLocatorTest
2424{
25+ private FileVarExportHandler $ handler ;
2526 private FileLocator $ locator ;
2627
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+
2740 protected function setUp (): void
2841 {
2942 parent ::setUp ();
@@ -51,4 +64,20 @@ protected function setUp(): void
5164 $ fileLocator = new FileLocator ($ autoloader );
5265 $ this ->locator = new FileLocatorCached ($ fileLocator , $ this ->handler );
5366 }
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+ }
5483}
You can’t perform that action at this time.
0 commit comments