Skip to content

Commit

Permalink
Merge pull request #102 from hskrasek/master
Browse files Browse the repository at this point in the history
Update RackspaceAdapter->has() to catch OpenCloud ObjectNotFoundExceptio...
  • Loading branch information
frankdejonge committed Mar 4, 2014
2 parents ee607ae + dfaf088 commit 2cd198f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Adapter/Rackspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use League\Flysystem\Util;
use OpenCloud\ObjectStore\Resource\Container;
use OpenCloud\ObjectStore\Resource\DataObject;
use OpenCloud\ObjectStore\Exception\ObjectNotFoundException;
use Guzzle\Http\Exception\ClientErrorResponseException;

class Rackspace extends AbstractAdapter
Expand Down Expand Up @@ -163,6 +164,8 @@ public function has($path)
$object = $this->getObject($path);
} catch(ClientErrorResponseException $e) {
return false;
} catch(ObjectNotFoundException $e) {
return false;
}

return $this->normalizeObject($object);
Expand Down
8 changes: 8 additions & 0 deletions tests/RackspaceTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public function testHasFail()
$this->assertFalse($adapter->has('filename.ext'));
}

public function testHasNotFound()
{
$container = $this->getContainerMock();
$container->shouldReceive('getObject')->andThrow('OpenCloud\ObjectStore\Exception\ObjectNotFoundException');
$adapter = new Rackspace($container);
$this->assertFalse($adapter->has('filename.ext'));
}

public function testWrite()
{
$container = $this->getContainerMock();
Expand Down

0 comments on commit 2cd198f

Please sign in to comment.