diff --git a/src/SftpAdapter.php b/src/SftpAdapter.php index 2eb1afb..04f81e0 100644 --- a/src/SftpAdapter.php +++ b/src/SftpAdapter.php @@ -503,7 +503,7 @@ public function getMetadata($path) $result = Util::map($info, $this->statMap); $result['type'] = $info['type'] === NET_SFTP_TYPE_DIRECTORY ? 'dir' : 'file'; - $result['visibility'] = $info['permissions'] & $this->permPublic ? 'public' : 'private'; + $result['visibility'] = $info['permissions'] & (0777 ^ $this->permPrivate) ? 'public' : 'private'; return $result; } diff --git a/tests/SftpAdapterTests.php b/tests/SftpAdapterTests.php index c897d93..63ce784 100644 --- a/tests/SftpAdapterTests.php +++ b/tests/SftpAdapterTests.php @@ -272,6 +272,24 @@ public function testGetVisibility($filesystem, $adapter, $mock) $this->assertEquals('public', $result); } + /** + * @dataProvider adapterProvider + */ + public function testGetVisibilityPrivate($filesystem, $adapter, $mock) + { + $mock->shouldReceive('stat')->andReturn([ + 'type' => NET_SFTP_TYPE_DIRECTORY, + 'mtime' => time(), + 'size' => 20, + 'permissions' => 0700, + ]); + $result = $adapter->getVisibility(uniqid().'object.ext'); + $this->assertInternalType('array', $result); + $result = $result['visibility']; + $this->assertInternalType('string', $result); + $this->assertEquals('private', $result); + } + /** * @dataProvider adapterProvider */