Skip to content

Commit

Permalink
bump up php-opencloud/openstack to v3.0.0 (php 7.2 support)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasmure committed Feb 5, 2018
1 parent bab50a6 commit 1f9e717
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ matrix:
include:
- php: '7.0'
- php: '7.1'
- php: '7.2'

before_install:
- echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"microsoft/windowsazure": "~0.4",
"microsoft/azure-storage": "~0.15.0",
"akeneo/phpspec-skip-example-extension": "^3.0",
"php-opencloud/openstack": "~2.0.15"
"php-opencloud/openstack": "~3.0.0"
},
"suggest": {
"knplabs/knp-gaufrette-bundle": "to use with Symfony",
Expand Down
52 changes: 26 additions & 26 deletions spec/Gaufrette/Adapter/OpenStackSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Identity\v2\Api;
use OpenStack\ObjectStore\v1\Models\Container;
use OpenStack\ObjectStore\v1\Models\Object;
use OpenStack\ObjectStore\v1\Models\StorageObject;
use OpenStack\ObjectStore\v1\Service;
use PhpSpec\ObjectBehavior;
use Psr\Http\Message\StreamInterface;
Expand Down Expand Up @@ -81,7 +81,7 @@ function it_throws_exeption_if_container_creation_fails(Service $objectStore)
$this->shouldThrow('\RuntimeException')->duringExists('test');
}

function it_reads_file(Container $container, Object $object)
function it_reads_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->download()->willReturn($this->getReadableStream('Hello World!'));
Expand Down Expand Up @@ -151,7 +151,7 @@ function it_list_objects(Container $container)

$generate = function () use ($client, $api) {
for ($i = 0; $i < 3; $i++) {
$object = new Object($client, $api);
$object = new StorageObject($client, $api);
$object->name = sprintf('object %d', $i + 1);

yield $object;
Expand Down Expand Up @@ -181,7 +181,7 @@ function it_list_objects_with_prefix(Container $container)

$generate = function () use ($client, $api) {
for ($i = 0; $i < 6; $i++) {
$object = new Object($client, $api);
$object = new StorageObject($client, $api);
$object->name = sprintf('%sobject %d', $i < 3 ? 'prefixed ' : '', $i + 1);

yield $object;
Expand All @@ -204,7 +204,7 @@ function it_throws_storage_failure_while_listing_objects_with_prefix(Container $
$this->shouldThrow('Gaufrette\Exception\StorageFailure')->duringlistKeys('prefix');
}

function it_fetches_mtime(Container $container, Object $object)
function it_fetches_mtime(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->shouldBeCalled();
Expand All @@ -213,47 +213,47 @@ function it_fetches_mtime(Container $container, Object $object)
$this->mtime('test')->shouldReturn('1497391354');
}

function it_throws_file_not_found_exception_when_trying_to_fetch_the_mtime_of_an_unexisting_file(Container $container, Object $object)
function it_throws_file_not_found_exception_when_trying_to_fetch_the_mtime_of_an_unexisting_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->willThrow($this->getBadResponseError(404));

$this->shouldThrow('Gaufrette\Exception\FileNotFound')->duringmtime('test');
}

function it_throws_storage_failure_while_fetching_mtime(Container $container, Object $object)
function it_throws_storage_failure_while_fetching_mtime(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->willThrow($this->getBadResponseError(400));

$this->shouldThrow('Gaufrette\Exception\StorageFailure')->duringmtime('test');
}

function it_deletes_file(Container $container, Object $object)
function it_deletes_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->delete()->shouldBeCalled();

$this->delete('test')->shouldNotThrow();
}

function it_throws_file_not_found_exception_when_trying_to_delete_an_unexisting_file(Container $container, Object $object)
function it_throws_file_not_found_exception_when_trying_to_delete_an_unexisting_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->delete()->willThrow($this->getBadResponseError(404));

$this->shouldThrow('Gaufrette\Exception\FileNotFound')->duringdelete('test');
}

function it_throws_storage_failure_while_deleting(Container $container, Object $object)
function it_throws_storage_failure_while_deleting(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->delete()->willThrow($this->getBadResponseError(400));

$this->shouldThrow('Gaufrette\Exception\StorageFailure')->duringdelete('test');
}

function it_renames_file(Container $container, Object $source)
function it_renames_file(Container $container, StorageObject $source)
{
$container->objectExists('dest')->willReturn(false);

Expand Down Expand Up @@ -282,7 +282,7 @@ function it_does_not_handle_directories()
$this->isDirectory('whatever')->shouldReturn(false);
}

function it_returns_checksum(Container $container, Object $object)
function it_returns_checksum(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->shouldBeCalled();
Expand All @@ -291,23 +291,23 @@ function it_returns_checksum(Container $container, Object $object)
$this->checksum('test')->shouldReturn('1234abcd');
}

function it_throws_file_not_found_exception_when_trying_to_get_the_checksum_of_an_unexisting_file(Container $container, Object $object)
function it_throws_file_not_found_exception_when_trying_to_get_the_checksum_of_an_unexisting_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->willThrow($this->getBadResponseError(404));

$this->shouldThrow('Gaufrette\Exception\FileNotFound')->duringchecksum('test');
}

