From 9c58be0754a2522b3ba897299aea05fabb76ce28 Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Wed, 14 Mar 2018 00:26:50 +0800 Subject: [PATCH 1/3] Bumped dependencies to remove guzzle/guzzle --- README.md | 31 +++++++++++++++++-------------- composer.json | 8 ++++---- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index dd550a78..cd22c91f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PHP OpenStack SDK [![Build Status](https://travis-ci.org/php-opencloud/openstack.svg?branch=master)](https://travis-ci.org/php-opencloud/openstack) -[![Code Coverage](https://scrutinizer-ci.com/g/php-opencloud/openstack/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/php-opencloud/openstack/?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/php-opencloud/openstack/badge.svg?branch=master)](https://coveralls.io/github/php-opencloud/openstack?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/php-opencloud/openstack/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/php-opencloud/openstack/?branch=master) `php-opencloud/openstack` is an SDK which allows PHP developers to easily connect to OpenStack APIs in a simple and @@ -15,28 +15,31 @@ OpenStack services, and versions of services, are supported. * [Contributing guide](/CONTRIBUTING.md) * [Code of Conduct](/CODE_OF_CONDUCT.md) -## Backward incompatibility +## Getting help + +- Meet us on Slack: https://phpopencloud.slack.com ([Get your invitation](https://launchpass.com/phpopencloud)) +- Report an issue: https://github.com/php-opencloud/openstack/issues -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 Guidance -| Version | Status | PHP Version | Life span | +| Version | Status | PHP Version | End of life | | --------- | --------------------------- | ------------- | ----------------------- | -| `^2.0` | Maintained (Bug fixes only) | `>=7.0,<7.2` | March 2016 - March 2018 | -| `^3.0` | Latest | `>=7.0` | March 2018 - March 2020 | +| `^3.0` | Latest | `>=7.0` | March 2020 | +| `^2.0` | Maintained (Bug fixes only) | `>=7.0,<7.2` | March 2018 | -## Getting help - -- 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 +## Upgrade from 2.x to 3.x + +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`. + +This change was introduced in [#184](https://github.com/php-opencloud/openstack/pull/184). ## Requirements * PHP 7.0 +* `ext-curl` ## How to install diff --git a/composer.json b/composer.json index 3becf3ed..644bbefa 100644 --- a/composer.json +++ b/composer.json @@ -44,11 +44,11 @@ "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", - "jakub-onderka/php-parallel-lint": "0.*", + "psr/log": "^1.0", + "satooshi/php-coveralls": "^2.0", + "jakub-onderka/php-parallel-lint": "^1.0", "friendsofphp/php-cs-fixer": "^2.9" } } From 453eb5ec02c9ed640066916e2338c97a452eb68b Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Wed, 14 Mar 2018 00:29:52 +0800 Subject: [PATCH 2/3] Enabel coverall --- .travis.yml | 3 +++ phpunit.xml.dist | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3d58c73c..a020a10d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,9 @@ before_script: after_script: - php vendor/bin/coveralls -v +after_success: + - travis_retry php vendor/bin/php-coveralls -v + notifications: email: - jamie.hannaford@rackspace.com diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cf698d5b..ff7dd902 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,8 @@ - - + + + + tests/unit @@ -18,4 +20,4 @@ - \ No newline at end of file + From 9ba6503b06fcdeab167dc9e6d08553554d158071 Mon Sep 17 00:00:00 2001 From: Ha Phan Date: Wed, 14 Mar 2018 09:53:40 +0800 Subject: [PATCH 3/3] Updated tests compatibility with phpunit 6 --- tests/integration/Compute/v2/CoreTest.php | 3 +- tests/integration/TestCase.php | 2 +- tests/unit/Common/Api/OperationTest.php | 2 +- tests/unit/Common/Api/OperatorTraitTest.php | 6 +++ tests/unit/Common/Api/ParameterTest.php | 2 +- tests/unit/Common/Error/BuilderTest.php | 4 +- tests/unit/Common/JsonPathTest.php | 2 +- .../Common/Transport/JsonSerializerTest.php | 2 +- .../Layer3/Models/FloatingIpTest.php | 42 ++++++++++++------- tests/unit/TestCase.php | 2 +- 10 files changed, 44 insertions(+), 23 deletions(-) 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]) ); } 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/OperatorTraitTest.php b/tests/unit/Common/Api/OperatorTraitTest.php index c0589141..813eddcd 100644 --- a/tests/unit/Common/Api/OperatorTraitTest.php +++ b/tests/unit/Common/Api/OperatorTraitTest.php @@ -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, []); + + $this->addToAssertionCount(1); } 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, []); + + $this->addToAssertionCount(1); } 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/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..f5710a1b 100644 --- a/tests/unit/Common/Error/BuilderTest.php +++ b/tests/unit/Common/Error/BuilderTest.php @@ -13,12 +13,12 @@ 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; - public function __construct() + public function setUp() { $this->client = $this->prophesize(ClientInterface::class); $this->builder = new Builder($this->client->reveal()); 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/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 + ); } } 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;