From 235ceb5370641522176ea5a38c0f970f19bfd8b6 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Mon, 16 Mar 2015 12:25:20 +0100 Subject: [PATCH] fix listContents() for subdirectories if parent is uppercase --- src/DropboxAdapter.php | 1 + tests/DropboxAdapterTests.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DropboxAdapter.php b/src/DropboxAdapter.php index 1a990d4..5acc894 100644 --- a/src/DropboxAdapter.php +++ b/src/DropboxAdapter.php @@ -243,6 +243,7 @@ public function listContents($directory = '', $recursive = false) foreach ($result['contents'] as $object) { $path = $this->removePathPrefix($object['path']); + $path = str_replace(mb_strtolower($directory), $directory, $path); $listing[] = $this->normalizeResponse($object, $path); if ($recursive && $object['is_dir']) { diff --git a/tests/DropboxAdapterTests.php b/tests/DropboxAdapterTests.php index d9f0a67..ad6b1f4 100644 --- a/tests/DropboxAdapterTests.php +++ b/tests/DropboxAdapterTests.php @@ -180,16 +180,19 @@ public function testListContents(Dropbox $adapter, $mock) { $mock->shouldReceive('getMetadataWithChildren')->andReturn( ['contents' => [ - ['is_dir' => true, 'path' => 'dirname'], + ['is_dir' => true, 'path' => 'Root/dirname'], ]], ['contents' => [ - ['is_dir' => false, 'path' => 'dirname/file'], + ['is_dir' => false, 'path' => 'root/dirname/file'], ]], false ); + $adapter->setPathPrefix(null); $result = $adapter->listContents('', true); $this->assertCount(2, $result); + $this->assertEquals('Root/dirname/file', $result[1]['path']); + $this->assertEquals([], $adapter->listContents('', false)); }