function it_throws_storage_failure_while_fetching_checksum(Container $container, Object $object)
function it_throws_storage_failure_while_fetching_checksum(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->willThrow($this->getBadResponseError(400));

$this->shouldThrow('Gaufrette\Exception\StorageFailure')->duringchecksum('test');
}

function it_fetches_metadata(Container $container, Object $object)
function it_fetches_metadata(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->getMetadata()->willReturn([
Expand All @@ -319,23 +319,23 @@ function it_fetches_metadata(Container $container, Object $object)
]);
}

function it_throws_file_not_found_exception_when_trying_to_get_the_metadata_of_an_unexisting_file(Container $container, Object $object)
function it_throws_file_not_found_exception_when_trying_to_get_the_metadata_of_an_unexisting_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->getMetadata()->willThrow($this->getBadResponseError(404));

$this->shouldThrow('Gaufrette\Exception\FileNotFound')->duringgetMetadata('test');
}

function it_throws_storage_failure_while_fetching_metadata(Container $container, Object $object)
function it_throws_storage_failure_while_fetching_metadata(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->getMetadata()->willThrow($this->getBadResponseError(400));

$this->shouldThrow('Gaufrette\Exception\StorageFailure')->duringgetMetadata('test');
}

function it_set_metadata(Container $container, Object $object)
function it_set_metadata(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->resetMetadata([
Expand All @@ -345,23 +345,23 @@ function it_set_metadata(Container $container, Object $object)
$this->setMetadata('test', ['foo' => 'bar'])->shouldNotThrow();
}

function it_throws_file_not_found_exception_when_trying_to_set_the_metadata_of_an_unexisting_file(Container $container, Object $object)
function it_throws_file_not_found_exception_when_trying_to_set_the_metadata_of_an_unexisting_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->resetMetadata(['foo' => 'bar'])->willThrow($this->getBadResponseError(404));

$this->shouldThrow('Gaufrette\Exception\FileNotFound')->duringsetMetadata('test', ['foo' => 'bar']);
}

function it_throws_storage_failure_while_setting_metadata(Container $container, Object $object)
function it_throws_storage_failure_while_setting_metadata(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->resetMetadata(['foo' => 'bar'])->willThrow($this->getBadResponseError(400));

$this->shouldThrow('Gaufrette\Exception\StorageFailure')->duringsetMetadata('test', ['foo' => 'bar']);
}

function it_returns_mime_type(Container $container, Object $object)
function it_returns_mime_type(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->shouldBeCalled();
Expand All @@ -370,23 +370,23 @@ function it_returns_mime_type(Container $container, Object $object)
$this->mimeType('test')->shouldReturn('plain/text');
}

function it_throws_file_not_found_exception_when_trying_to_get_the_mime_type_of_an_unexisting_file(Container $container, Object $object)
function it_throws_file_not_found_exception_when_trying_to_get_the_mime_type_of_an_unexisting_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->willThrow($this->getBadResponseError(404));

$this->shouldThrow('Gaufrette\Exception\FileNotFound')->duringmimeType('test');
}

function it_throws_storage_failure_while_fetching_mime_type(Container $container, Object $object)
function it_throws_storage_failure_while_fetching_mime_type(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->willThrow($this->getBadResponseError(400));

$this->shouldThrow('Gaufrette\Exception\StorageFailure')->duringmimeType('test');
}

function it_returns_size(Container $container, Object $object)
function it_returns_size(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->shouldBeCalled();
Expand All @@ -395,15 +395,15 @@ function it_returns_size(Container $container, Object $object)
$this->size('test')->shouldReturn(42);
}

function it_throws_file_not_found_exception_when_trying_to_get_the_size_of_an_unexisting_file(Container $container, Object $object)
function it_throws_file_not_found_exception_when_trying_to_get_the_size_of_an_unexisting_file(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->willThrow($this->getBadResponseError(404));

$this->shouldThrow('Gaufrette\Exception\FileNotFound')->duringsize('test');
}

function it_throws_storage_failure_while_fetching_size(Container $container, Object $object)
function it_throws_storage_failure_while_fetching_size(Container $container, StorageObject $object)
{
$container->getObject('test')->willReturn($object);
$object->retrieve()->willThrow($this->getBadResponseError(400));
Expand Down
8 changes: 4 additions & 4 deletions src/Gaufrette/Adapter/OpenStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Gaufrette\Util;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\ObjectStore\v1\Models\Container;
use OpenStack\ObjectStore\v1\Models\Object;
use OpenStack\ObjectStore\v1\Models\StorageObject;
use OpenStack\ObjectStore\v1\Service;

/**
Expand Down Expand Up @@ -152,7 +152,7 @@ public function exists($key)
public function keys()
{
try {
return array_map(function (Object $object) {
return array_map(function (StorageObject $object) {
return $object->name;
}, iterator_to_array($this->getContainer()->listObjects()));
} catch (BadResponseError $e ) {
Expand Down Expand Up @@ -323,7 +323,7 @@ public function size($key)
*
* @throws BadResponseError
*
* @return Object
* @return StorageObject
*/
protected function getObject($key)
{
Expand All @@ -339,7 +339,7 @@ protected function getObject($key)
*
* @throws BadResponseError
*
* @return Object
* @return StorageObject
*/
protected function retrieveObject($key)
{
Expand Down

0 comments on commit 1f9e717

Please sign in to comment.