From 1f9e717b32b2bcac7a46d9d89ca77267f6c6b928 Mon Sep 17 00:00:00 2001 From: Nicolas MURE Date: Mon, 5 Feb 2018 10:01:00 +0100 Subject: [PATCH] bump up php-opencloud/openstack to v3.0.0 (php 7.2 support) --- .travis.yml | 1 + composer.json | 2 +- spec/Gaufrette/Adapter/OpenStackSpec.php | 52 ++++++++++++------------ src/Gaufrette/Adapter/OpenStack.php | 8 ++-- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1837a0ac..0b0da4e9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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; diff --git a/composer.json b/composer.json index a5b2909c1..d1a767e07 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/spec/Gaufrette/Adapter/OpenStackSpec.php b/spec/Gaufrette/Adapter/OpenStackSpec.php index 561c008ed..3b7398343 100644 --- a/spec/Gaufrette/Adapter/OpenStackSpec.php +++ b/spec/Gaufrette/Adapter/OpenStackSpec.php @@ -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; @@ -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!')); @@ -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; @@ -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; @@ -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(); @@ -213,7 +213,7 @@ 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)); @@ -221,7 +221,7 @@ function it_throws_file_not_found_exception_when_trying_to_fetch_the_mtime_of_an $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)); @@ -229,7 +229,7 @@ function it_throws_storage_failure_while_fetching_mtime(Container $container, Ob $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(); @@ -237,7 +237,7 @@ function it_deletes_file(Container $container, Object $object) $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)); @@ -245,7 +245,7 @@ function it_throws_file_not_found_exception_when_trying_to_delete_an_unexisting_ $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)); @@ -253,7 +253,7 @@ function it_throws_storage_failure_while_deleting(Container $container, Object $ $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); @@ -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(); @@ -291,7 +291,7 @@ 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)); @@ -299,7 +299,7 @@ function it_throws_file_not_found_exception_when_trying_to_get_the_checksum_of_a $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)); @@ -307,7 +307,7 @@ function it_throws_storage_failure_while_fetching_checksum(Container $container, $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([ @@ -319,7 +319,7 @@ 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)); @@ -327,7 +327,7 @@ function it_throws_file_not_found_exception_when_trying_to_get_the_metadata_of_a $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)); @@ -335,7 +335,7 @@ function it_throws_storage_failure_while_fetching_metadata(Container $container, $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([ @@ -345,7 +345,7 @@ 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)); @@ -353,7 +353,7 @@ function it_throws_file_not_found_exception_when_trying_to_set_the_metadata_of_a $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)); @@ -361,7 +361,7 @@ function it_throws_storage_failure_while_setting_metadata(Container $container, $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(); @@ -370,7 +370,7 @@ 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)); @@ -378,7 +378,7 @@ function it_throws_file_not_found_exception_when_trying_to_get_the_mime_type_of_ $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)); @@ -386,7 +386,7 @@ function it_throws_storage_failure_while_fetching_mime_type(Container $container $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(); @@ -395,7 +395,7 @@ 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)); @@ -403,7 +403,7 @@ function it_throws_file_not_found_exception_when_trying_to_get_the_size_of_an_un $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)); diff --git a/src/Gaufrette/Adapter/OpenStack.php b/src/Gaufrette/Adapter/OpenStack.php index 96068f2e1..bebd988f6 100644 --- a/src/Gaufrette/Adapter/OpenStack.php +++ b/src/Gaufrette/Adapter/OpenStack.php @@ -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; /** @@ -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 ) { @@ -323,7 +323,7 @@ public function size($key) * * @throws BadResponseError * - * @return Object + * @return StorageObject */ protected function getObject($key) { @@ -339,7 +339,7 @@ protected function getObject($key) * * @throws BadResponseError * - * @return Object + * @return StorageObject */ protected function retrieveObject($key) {