diff --git a/src/SftpAdapter.php b/src/SftpAdapter.php index 013e13e..1473464 100644 --- a/src/SftpAdapter.php +++ b/src/SftpAdapter.php @@ -384,7 +384,7 @@ protected function normalizeListingObject($path, array $object) $permissions = $this->normalizePermissions($object['permissions']); $type = isset($object['type']) && ($object['type'] === 2) ? 'dir' : 'file'; - $timestamp = $object['mtime']; + $timestamp = (isset($object['mtime'])) ? $object['mtime'] : null; if ($type === 'dir') { return compact('path', 'timestamp', 'type'); diff --git a/tests/SftpAdapterTests.php b/tests/SftpAdapterTests.php index e6cf3f4..4d38f9e 100644 --- a/tests/SftpAdapterTests.php +++ b/tests/SftpAdapterTests.php @@ -733,4 +733,21 @@ public function testListContentsWithZeroNamedDir($filesystem, $adapter, $mock) $this->assertInternalType('array', $listing); $this->assertCount(1, $listing); } + + /** + * @dataProvider adapterProvider + */ + public function testListContentsWithoutMTime($filesystem, $adapter, $mock) + { + $mock->shouldReceive('rawlist')->andReturn([ + 'dirname' => [ + 'type' => NET_SFTP_TYPE_DIRECTORY, + 'size' => 20, + 'permissions' => 0777, + ], + ]); + $listing = $adapter->listContents(''); + $this->assertInternalType('array', $listing); + $this->assertCount(1, $listing); + } }