diff --git a/CHANGELOG.md b/CHANGELOG.md index eb9321d..0efa5d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +# 5.0.0 + +## BC Breaks + +Use PSR-7, PSR-17 and PSR-18 instead of HttpPlug. + +- Change the type of the first parameter of `Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder::setHttpClient` from `Http\Client\HttpClient` to `Psr\Http\Client\ClientInterface` +- Change the type of the first parameter of `Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder::setRequestFactory` from `Http\Message\RequestFactory` to `Psr\Http\Message\RequestFactoryInterface` +- Change the type of the first parameter of `Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder::setStreamFactory` from `Http\Message\StreamFactory` to `Psr\Http\Message\StreamFactoryInterface` + +Factory implementations are necessary as dependency. +For example, with Guzzle: + +```bash +$ php composer.phar require akeneo/api-php-client-ee php-http/guzzle6-adapter:^2.0 http-interop/http-factory-guzzle:^1.0 +``` + # 4.0.0 (2019-02-08) ## Improvements diff --git a/composer.json b/composer.json index 9c720a2..d487672 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,7 @@ "phpspec/phpspec": "^5.0", "symfony/yaml": "^4.2", "donatj/mock-webserver": "^2.0", + "http-interop/http-factory-guzzle": "^1.0", "php-http/guzzle6-adapter": "^2.0" }, "config": { diff --git a/docker-compose.yml.dist b/docker-compose.yml.dist index 6b1bb78..397bf0c 100644 --- a/docker-compose.yml.dist +++ b/docker-compose.yml.dist @@ -8,7 +8,6 @@ services: PHP_IDE_CONFIG: 'serverName=akeneo-client' PHP_XDEBUG_ENABLED: 0 PHP_XDEBUG_IDE_KEY: XDEBUG_IDE_KEY - PHP_XDEBUG_REMOTE_HOST: xxx.xxx.xxx.xxx XDEBUG_CONFIG: 'remote_host=xxx.xxx.xxx.xxx' user: docker volumes: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a240bcc..b941627 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,7 +7,7 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" - processIsolation="true" + processIsolation="false" stopOnFailure="false" syntaxCheck="false"> diff --git a/src/AkeneoPimEnterpriseClientBuilder.php b/src/AkeneoPimEnterpriseClientBuilder.php index b920b7a..ea26879 100644 --- a/src/AkeneoPimEnterpriseClientBuilder.php +++ b/src/AkeneoPimEnterpriseClientBuilder.php @@ -42,12 +42,13 @@ use Akeneo\PimEnterprise\ApiClient\Api\ReferenceEntityAttributeOptionApi; use Akeneo\PimEnterprise\ApiClient\Api\ReferenceEntityMediaFileApi; use Akeneo\PimEnterprise\ApiClient\Api\ReferenceEntityRecordApi; -use Http\Client\HttpClient as Client; -use Http\Discovery\HttpClientDiscovery; -use Http\Discovery\MessageFactoryDiscovery; -use Http\Discovery\StreamFactoryDiscovery; +use Http\Discovery\Psr17FactoryDiscovery; +use Http\Discovery\Psr18ClientDiscovery; use Http\Message\RequestFactory; use Http\Message\StreamFactory; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; /** * Builder of the class AkeneoPimEnterpriseClient. @@ -62,7 +63,7 @@ class AkeneoPimEnterpriseClientBuilder /** @var string */ protected $baseUri; - /** @var Client */ + /** @var ClientInterface */ protected $httpClient; /** @var RequestFactory */ @@ -83,13 +84,9 @@ public function __construct(string $baseUri) } /** - * Allows to directly set a client instead of using HttpClientDiscovery::find() - * - * @param Client $httpClient - * - * @return AkeneoPimClientBuilder + * Allows to directly set a client instead of using the discovery */ - public function setHttpClient(Client $httpClient): self + public function setHttpClient(ClientInterface $httpClient): self { $this->httpClient = $httpClient; @@ -97,13 +94,9 @@ public function setHttpClient(Client $httpClient): self } /** - * Allows to directly set a request factory instead of using MessageFactoryDiscovery::find() - * - * @param RequestFactory $requestFactory - * - * @return AkeneoPimClientBuilder + * Allows to directly set a request factory instead of using the discovery */ - public function setRequestFactory(RequestFactory $requestFactory): self + public function setRequestFactory(RequestFactoryInterface $requestFactory): self { $this->requestFactory = $requestFactory; @@ -111,13 +104,9 @@ public function setRequestFactory(RequestFactory $requestFactory): self } /** - * Allows to directly set a stream factory instead of using StreamFactoryDiscovery::find() - * - * @param StreamFactory $streamFactory - * - * @return AkeneoPimClientBuilder + * Allows to directly set a stream factory instead of using the discovery */ - public function setStreamFactory(StreamFactory $streamFactory): self + public function setStreamFactory(StreamFactoryInterface $streamFactory): self { $this->streamFactory = $streamFactory; @@ -224,7 +213,7 @@ protected function setUp(Authentication $authentication): array { $uriGenerator = new UriGenerator($this->baseUri); - $httpClient = new HttpClient($this->getHttpClient(), $this->getRequestFactory()); + $httpClient = new HttpClient($this->getHttpClient(), $this->getRequestFactory(), $this->getStreamFactory()); $authenticationApi = new AuthenticationApi($httpClient, $uriGenerator); $authenticatedHttpClient = new AuthenticatedHttpClient($httpClient, $authenticationApi, $authentication); @@ -244,28 +233,28 @@ protected function setUp(Authentication $authentication): array return [$resourceClient, $pageFactory, $cursorFactory, $fileSystem]; } - private function getHttpClient(): Client + private function getHttpClient(): ClientInterface { if (null === $this->httpClient) { - $this->httpClient = HttpClientDiscovery::find(); + $this->httpClient = Psr18ClientDiscovery::find(); } return $this->httpClient; } - private function getRequestFactory(): RequestFactory + private function getRequestFactory(): RequestFactoryInterface { if (null === $this->requestFactory) { - $this->requestFactory = MessageFactoryDiscovery::find(); + $this->requestFactory = Psr17FactoryDiscovery::findRequestFactory(); } return $this->requestFactory; } - private function getStreamFactory(): StreamFactory + private function getStreamFactory(): StreamFactoryInterface { if (null === $this->streamFactory) { - $this->streamFactory = StreamFactoryDiscovery::find(); + $this->streamFactory = Psr17FactoryDiscovery::findStreamFactory(); } return $this->streamFactory; diff --git a/tests/Api/AssetReferenceFile/UploadAssetReferenceFileIntegration.php b/tests/Api/AssetReferenceFile/UploadAssetReferenceFileIntegration.php index 7bd1f66..cc4bd36 100644 --- a/tests/Api/AssetReferenceFile/UploadAssetReferenceFileIntegration.php +++ b/tests/Api/AssetReferenceFile/UploadAssetReferenceFileIntegration.php @@ -104,7 +104,7 @@ public function test_upload_from_resource_file() */ public function test_upload_for_an_unknown_asset() { - $filePath = realpath(__DIR__ . '/../../../fixtures/ziggy.png'); + $filePath = realpath(__DIR__ . '/../../fixtures/ziggy.png'); $this->server->setResponseOfPath( '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'unknown_asset', 'en_US'), @@ -123,7 +123,7 @@ public function test_upload_for_an_unknown_asset() */ public function test_upload_a_file_that_cannot_be_transformed_for_the_variations() { - $filePath = realpath(__DIR__ . '/../../../fixtures/unicorn.png'); + $filePath = realpath(__DIR__ . '/../../fixtures/unicorn.png'); $this->server->setResponseOfPath( '/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'unicorn', AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE), diff --git a/tests/Api/AssetVariationFile/UploadAssetVariationFileApiIntegration.php b/tests/Api/AssetVariationFile/UploadAssetVariationFileApiIntegration.php index 21c1efe..172db1c 100644 --- a/tests/Api/AssetVariationFile/UploadAssetVariationFileApiIntegration.php +++ b/tests/Api/AssetVariationFile/UploadAssetVariationFileApiIntegration.php @@ -105,7 +105,7 @@ public function test_upload_from_resource_file() */ public function test_upload_for_an_unknown_asset() { - $filePath = realpath(__DIR__ . '/../../../fixtures/ziggy.png'); + $filePath = realpath(__DIR__ . '/../../fixtures/ziggy.png'); $this->server->setResponseOfPath( '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'unknown_asset', 'ecommerce', 'en_US'), @@ -124,7 +124,7 @@ public function test_upload_for_an_unknown_asset() */ public function test_upload_for_an_asset_that_should_be_localizable() { - $filePath = realpath(__DIR__ . '/../../../fixtures/unicorn.png'); + $filePath = realpath(__DIR__ . '/../../fixtures/unicorn.png'); $this->server->setResponseOfPath( '/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'unicorn', 'ecommerce', AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE),