From 9b53613b21daf8b2e6464517c7cc128f5d4f4d1f Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Thu, 7 Dec 2017 22:43:47 +0800 Subject: [PATCH 01/16] Added php7.2 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ca85ee1..fcea9433 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,6 @@ language: php sudo: false -dist: precise - cache: directories: - $HOME/.composer/cache @@ -12,6 +10,7 @@ matrix: include: - php: 7.0 - php: 7.1 + - php: 7.2 - php: nightly allow_failures: - php: nightly From 8250877cb498721da9120ca543a24055baa6f147 Mon Sep 17 00:00:00 2001 From: mrwogu Date: Sat, 16 Dec 2017 21:02:16 +0100 Subject: [PATCH 02/16] Renamed model Object to StorageObject --- samples/object_store/v1/objects/create.php | 2 +- .../v1/objects/create_from_stream.php | 2 +- .../v1/objects/create_large_object.php | 2 +- samples/object_store/v1/objects/get.php | 2 +- samples/object_store/v1/objects/list.php | 2 +- src/ObjectStore/v1/Models/Container.php | 22 +++++++++---------- .../Models/{Object.php => StorageObject.php} | 2 +- .../ObjectStore/v1/Models/ContainerTest.php | 6 ++--- .../unit/ObjectStore/v1/Models/ObjectTest.php | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) rename src/ObjectStore/v1/Models/{Object.php => StorageObject.php} (98%) diff --git a/samples/object_store/v1/objects/create.php b/samples/object_store/v1/objects/create.php index 6ab81c09..1541c22c 100644 --- a/samples/object_store/v1/objects/create.php +++ b/samples/object_store/v1/objects/create.php @@ -17,7 +17,7 @@ 'content' => '{objectContent}', ]; -/** @var \OpenStack\ObjectStore\v1\Models\Object $object */ +/** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ $object = $openstack->objectStoreV1() ->getContainer('{containerName}') ->createObject($options); diff --git a/samples/object_store/v1/objects/create_from_stream.php b/samples/object_store/v1/objects/create_from_stream.php index 5873a3ae..eed9fa20 100644 --- a/samples/object_store/v1/objects/create_from_stream.php +++ b/samples/object_store/v1/objects/create_from_stream.php @@ -22,7 +22,7 @@ 'stream' => $stream, ]; -/** @var \OpenStack\ObjectStore\v1\Models\Object $object */ +/** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ $object = $openstack->objectStoreV1() ->getContainer('{containerName}') ->createObject($options); diff --git a/samples/object_store/v1/objects/create_large_object.php b/samples/object_store/v1/objects/create_large_object.php index 87cfc7a7..52f03b3f 100644 --- a/samples/object_store/v1/objects/create_large_object.php +++ b/samples/object_store/v1/objects/create_large_object.php @@ -27,7 +27,7 @@ $options['segmentContainer'] = 'test_segments'; -/** @var \OpenStack\ObjectStore\v1\Models\Object $object */ +/** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ $object = $openstack->objectStoreV1() ->getContainer('test') ->createLargeObject($options); diff --git a/samples/object_store/v1/objects/get.php b/samples/object_store/v1/objects/get.php index 3789bdab..b7b42f3a 100644 --- a/samples/object_store/v1/objects/get.php +++ b/samples/object_store/v1/objects/get.php @@ -12,7 +12,7 @@ 'scope' => ['project' => ['id' => '{projectId}']] ]); -/** @var \OpenStack\ObjectStore\v1\Models\Object $object */ +/** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ $object = $openstack->objectStoreV1() ->getContainer('{containerName}') ->getObject('{objectName}'); diff --git a/samples/object_store/v1/objects/list.php b/samples/object_store/v1/objects/list.php index fa7daef5..8d08cf0d 100644 --- a/samples/object_store/v1/objects/list.php +++ b/samples/object_store/v1/objects/list.php @@ -16,5 +16,5 @@ ->getContainer('{containerName}'); foreach ($container->listObjects() as $object) { - /** @var \OpenStack\ObjectStore\v1\Models\Object $object */ + /** @var \OpenStack\ObjectStore\v1\Models\StorageObject $object */ } diff --git a/src/ObjectStore/v1/Models/Container.php b/src/ObjectStore/v1/Models/Container.php index 52704546..31414a94 100644 --- a/src/ObjectStore/v1/Models/Container.php +++ b/src/ObjectStore/v1/Models/Container.php @@ -61,7 +61,7 @@ public function populateFromResponse(ResponseInterface $response): self public function listObjects(array $options = [], callable $mapFn = null): \Generator { $options = array_merge($options, ['name' => $this->name, 'format' => 'json']); - return $this->model(Object::class)->enumerate($this->api->getContainer(), $options, $mapFn); + return $this->model(StorageObject::class)->enumerate($this->api->getContainer(), $options, $mapFn); } /** @@ -136,17 +136,17 @@ public function getMetadata(): array } /** - * Retrieves an Object and populates its `name` and `containerName` properties according to the name provided and + * Retrieves an StorageObject and populates its `name` and `containerName` properties according to the name provided and * the name of this container. A HTTP call will not be executed by default - you need to call - * {@see Object::retrieve} or {@see Object::download} on the returned Object object to do that. + * {@see StorageObject::retrieve} or {@see StorageObject::download} on the returned StorageObject object to do that. * * @param string $name The name of the object * - * @return Object + * @return StorageObject */ - public function getObject($name): Object + public function getObject($name): StorageObject { - return $this->model(Object::class, ['containerName' => $this->name, 'name' => $name]); + return $this->model(StorageObject::class, ['containerName' => $this->name, 'name' => $name]); } /** @@ -179,9 +179,9 @@ public function objectExists(string $name): bool * * @return Object */ - public function createObject(array $data): Object + public function createObject(array $data): StorageObject { - return $this->model(Object::class)->create($data + ['containerName' => $this->name]); + return $this->model(StorageObject::class)->create($data + ['containerName' => $this->name]); } /** @@ -195,9 +195,9 @@ public function createObject(array $data): Object * @param string $data['segmentPrefix'] The prefix that will come before each segment. If omitted, a default * is used: name/timestamp/filesize * - * @return Object + * @return StorageObject */ - public function createLargeObject(array $data): Object + public function createLargeObject(array $data): StorageObject { /** @var \Psr\Http\Message\StreamInterface $stream */ $stream = $data['stream']; @@ -218,7 +218,7 @@ public function createLargeObject(array $data): Object $count = 0; while (!$stream->eof() && $count < round($stream->getSize() / $segmentSize)) { - $promises[] = $this->model(Object::class)->createAsync([ + $promises[] = $this->model(StorageObject::class)->createAsync([ 'name' => sprintf("%s/%d", $segmentPrefix, ++$count), 'stream' => new LimitStream($stream, $segmentSize, ($count - 1) * $segmentSize), 'containerName' => $segmentContainer, diff --git a/src/ObjectStore/v1/Models/Object.php b/src/ObjectStore/v1/Models/StorageObject.php similarity index 98% rename from src/ObjectStore/v1/Models/Object.php rename to src/ObjectStore/v1/Models/StorageObject.php index 2f255817..ca9302be 100644 --- a/src/ObjectStore/v1/Models/Object.php +++ b/src/ObjectStore/v1/Models/StorageObject.php @@ -14,7 +14,7 @@ /** * @property \OpenStack\ObjectStore\v1\Api $api */ -class Object extends OperatorResource implements Creatable, Deletable, HasMetadata +class StorageObject extends OperatorResource implements Creatable, Deletable, HasMetadata { use MetadataTrait; diff --git a/tests/unit/ObjectStore/v1/Models/ContainerTest.php b/tests/unit/ObjectStore/v1/Models/ContainerTest.php index 6e83b8a4..78fe4c65 100644 --- a/tests/unit/ObjectStore/v1/Models/ContainerTest.php +++ b/tests/unit/ObjectStore/v1/Models/ContainerTest.php @@ -8,7 +8,7 @@ use OpenStack\Common\Error\BadResponseError; use OpenStack\ObjectStore\v1\Api; use OpenStack\ObjectStore\v1\Models\Container; -use OpenStack\ObjectStore\v1\Models\Object; +use OpenStack\ObjectStore\v1\Models\StorageObject; use OpenStack\Test\TestCase; use Prophecy\Argument; @@ -95,7 +95,7 @@ public function test_It_Gets_Object() { $object = $this->container->getObject('foo.txt'); - $this->assertInstanceOf(Object::class, $object); + $this->assertInstanceOf(StorageObject::class, $object); $this->assertEquals('foo.txt', $object->name); } @@ -135,7 +135,7 @@ public function test_it_lists_objects() ->willReturn($this->getFixture('GET_Container')); foreach ($this->container->listObjects(['limit' => 2]) as $object) { - $this->assertInstanceOf(Object::class, $object); + $this->assertInstanceOf(StorageObject::class, $object); } } diff --git a/tests/unit/ObjectStore/v1/Models/ObjectTest.php b/tests/unit/ObjectStore/v1/Models/ObjectTest.php index 2dd54a3e..85202b82 100644 --- a/tests/unit/ObjectStore/v1/Models/ObjectTest.php +++ b/tests/unit/ObjectStore/v1/Models/ObjectTest.php @@ -5,7 +5,7 @@ use function GuzzleHttp\Psr7\uri_for; use GuzzleHttp\Psr7\Stream; use OpenStack\ObjectStore\v1\Api; -use OpenStack\ObjectStore\v1\Models\Object; +use OpenStack\ObjectStore\v1\Models\StorageObject; use OpenStack\Test\TestCase; class ObjectTest extends TestCase @@ -21,7 +21,7 @@ public function setUp() $this->rootFixturesDir = dirname(__DIR__); - $this->object = new Object($this->client->reveal(), new Api()); + $this->object = new StorageObject($this->client->reveal(), new Api()); $this->object->containerName = self::CONTAINER; $this->object->name = self::NAME; } From 3b5e574f9ee99994a7660e1f0e8b923ed7ebcd8b Mon Sep 17 00:00:00 2001 From: mrwogu Date: Sat, 16 Dec 2017 21:14:56 +0100 Subject: [PATCH 03/16] Updated php-cs-fixer to 2.9.0 Speechless --- .travis.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fcea9433..de1ef134 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: before_script: - composer install --prefer-source - vendor/bin/parallel-lint --exclude vendor . - - vendor/bin/php-cs-fixer fix --dry-run --diff --level psr2 . + - vendor/bin/php-cs-fixer fix --dry-run --diff --rules=@PSR2 . - phpenv config-add ./xdebug.ini after_script: diff --git a/composer.json b/composer.json index 6b699598..a73b3b9b 100644 --- a/composer.json +++ b/composer.json @@ -49,6 +49,6 @@ "psr/log": "~1.0", "satooshi/php-coveralls": "~1.0", "jakub-onderka/php-parallel-lint": "0.*", - "friendsofphp/php-cs-fixer": "^1.0" + "friendsofphp/php-cs-fixer": "^2.9" } } From 3b618fc5f56488c65db79a9e21642e62fd58bf96 Mon Sep 17 00:00:00 2001 From: mrwogu Date: Sat, 16 Dec 2017 21:16:31 +0100 Subject: [PATCH 04/16] Fixed PSR2 php-cs-fixer rules --- src/Common/Api/Parameter.php | 9 +++++++-- src/Common/Error/Builder.php | 14 ++++++++++---- src/Common/Service/Builder.php | 3 ++- src/Common/Transport/JsonSerializer.php | 3 ++- src/Identity/v2/Models/Catalog.php | 5 ++++- src/Identity/v3/Models/Catalog.php | 5 ++++- src/Identity/v3/Service.php | 9 +++++++-- tests/integration/Compute/v2/CoreTest.php | 3 ++- 8 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/Common/Api/Parameter.php b/src/Common/Api/Parameter.php index 15ab8369..136ff016 100644 --- a/src/Common/Api/Parameter.php +++ b/src/Common/Api/Parameter.php @@ -207,7 +207,9 @@ private function validateEnums($userValues) { if (!empty($this->enum) && $this->type == 'string' && !in_array($userValues, $this->enum)) { throw new \Exception(sprintf( - 'The only permitted values are %s. You provided %s', implode(', ', $this->enum), print_r($userValues, true) + 'The only permitted values are %s. You provided %s', + implode(', ', $this->enum), + print_r($userValues, true) )); } } @@ -217,7 +219,10 @@ private function validateType($userValues) if (!$this->hasCorrectType($userValues)) { throw new \Exception(sprintf( 'The key provided "%s" has the wrong value type. You provided %s (%s) but was expecting %s', - $this->name, print_r($userValues, true), gettype($userValues), $this->type + $this->name, + print_r($userValues, true), + gettype($userValues), + $this->type )); } } diff --git a/src/Common/Error/Builder.php b/src/Common/Error/Builder.php index 304e54eb..ad693b7c 100644 --- a/src/Common/Error/Builder.php +++ b/src/Common/Error/Builder.php @@ -116,8 +116,11 @@ public function httpError(RequestInterface $request, ResponseInterface $response { $message = $this->header('HTTP Error'); - $message .= sprintf("The remote server returned a \"%d %s\" error for the following transaction:\n\n", - $response->getStatusCode(), $response->getReasonPhrase()); + $message .= sprintf( + "The remote server returned a \"%d %s\" error for the following transaction:\n\n", + $response->getStatusCode(), + $response->getReasonPhrase() + ); $message .= $this->header('Request'); $message .= trim($this->str($request)) . PHP_EOL . PHP_EOL; @@ -163,8 +166,11 @@ public function userInputError(string $expectedType, $userValue, string $further { $message = $this->header('User Input Error'); - $message .= sprintf("%s was expected, but the following value was passed in:\n\n%s\n", - $expectedType, print_r($userValue, true)); + $message .= sprintf( + "%s was expected, but the following value was passed in:\n\n%s\n", + $expectedType, + print_r($userValue, true) + ); $message .= "Please ensure that the value adheres to the expectation above. "; diff --git a/src/Common/Service/Builder.php b/src/Common/Service/Builder.php index ee7b5442..f1c1d155 100644 --- a/src/Common/Service/Builder.php +++ b/src/Common/Service/Builder.php @@ -166,7 +166,8 @@ private function mergeOptions(array $serviceOptions): array if (!isset($options['identityService']) || !($options['identityService'] instanceof IdentityService)) { throw new \InvalidArgumentException(sprintf( - '"identityService" must be specified and implement %s', IdentityService::class + '"identityService" must be specified and implement %s', + IdentityService::class )); } diff --git a/src/Common/Transport/JsonSerializer.php b/src/Common/Transport/JsonSerializer.php index 24a62a31..826d396c 100644 --- a/src/Common/Transport/JsonSerializer.php +++ b/src/Common/Transport/JsonSerializer.php @@ -101,7 +101,8 @@ private function serializeObjectValue($value) } elseif (!($value instanceof \stdClass)) { throw new \InvalidArgumentException(sprintf( 'When an object value is provided, it must either be \stdClass or implement the Serializable ' - . 'interface, you provided %s', print_r($value, true) + . 'interface, you provided %s', + print_r($value, true) )); } } diff --git a/src/Identity/v2/Models/Catalog.php b/src/Identity/v2/Models/Catalog.php index 6081507a..f2cd02c2 100644 --- a/src/Identity/v2/Models/Catalog.php +++ b/src/Identity/v2/Models/Catalog.php @@ -61,7 +61,10 @@ public function getServiceUrl( throw new \RuntimeException(sprintf( "Endpoint URL could not be found in the catalog for this service.\nName: %s\nType: %s\nRegion: %s\nURL type: %s", - $serviceName, $serviceType, $region, $urlType + $serviceName, + $serviceType, + $region, + $urlType )); } } diff --git a/src/Identity/v3/Models/Catalog.php b/src/Identity/v3/Models/Catalog.php index 9fc1a7f9..55b39c4a 100644 --- a/src/Identity/v3/Models/Catalog.php +++ b/src/Identity/v3/Models/Catalog.php @@ -56,7 +56,10 @@ public function getServiceUrl(string $name, string $type, string $region, string throw new \RuntimeException(sprintf( "Endpoint URL could not be found in the catalog for this service.\nName: %s\nType: %s\nRegion: %s\nURL type: %s", - $name, $type, $region, $urlType + $name, + $type, + $region, + $urlType )); } } diff --git a/src/Identity/v3/Service.php b/src/Identity/v3/Service.php index 4fca5626..b29261cd 100644 --- a/src/Identity/v3/Service.php +++ b/src/Identity/v3/Service.php @@ -50,8 +50,13 @@ public function authenticate(array $options): array return [$token, $baseUrl]; } - throw new \RuntimeException(sprintf("No service found with type [%s] name [%s] region [%s] interface [%s]", - $type, $name, $region, $interface)); + throw new \RuntimeException(sprintf( + "No service found with type [%s] name [%s] region [%s] interface [%s]", + $type, + $name, + $region, + $interface + )); } /** diff --git a/tests/integration/Compute/v2/CoreTest.php b/tests/integration/Compute/v2/CoreTest.php index ae4c644c..eb829b73 100644 --- a/tests/integration/Compute/v2/CoreTest.php +++ b/tests/integration/Compute/v2/CoreTest.php @@ -672,7 +672,8 @@ private function attachVolumeToServer() $this->volume->waitUntil('in-use'); - $this->logStep('Attached volume {volumeId} to server {serverId} with volume attachment id {volumeAttachmentId}', + $this->logStep( + 'Attached volume {volumeId} to server {serverId} with volume attachment id {volumeAttachmentId}', array_merge($replacements, ['{volumeAttachmentId}' => $volumeAttachment->id]) ); } From dc927f4afe54247c597c0fac6f1a121d863024d9 Mon Sep 17 00:00:00 2001 From: mrwogu Date: Sat, 16 Dec 2017 21:25:02 +0100 Subject: [PATCH 05/16] Updated PHPUnit to 6.5 (stable) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a73b3b9b..d68c7c30 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "justinrainbow/json-schema": "~5.2" }, "require-dev": { - "phpunit/phpunit": "~4.0", + "phpunit/phpunit": "^6.5", "sami/sami": "dev-master", "psr/log": "~1.0", "satooshi/php-coveralls": "~1.0", From a5916e85e55f4262b29752a704b0b46c1ae4ea75 Mon Sep 17 00:00:00 2001 From: mrwogu Date: Sat, 16 Dec 2017 22:07:47 +0100 Subject: [PATCH 06/16] Updated tests to use new version PHPUnit --- tests/integration/TestCase.php | 2 +- tests/unit/Common/Api/OperationTest.php | 2 +- tests/unit/Common/Api/ParameterTest.php | 2 +- tests/unit/Common/Error/BuilderTest.php | 2 +- tests/unit/Common/JsonPathTest.php | 2 +- tests/unit/Common/Transport/JsonSerializerTest.php | 2 +- tests/unit/TestCase.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/integration/TestCase.php b/tests/integration/TestCase.php index cebb1953..f382e301 100644 --- a/tests/integration/TestCase.php +++ b/tests/integration/TestCase.php @@ -5,7 +5,7 @@ use OpenStack\Common\Resource\Deletable; use Psr\Log\LoggerInterface; -abstract class TestCase extends \PHPUnit_Framework_TestCase implements TestInterface +abstract class TestCase extends \PHPUnit\Framework\TestCase implements TestInterface { protected $logger; private $startPoint; diff --git a/tests/unit/Common/Api/OperationTest.php b/tests/unit/Common/Api/OperationTest.php index 36adf3bd..68e0eaa9 100644 --- a/tests/unit/Common/Api/OperationTest.php +++ b/tests/unit/Common/Api/OperationTest.php @@ -6,7 +6,7 @@ use OpenStack\Common\Api\Parameter; use OpenStack\Test\Fixtures\ComputeV2Api; -class OperationTest extends \PHPUnit_Framework_TestCase +class OperationTest extends \PHPUnit\Framework\TestCase { private $operation; diff --git a/tests/unit/Common/Api/ParameterTest.php b/tests/unit/Common/Api/ParameterTest.php index 79aaa118..320d25be 100644 --- a/tests/unit/Common/Api/ParameterTest.php +++ b/tests/unit/Common/Api/ParameterTest.php @@ -5,7 +5,7 @@ use OpenStack\Common\Api\Parameter; use OpenStack\Test\Fixtures\ComputeV2Api; -class ParameterTest extends \PHPUnit_Framework_TestCase +class ParameterTest extends \PHPUnit\Framework\TestCase { private $param; private $data; diff --git a/tests/unit/Common/Error/BuilderTest.php b/tests/unit/Common/Error/BuilderTest.php index 0c91e697..191fbd23 100644 --- a/tests/unit/Common/Error/BuilderTest.php +++ b/tests/unit/Common/Error/BuilderTest.php @@ -13,7 +13,7 @@ use OpenStack\Common\Error\Builder; use OpenStack\Common\Error\UserInputError; -class BuilderTest extends \PHPUnit_Framework_TestCase +class BuilderTest extends \PHPUnit\Framework\TestCase { private $builder; private $client; diff --git a/tests/unit/Common/JsonPathTest.php b/tests/unit/Common/JsonPathTest.php index 5648e327..42edb91c 100644 --- a/tests/unit/Common/JsonPathTest.php +++ b/tests/unit/Common/JsonPathTest.php @@ -4,7 +4,7 @@ use OpenStack\Common\JsonPath; -class JsonPathTest extends \PHPUnit_Framework_TestCase +class JsonPathTest extends \PHPUnit\Framework\TestCase { private $jsonPath; diff --git a/tests/unit/Common/Transport/JsonSerializerTest.php b/tests/unit/Common/Transport/JsonSerializerTest.php index 652c7219..50a54e5a 100644 --- a/tests/unit/Common/Transport/JsonSerializerTest.php +++ b/tests/unit/Common/Transport/JsonSerializerTest.php @@ -8,7 +8,7 @@ use OpenStack\Common\Resource\OperatorResource; use OpenStack\Common\Transport\JsonSerializer; -class JsonSerializerTest extends \PHPUnit_Framework_TestCase +class JsonSerializerTest extends \PHPUnit\Framework\TestCase { /** @var JsonSerializer */ private $serializer; diff --git a/tests/unit/TestCase.php b/tests/unit/TestCase.php index 3a372dd0..30f14879 100644 --- a/tests/unit/TestCase.php +++ b/tests/unit/TestCase.php @@ -8,7 +8,7 @@ use GuzzleHttp\Psr7\Response; use Prophecy\Argument; -abstract class TestCase extends \PHPUnit_Framework_TestCase +abstract class TestCase extends \PHPUnit\Framework\TestCase { /** @var \Prophecy\Prophecy\ObjectProphecy */ protected $client; From c747738680546396d3e76dd777c37a1a7c170e5e Mon Sep 17 00:00:00 2001 From: mrwogu Date: Tue, 19 Dec 2017 14:40:01 +0100 Subject: [PATCH 07/16] Fixed PHPUnit tests --- tests/unit/Common/Api/OperatorTraitTest.php | 8 +++++++- tests/unit/Common/Error/BuilderTest.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/unit/Common/Api/OperatorTraitTest.php b/tests/unit/Common/Api/OperatorTraitTest.php index c0589141..7c913123 100644 --- a/tests/unit/Common/Api/OperatorTraitTest.php +++ b/tests/unit/Common/Api/OperatorTraitTest.php @@ -28,7 +28,7 @@ public function setUp() $this->def = [ 'method' => 'GET', - 'path' => 'test', + 'path' => 'test', 'params' => [], ]; @@ -48,6 +48,8 @@ public function test_it_sends_a_request_when_operations_are_executed() $this->client->request('GET', 'test', ['headers' => []])->willReturn(new Response()); $this->operator->execute($this->def, []); + + self::assertTrue(true); } public function test_it_sends_a_request_when_async_operations_are_executed() @@ -55,6 +57,8 @@ public function test_it_sends_a_request_when_async_operations_are_executed() $this->client->requestAsync('GET', 'test', ['headers' => []])->willReturn(new Promise()); $this->operator->executeAsync($this->def, []); + + self::assertTrue(true); } public function test_it_wraps_sequential_ops_in_promise_when_async_is_appended_to_method_name() @@ -90,10 +94,12 @@ public function test_it_returns_a_model_instance() { $this->assertInstanceOf(ResourceInterface::class, $this->operator->model(TestResource::class)); } + public function test_it_populates_models_from_response() { $this->assertInstanceOf(ResourceInterface::class, $this->operator->model(TestResource::class, new Response(200))); } + public function test_it_populates_models_from_arrays() { $data = ['flavor' => [], 'image' => []]; diff --git a/tests/unit/Common/Error/BuilderTest.php b/tests/unit/Common/Error/BuilderTest.php index 191fbd23..f5710a1b 100644 --- a/tests/unit/Common/Error/BuilderTest.php +++ b/tests/unit/Common/Error/BuilderTest.php @@ -18,7 +18,7 @@ class BuilderTest extends \PHPUnit\Framework\TestCase private $builder; private $client; - public function __construct() + public function setUp() { $this->client = $this->prophesize(ClientInterface::class); $this->builder = new Builder($this->client->reveal()); From 546ff446866e691847b338a296578c349652b2fd Mon Sep 17 00:00:00 2001 From: mrwogu Date: Tue, 19 Dec 2017 20:30:04 +0100 Subject: [PATCH 08/16] Removed return type for two methods in AbstractResource --- src/Common/Resource/AbstractResource.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Common/Resource/AbstractResource.php b/src/Common/Resource/AbstractResource.php index a3f2f51a..1adaf2b5 100644 --- a/src/Common/Resource/AbstractResource.php +++ b/src/Common/Resource/AbstractResource.php @@ -42,7 +42,7 @@ abstract class AbstractResource implements ResourceInterface, Serializable * * @return AbstractResource */ - public function populateFromResponse(ResponseInterface $response): self + public function populateFromResponse(ResponseInterface $response) { if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { $json = Utils::jsonDecode($response); @@ -61,7 +61,7 @@ public function populateFromResponse(ResponseInterface $response): self * * @return mixed|void */ - public function populateFromArray(array $array): self + public function populateFromArray(array $array) { $aliases = $this->getAliases(); From d21c534884eaac2f85863dc2b83748d0bb54914f Mon Sep 17 00:00:00 2001 From: mrwogu Date: Sat, 6 Jan 2018 16:04:09 +0100 Subject: [PATCH 09/16] Updated docks & readme --- README.md | 4 ++++ doc/services/object-store/v1/objects.rst | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 01d40516..930630f7 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ OpenStack services, and versions of services, are supported. * [Contributing guide](/CONTRIBUTING.md) * [Code of Conduct](/CODE_OF_CONDUCT.md) +## Backward incompatibility + +Due to new [object typehint](https://wiki.php.net/rfc/object-typehint) since PHP 7.2, class `OpenStack\ObjectStore\v1\Models\Object` had to be renamed to `OpenStack\ObjectStore\v1\Models\StorageObject` + ## Getting help - Meet us on Slack: https://phpopencloud.slack.com ([Get your invitation](https://slackpass.io/phpopencloud)) diff --git a/doc/services/object-store/v1/objects.rst b/doc/services/object-store/v1/objects.rst index f2a2ff88..b958a03c 100644 --- a/doc/services/object-store/v1/objects.rst +++ b/doc/services/object-store/v1/objects.rst @@ -27,7 +27,7 @@ Download an object ------------------ .. sample:: object_store/v1/objects/download.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Object.html#method_download +.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_download As you will notice, a Stream_ object is returned by this call. For more information about dealing with streams, please consult `Guzzle's docs`_. @@ -88,19 +88,19 @@ Copy object ----------- .. sample:: object_store/v1/objects/copy.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Object.html#method_copy +.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_copy Delete object ------------- .. sample:: object_store/v1/objects/delete.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Object.html#method_delete +.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_delete Get metadata ------------ .. sample:: object_store/v1/objects/get_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Object.html#method_getMetadata +.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_getMetadata The returned value will be a standard associative array, or hash, containing arbitrary key/value pairs. These will correspond to the values set either when the object was created, or when a previous ``mergeMetadata`` or @@ -110,7 +110,7 @@ Replace all metadata with new values ------------------------------------ .. sample:: object_store/v1/objects/reset_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Object.html#method_resetMetadata +.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_resetMetadata In order to replace all existing metadata with a set of new values, you can use this operation. Any existing metadata items which not specified in the new set will be removed. For example, say an account has the following metadata @@ -140,7 +140,7 @@ Merge new metadata values with existing --------------------------------------- .. sample:: object_store/v1/objects/merge_metadata.php -.. refdoc:: OpenStack/ObjectStore/v1/Models/Object.html#method_mergeMetadata +.. refdoc:: OpenStack/ObjectStore/v1/Models/StorageObject.html#method_mergeMetadata In order to merge a set of new metadata values with the existing metadata set, you can use this operation. Any existing metadata items which are not specified in the new set will be preserved. For example, say an account has the following From fbddef50aed3753f21ac40db16b9ae0e5d7fa33a Mon Sep 17 00:00:00 2001 From: mrwogu Date: Sat, 27 Jan 2018 18:01:13 +0100 Subject: [PATCH 10/16] Fixed code to PSR2 compatibility --- .../Layer3/Models/FloatingIpTest.php | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/tests/unit/Networking/v2/Extensions/Layer3/Models/FloatingIpTest.php b/tests/unit/Networking/v2/Extensions/Layer3/Models/FloatingIpTest.php index fe757adc..f7e5e51f 100644 --- a/tests/unit/Networking/v2/Extensions/Layer3/Models/FloatingIpTest.php +++ b/tests/unit/Networking/v2/Extensions/Layer3/Models/FloatingIpTest.php @@ -49,20 +49,34 @@ public function test_it_retrieves() $this->floatingIp->retrieve(); - $this->assertEquals('376da547-b977-4cfe-9cba-275c80debf57', - $this->floatingIp->floatingNetworkId); - $this->assertEquals('d23abc8d-2991-4a55-ba98-2aaea84cc72f', - $this->floatingIp->routerId); - $this->assertEquals('10.0.0.3', - $this->floatingIp->fixedIpAddress); - $this->assertEquals('172.24.4.228', - $this->floatingIp->floatingIpAddress); - $this->assertEquals('4969c491a3c74ee4af974e6d800c62de', - $this->floatingIp->tenantId); + $this->assertEquals( + '376da547-b977-4cfe-9cba-275c80debf57', + $this->floatingIp->floatingNetworkId + ); + $this->assertEquals( + 'd23abc8d-2991-4a55-ba98-2aaea84cc72f', + $this->floatingIp->routerId + ); + $this->assertEquals( + '10.0.0.3', + $this->floatingIp->fixedIpAddress + ); + $this->assertEquals( + '172.24.4.228', + $this->floatingIp->floatingIpAddress + ); + $this->assertEquals( + '4969c491a3c74ee4af974e6d800c62de', + $this->floatingIp->tenantId + ); $this->assertEquals('ACTIVE', $this->floatingIp->status); - $this->assertEquals('ce705c24-c1ef-408a-bda3-7bbd946164ab', - $this->floatingIp->portId); - $this->assertEquals('2f245a7b-796b-4f26-9cf9-9e82d248fda7', - $this->floatingIp->id); + $this->assertEquals( + 'ce705c24-c1ef-408a-bda3-7bbd946164ab', + $this->floatingIp->portId + ); + $this->assertEquals( + '2f245a7b-796b-4f26-9cf9-9e82d248fda7', + $this->floatingIp->id + ); } } From f837c8e1ce882b8666be735a4987fbda90450945 Mon Sep 17 00:00:00 2001 From: mrwogu Date: Sun, 28 Jan 2018 08:50:41 +0100 Subject: [PATCH 11/16] Fixed: Count returns 1 on StdClass object --- src/Common/JsonSchema/JsonPatch.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Common/JsonSchema/JsonPatch.php b/src/Common/JsonSchema/JsonPatch.php index eb6c6e0a..ca69f792 100644 --- a/src/Common/JsonSchema/JsonPatch.php +++ b/src/Common/JsonSchema/JsonPatch.php @@ -78,7 +78,8 @@ protected function handleObject(\stdClass $srcStruct, \stdClass $desStruct, stri protected function shouldPartiallyReplace(\stdClass $o1, \stdClass $o2): bool { - return count(array_diff_key((array) $o1, (array) $o2)) < count($o1); + // NOTE: count(stdClass) always returns 1 + return count(array_diff_key((array) $o1, (array) $o2)) < 1; } protected function arrayDiff(array $a1, array $a2): array From 5e03d16b8a701e7d43b45d1301dbc1591d1bbb9d Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Sat, 3 Feb 2018 20:08:19 +0800 Subject: [PATCH 12/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 930630f7..a528b81a 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Due to new [object typehint](https://wiki.php.net/rfc/object-typehint) since PHP ## Getting help -- Meet us on Slack: https://phpopencloud.slack.com ([Get your invitation](https://slackpass.io/phpopencloud)) +- Meet us on Slack: https://phpopencloud.slack.com ([Get your invitation](https://launchpass.com/phpopencloud)) - Report and issue: https://github.com/php-opencloud/openstack/issues ## Requirements From 78441f11bc6ae9bf2095a8387db73ba508cca8a1 Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Mon, 5 Feb 2018 11:28:02 +0800 Subject: [PATCH 13/16] Added php_cs config --- .php_cs.dist | 19 +++++++++++++++++++ .travis.yml | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .php_cs.dist diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 00000000..7ae8c400 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,19 @@ +setRules( + [ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'protected_to_private' => false + ] + ) + ->setUsingCache(false) + ->setRiskyAllowed(true) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__.'/src') + ->append([__FILE__]) + ); diff --git a/.travis.yml b/.travis.yml index de1ef134..b657775a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: before_script: - composer install --prefer-source - vendor/bin/parallel-lint --exclude vendor . - - vendor/bin/php-cs-fixer fix --dry-run --diff --rules=@PSR2 . + - vendor/bin/php-cs-fixer fix --dry-run --diff . - phpenv config-add ./xdebug.ini after_script: From a29d6341aa26d5a79aa324987d0e9d65469befc4 Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Mon, 5 Feb 2018 11:28:36 +0800 Subject: [PATCH 14/16] Updated BC breaks notice and version guidance --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a528b81a..e0460b57 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,22 @@ OpenStack services, and versions of services, are supported. * [Official documentation](http://docs.os.php-opencloud.com/) * [Reference documentation](http://refdocs.os.php-opencloud.com) -* [Developer support](https://developer.rackspace.com/) -* [Mailing list](https://groups.google.com/forum/#!forum/php-opencloud) * [Contributing guide](/CONTRIBUTING.md) * [Code of Conduct](/CODE_OF_CONDUCT.md) ## Backward incompatibility -Due to new [object typehint](https://wiki.php.net/rfc/object-typehint) since PHP 7.2, class `OpenStack\ObjectStore\v1\Models\Object` had to be renamed to `OpenStack\ObjectStore\v1\Models\StorageObject` +Due to new [object typehint](https://wiki.php.net/rfc/object-typehint) since PHP 7.2, `Object` is a reserved keyword +thus class `OpenStack\ObjectStore\v1\Models\Object` had to be renamed to +`OpenStack\ObjectStore\v1\Models\StorageObject`. See [#184](https://github.com/php-opencloud/openstack/pull/184) for +details. + +### Version Guidance + +| Version | Status | PHP Version | Life span | +| --------- | --------------------------- | ------------- | ----------------------- | +| `^2.0` | Maintained (Bug fixes only) | `^=7.0,<7.2` | March 2016 - March 2018 | +| `^3.0` | Latest | `^7.0` | March 2018 - March 2020 | ## Getting help From b6ed2cdaee0dbc06a4583ea5471e67ddc2786546 Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Mon, 5 Feb 2018 11:37:12 +0800 Subject: [PATCH 15/16] Added strict mode, increase assertion count instead of assert true --- phpunit.xml.dist | 2 +- tests/unit/Common/Api/OperatorTraitTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cf698d5b..2493eb9e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ - + diff --git a/tests/unit/Common/Api/OperatorTraitTest.php b/tests/unit/Common/Api/OperatorTraitTest.php index 7c913123..813eddcd 100644 --- a/tests/unit/Common/Api/OperatorTraitTest.php +++ b/tests/unit/Common/Api/OperatorTraitTest.php @@ -28,7 +28,7 @@ public function setUp() $this->def = [ 'method' => 'GET', - 'path' => 'test', + 'path' => 'test', 'params' => [], ]; @@ -49,7 +49,7 @@ public function test_it_sends_a_request_when_operations_are_executed() $this->operator->execute($this->def, []); - self::assertTrue(true); + $this->addToAssertionCount(1); } public function test_it_sends_a_request_when_async_operations_are_executed() @@ -58,7 +58,7 @@ public function test_it_sends_a_request_when_async_operations_are_executed() $this->operator->executeAsync($this->def, []); - self::assertTrue(true); + $this->addToAssertionCount(1); } public function test_it_wraps_sequential_ops_in_promise_when_async_is_appended_to_method_name() From 756a8f8d838cdfbac229f50d7902faab864f72fd Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Mon, 5 Feb 2018 11:40:24 +0800 Subject: [PATCH 16/16] Updated php-cs-fixer --- .php_cs.dist | 2 +- .travis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 7ae8c400..fa934870 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -15,5 +15,5 @@ return PhpCsFixer\Config::create() ->setFinder( PhpCsFixer\Finder::create() ->in(__DIR__.'/src') - ->append([__FILE__]) + ->append([__FILE__, __DIR__.'/samples']) ); diff --git a/.travis.yml b/.travis.yml index b657775a..b95c4d7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: before_script: - composer install --prefer-source - vendor/bin/parallel-lint --exclude vendor . - - vendor/bin/php-cs-fixer fix --dry-run --diff . + - vendor/bin/php-cs-fixer fix --dry-run --diff - phpenv config-add ./xdebug.ini after_script: