diff --git a/src/Cache/Noop.php b/src/Cache/Noop.php index be9f57abd..4df6387a7 100644 --- a/src/Cache/Noop.php +++ b/src/Cache/Noop.php @@ -2,6 +2,8 @@ namespace League\Flysystem\Cache; +use League\Flysystem\Util; + class Noop extends AbstractCache { /** @@ -38,9 +40,33 @@ public function setComplete($dirname, $recursive) */ public function storeContents($directory, array $contents, $recursive) { + if ($recursive) { + return $contents; + } + + foreach ($contents as $index => $object) { + $pathinfo = Util::pathinfo($object['path']); + $object = array_merge($pathinfo, $object); + + if ( ! $recursive && $object['dirname'] !== $directory) { + unset($contents[$index]); + continue; + } + + $contents[$index] = $object; + } + return $contents; } + /** + * {@inheritdoc} + */ + public function storeMiss($path) + { + return $this; + } + /** * {@inheritdoc} */ diff --git a/tests/FilesystemTests.php b/tests/FilesystemTests.php index 48dd9b8f8..7ad8a43d4 100644 --- a/tests/FilesystemTests.php +++ b/tests/FilesystemTests.php @@ -390,6 +390,7 @@ public function testNoop() $filesystem->write('test.txt', 'contents'); $this->assertTrue($filesystem->has('test.txt')); $this->assertInternalType('array', $filesystem->listContents()); + $this->assertInternalType('array', $filesystem->listContents('', true)); $cache = $filesystem->getCache(); $cache->setComplete('', false); $cache->flush(); @@ -403,6 +404,10 @@ public function testNoop() $this->assertFalse($cache->getVisibility('something')); $this->assertFalse($cache->listContents('', false)); $filesystem->delete('test.txt'); + + $this->assertEquals(array(), $cache->storeContents('unknwon', array( + array('path' => 'some/file.txt'), + ), false)); } /**