Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle listing objects without 'mtime' attribute in listContents() #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SftpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
17 changes: 17 additions & 0 deletions tests/SftpAdapterTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}