diff --git a/composer.json b/composer.json index 96de9d8..b8319fc 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,11 @@ "League\\Flysystem\\Memory\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "League\\Flysystem\\Memory\\Tests\\": "tests/" + } + }, "config": { "bin-dir": "bin" }, diff --git a/src/MemoryAdapter.php b/src/MemoryAdapter.php index 1331380..d741a5d 100644 --- a/src/MemoryAdapter.php +++ b/src/MemoryAdapter.php @@ -28,6 +28,7 @@ public function __construct(Config $config = null) $config = $config ?: new Config(); $this->storage['']['timestamp'] = $config->get('timestamp', time()); + $this->storage['']['visibility'] = $config->get('visibility', AdapterInterface::VISIBILITY_PUBLIC); } /** @@ -268,6 +269,7 @@ protected function doCreateDir($dirname, Config $config) $this->storage[$dirname]['type'] = 'dir'; $this->storage[$dirname]['timestamp'] = $config->get('timestamp', time()); + $this->storage[$dirname]['visibility'] = $config->get('visibility', AdapterInterface::VISIBILITY_PUBLIC); return true; } diff --git a/tests/MemoryAdapterTest.php b/tests/MemoryAdapterTest.php index a53b206..925a736 100644 --- a/tests/MemoryAdapterTest.php +++ b/tests/MemoryAdapterTest.php @@ -1,5 +1,8 @@ adapter->createDir('dir/subdir', new Config()); - $this->assertSame(3, count($result)); + $this->assertSame(4, count($result)); $this->assertSame('dir/subdir', $result['path']); $this->assertSame('dir', $result['type']); $this->arrayHasKey($result, 'timestamp'); + $this->arrayHasKey($result, 'visibility'); + $this->assertTrue($this->adapter->has('dir')); $this->assertTrue($this->adapter->has('dir/subdir')); $result = $this->adapter->createDir('dir', new Config()); - $this->assertSame(3, count($result)); + $this->assertSame(4, count($result)); $this->assertSame('dir', $result['path']); $this->assertSame('dir', $result['type']); $this->arrayHasKey($result, 'timestamp'); + $this->arrayHasKey($result, 'visibility'); $this->assertFalse($this->adapter->createDir('file.txt', new Config())); $this->assertFalse($this->adapter->createDir('file.txt/dir', new Config())); + + $this->adapter->createDir('public', new Config()); + $this->assertEquals(AdapterInterface::VISIBILITY_PUBLIC, $this->adapter->getVisibility('public')['visibility']); + + $this->adapter->createDir('private', new Config(['visibility' => AdapterInterface::VISIBILITY_PRIVATE])); + $this->assertEquals(AdapterInterface::VISIBILITY_PRIVATE, $this->adapter->getVisibility('private')['visibility']); } public function testDelete()