Skip to content

Commit

Permalink
feat: add FileLocatorCached::deleteCache()
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Oct 8, 2023
1 parent 40ea549 commit 777a3eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions system/Autoloader/FileLocatorCached.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ private function saveCache(): void
}
}

/**
* Delete cache data
*/
public function deleteCache(): void
{
$this->cacheHandler->delete($this->cacheKey);
}

protected function getNamespaces()
{
if (isset($this->cache['getNamespaces'])) {
Expand Down
9 changes: 9 additions & 0 deletions tests/system/Autoloader/FileLocatorCachedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ protected function setUp(): void
$fileLocator = new FileLocator($autoloader);
$this->locator = new FileLocatorCached($fileLocator, $this->handler);
}

public function testDeleteCache()
{
$this->assertNotSame([], $this->handler->get('FileLocatorCache'));

$this->locator->deleteCache();

$this->assertFalse($this->handler->get('FileLocatorCache'));
}
}

0 comments on commit 777a3eb

Please sign in to comment.