diff --git a/src/SwiftAdapter.php b/src/SwiftAdapter.php index 929e190..a251870 100755 --- a/src/SwiftAdapter.php +++ b/src/SwiftAdapter.php @@ -114,7 +114,7 @@ public function rename($path, $newpath) */ public function delete($path) { - $object = $this->getObject($path); + $object = $this->getObjectInstance($path); try { $object->delete(); @@ -253,17 +253,31 @@ public function getTimestamp($path) } /** - * Get an object. + * Get an object instance. * * @param string $path * * @return StorageObject */ - protected function getObject($path) + protected function getObjectInstance($path) { $location = $this->applyPathPrefix($path); $object = $this->container->getObject($location); + + return $object; + } + + /** + * Get an object instance and retrieve its metadata from storage. + * + * @param string $path + * + * @return StorageObject + */ + protected function getObject($path) + { + $object = $this->getObjectInstance($path); $object->retrieve(); return $object; diff --git a/tests/SwiftAdapterTest.php b/tests/SwiftAdapterTest.php index 8fd41c3..b320f06 100755 --- a/tests/SwiftAdapterTest.php +++ b/tests/SwiftAdapterTest.php @@ -3,6 +3,7 @@ use GuzzleHttp\Psr7\Stream; use League\Flysystem\Config; use org\bovigo\vfs\vfsStream; +use OpenStack\Common\Error\BadResponseError; use org\bovigo\vfs\content\LargeFileContent; use Nimbusoft\Flysystem\OpenStack\SwiftAdapter; @@ -121,7 +122,7 @@ public function testRename() public function testDelete() { - $this->object->shouldReceive('retrieve')->once(); + $this->object->shouldNotReceive('retrieve'); $this->object->shouldReceive('delete')->once(); $this->container->shouldReceive('getObject')