From 4331aa125745d2a900c090aea991c425316c7016 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 20 Oct 2020 13:36:23 +0200 Subject: [PATCH 01/93] Adds PSR-17 and PSR-18 support. Removes built-in proxy support. --- CHANGELOG.md | 6 + README.md | 116 +++++++++++------- composer.json | 5 +- src/Feature/Sms/SmsHttpFeature.php | 10 +- .../Client/GuzzleClientFactory.php | 46 ------- .../Decorator/AcceptJsonHeaderDecorator.php} | 4 +- .../AuthorizationHeaderDecorator.php} | 4 +- .../Decorator/BaseUriDecorator.php} | 4 +- .../CorrelationIdHeaderDecorator.php} | 4 +- .../HttpClientUserAgentHeaderDecorator.php} | 8 +- .../Decorator/LoggerDecorator.php} | 4 +- .../HttpClient/HttpClientFactory.php | 43 +++++++ .../GuzzleRequestAssembler.php | 25 ---- .../RequestAssembler/RequestAssembler.php | 41 +++++++ .../RequestExecutor/LegacyRequestExecutor.php | 15 ++- .../RequestExecutorFactory.php | 42 ++++--- .../RequestExecutor/RestRequestExecutor.php | 15 ++- src/Service/HttpDefaultFeatures.php | 22 ++-- src/Service/SmsapiComHttpService.php | 6 +- src/Service/SmsapiPlHttpService.php | 10 +- src/SmsapiClient.php | 2 - src/SmsapiHttpClient.php | 33 +++-- tests/Fixture/GuzzleClientFactoryMother.php | 15 --- tests/Fixture/HttpClientFactoryMother.php | 15 +++ .../HttpClient}/Exception/ClientException.php | 2 +- .../Exception/NetworkException.php | 2 +- .../Exception/RequestException.php | 2 +- .../Helper/HttpClient/HttpClient.php | 21 +--- tests/Helper/HttpClient/HttpClientMock.php | 51 ++++++++ tests/Helper/HttpClient/RequestFactory.php | 17 +++ tests/Helper/HttpClient/StreamFactory.php | 27 ++++ tests/SmsapiClientIntegrationTestCase.php | 5 +- tests/SmsapiClientUnitTestCase.php | 58 ++++----- .../GuzzleClientFactoryTest.php | 24 ---- .../RequestExecutorFactoryTest.php | 38 ------ 35 files changed, 420 insertions(+), 322 deletions(-) delete mode 100644 src/Infrastructure/Client/GuzzleClientFactory.php rename src/Infrastructure/{Client/Decorator/GuzzleClientAcceptJsonHeaderDecorator.php => HttpClient/Decorator/AcceptJsonHeaderDecorator.php} (83%) rename src/Infrastructure/{Client/Decorator/GuzzleClientAuthorizationHeaderDecorator.php => HttpClient/Decorator/AuthorizationHeaderDecorator.php} (85%) rename src/Infrastructure/{Client/Decorator/GuzzleClientBaseUriDecorator.php => HttpClient/Decorator/BaseUriDecorator.php} (89%) rename src/Infrastructure/{Client/Decorator/GuzzleClientCorrelationIdHeaderDecorator.php => HttpClient/Decorator/CorrelationIdHeaderDecorator.php} (85%) rename src/Infrastructure/{Client/Decorator/GuzzleClientUserAgentHeaderDecorator.php => HttpClient/Decorator/HttpClientUserAgentHeaderDecorator.php} (75%) rename src/Infrastructure/{Client/Decorator/GuzzleClientLoggerDecorator.php => HttpClient/Decorator/LoggerDecorator.php} (87%) create mode 100644 src/Infrastructure/HttpClient/HttpClientFactory.php delete mode 100644 src/Infrastructure/RequestAssembler/GuzzleRequestAssembler.php create mode 100644 src/Infrastructure/RequestAssembler/RequestAssembler.php delete mode 100644 tests/Fixture/GuzzleClientFactoryMother.php create mode 100644 tests/Fixture/HttpClientFactoryMother.php rename {src/Infrastructure/Client => tests/Helper/HttpClient}/Exception/ClientException.php (90%) rename {src/Infrastructure/Client => tests/Helper/HttpClient}/Exception/NetworkException.php (75%) rename {src/Infrastructure/Client => tests/Helper/HttpClient}/Exception/RequestException.php (75%) rename src/Infrastructure/Client/GuzzleClient.php => tests/Helper/HttpClient/HttpClient.php (66%) create mode 100644 tests/Helper/HttpClient/HttpClientMock.php create mode 100644 tests/Helper/HttpClient/RequestFactory.php create mode 100644 tests/Helper/HttpClient/StreamFactory.php delete mode 100644 tests/Unit/Infrastructure/RequestExecutor/GuzzleClientFactoryTest.php delete mode 100644 tests/Unit/Infrastructure/RequestExecutor/RequestExecutorFactoryTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index e49a5ac..2c4e473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- PSR-18 support +- PSR-17 support + ### Changed - utf-8 as default encoding - `CreateContactBag::withPhone` marked as deprecated ### Removed +- built-in proxy support - use own implementation +- concrete HTTP client dependency (Guzzle 6) - `SendSmsBag::setIdx` - `DeleteSmsBag` - `FindSendernamesBag` diff --git a/README.md b/README.md index 3eaa60c..e94b4ff 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ Execute: `composer require smsapi/php-client` Depending on which of SMSAPI service your account is, you should pick it calling one of a method from examples below: +### PSR-17 and PSR-18 + +Starting form version 3, SMSAPI PHP Client supports PSR-17 and PSR-18 compliant HTTP clients. +That way this library is independent of client of your choice. +You have to provide your own HTTP client, request factory and stream factory to use our library. +All following examples consider you have HTTP client, request factory and stream factory well-defined in `bootstrap.php` file. + ### How to use *SMSAPI.COM* client? ```php @@ -30,13 +37,23 @@ Depending on which of SMSAPI service your account is, you should pick it calling declare(strict_types=1); +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; +use Smsapi\Client\SmsapiHttpClient; + require_once 'vendor/autoload.php'; -use Smsapi\Client\SmsapiHttpClient; +/** + * @var ClientInterface $httpClient + * @var RequestFactoryInterface $requestFactory + * @var StreamFactoryInterface $streamFactory + */ +require_once 'bootstrap.php'; $apiToken = '0000000000000000000000000000000000000000'; -$service = (new SmsapiHttpClient()) +$client = (new SmsapiHttpClient($httpClient, $requestFactory, $streamFactory)) ->smsapiComService($apiToken); ``` @@ -47,17 +64,25 @@ $service = (new SmsapiHttpClient()) declare(strict_types=1); +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; +use Smsapi\Client\SmsapiHttpClient; + require_once 'vendor/autoload.php'; -use Smsapi\Client\SmsapiHttpClient; +/** + * @var ClientInterface $httpClient + * @var RequestFactoryInterface $requestFactory + * @var StreamFactoryInterface $streamFactory + */ +require_once 'bootstrap.php'; $apiToken = '0000000000000000000000000000000000000000'; -$service = (new SmsapiHttpClient()) +$client = (new SmsapiHttpClient($httpClient, $requestFactory, $streamFactory)) ->smsapiPlService($apiToken); -``` - -All following examples consider you have a account on SMSAPI.COM. +``` ## How to use a custom URI? @@ -66,19 +91,31 @@ All following examples consider you have a account on SMSAPI.COM. declare(strict_types=1); +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; +use Smsapi\Client\SmsapiHttpClient; + require_once 'vendor/autoload.php'; -use Smsapi\Client\SmsapiHttpClient; +/** + * @var ClientInterface $httpClient + * @var RequestFactoryInterface $requestFactory + * @var StreamFactoryInterface $streamFactory + */ +require_once 'bootstrap.php'; $apiToken = '0000000000000000000000000000000000000000'; $uri = 'http://example.com'; -$service = (new SmsapiHttpClient()) +$client = (new SmsapiHttpClient($httpClient, $requestFactory, $streamFactory)) ->smsapiComServiceWithUri($apiToken, $uri); ``` ## How to use service business features? +All following examples consider you have an account on SMSAPI.COM and client has been setup in `client.php` file. + ### How to use ping feature? ```php @@ -86,15 +123,12 @@ $service = (new SmsapiHttpClient()) declare(strict_types=1); -require_once 'vendor/autoload.php'; - -use Smsapi\Client\SmsapiHttpClient; +use Smsapi\Client\Service\SmsapiComService; -$apiToken = '0000000000000000000000000000000000000000'; +/** @var SmsapiComService $client */ +require_once 'client.php'; -$service = (new SmsapiHttpClient()) - ->smsapiComService($apiToken); -$result = $service->pingFeature() +$result = $client->pingFeature() ->ping(); if ($result->smsapi) { @@ -111,18 +145,15 @@ if ($result->smsapi) { declare(strict_types=1); -require_once 'vendor/autoload.php'; - -use Smsapi\Client\SmsapiHttpClient; +use Smsapi\Client\Service\SmsapiComService; use Smsapi\Client\Feature\Sms\Bag\SendSmsBag; -$apiToken = '0000000000000000000000000000000000000000'; +/** @var SmsapiComService $client */ +require_once 'client.php'; $sms = SendSmsBag::withMessage('someone phone number', 'some message'); -$service = (new SmsapiHttpClient()) - ->smsapiComService($apiToken); -$service->smsFeature() +$client->smsFeature() ->sendSms($sms); ``` @@ -133,19 +164,16 @@ $service->smsFeature() declare(strict_types=1); -require_once 'vendor/autoload.php'; - -use Smsapi\Client\SmsapiHttpClient; +use Smsapi\Client\Service\SmsapiComService; use Smsapi\Client\Feature\Sms\Bag\SendSmsBag; -$apiToken = '0000000000000000000000000000000000000000'; +/** @var SmsapiComService $client */ +require_once 'client.php'; $sms = SendSmsBag::withMessage('someone phone number', 'some message'); $sms->from = 'Test'; -$service = (new SmsapiHttpClient()) - ->smsapiComService($apiToken); -$service->smsFeature() +$client->smsFeature() ->sendSms($sms); ``` @@ -177,19 +205,7 @@ $sms->encoding = 'utf-8'; ### How to use proxy server? -```php -setProxy($proxyUrl); -``` +To use proxy server you have to define it with your HTTP client. ### How to log requests and responses? @@ -200,12 +216,21 @@ Set logger to `SmsapiHttpClient` instance. declare(strict_types=1); +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; use Psr\Log\LoggerInterface; use Psr\Log\LoggerTrait; +use Smsapi\Client\SmsapiHttpClient; require_once 'vendor/autoload.php'; -use Smsapi\Client\SmsapiHttpClient; +/** + * @var ClientInterface $httpClient + * @var RequestFactoryInterface $requestFactory + * @var StreamFactoryInterface $streamFactory + */ +require_once 'bootstrap.php'; $logger = new class() implements LoggerInterface { @@ -217,7 +242,8 @@ $logger = new class() implements LoggerInterface } }; -(new SmsapiHttpClient())->setLogger($logger); +(new SmsapiHttpClient($httpClient, $requestFactory, $streamFactory)) + ->setLogger($logger); ``` ## Test package diff --git a/composer.json b/composer.json index c63aa0a..a3a2e7a 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "psr/log": "^1", "psr/http-message": "^1", "psr/http-client": "^1", - "guzzlehttp/guzzle": "^6" + "psr/http-factory": "^1" }, "require-dev": { "phpunit/phpunit": "^6", @@ -31,6 +31,7 @@ "phing/phing": "^2.5", "doctrine/instantiator": "1.0.5", "phpdocumentor/reflection-docblock": "^4.3", - "phpdocumentor/type-resolver": "^0.5" + "phpdocumentor/type-resolver": "^0.5", + "guzzlehttp/guzzle": "^6" } } diff --git a/src/Feature/Sms/SmsHttpFeature.php b/src/Feature/Sms/SmsHttpFeature.php index 5eafd75..185e53f 100644 --- a/src/Feature/Sms/SmsHttpFeature.php +++ b/src/Feature/Sms/SmsHttpFeature.php @@ -3,6 +3,7 @@ namespace Smsapi\Client\Feature\Sms; +use Psr\Http\Client\ClientInterface; use Smsapi\Client\Feature\Data\DataFactoryProvider; use Smsapi\Client\Feature\Sms\Bag\DeleteScheduledSmssBag; use Smsapi\Client\Feature\Sms\Bag\ScheduleSmsBag; @@ -25,13 +26,16 @@ */ class SmsHttpFeature implements SmsFeature { + private $externalHttpClient; private $requestExecutorFactory; private $dataFactoryProvider; public function __construct( + ClientInterface $externalHttpClient, RequestExecutorFactory $requestExecutorFactory, DataFactoryProvider $dataFactoryProvider ) { + $this->externalHttpClient = $externalHttpClient; $this->requestExecutorFactory = $requestExecutorFactory; $this->dataFactoryProvider = $dataFactoryProvider; } @@ -39,7 +43,7 @@ public function __construct( public function sendernameFeature(): SendernamesFeature { return new SendernamesHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), + $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider->provideSendernameFactory() ); } @@ -216,6 +220,8 @@ public function deleteScheduledSms(DeleteScheduledSmssBag $deleteScheduledSmsBag */ private function makeRequest($data): stdClass { - return $this->requestExecutorFactory->createLegacyRequestExecutor()->request('sms.do', (array)$data); + return $this->requestExecutorFactory + ->createLegacyRequestExecutor($this->externalHttpClient) + ->request('sms.do', (array)$data); } } diff --git a/src/Infrastructure/Client/GuzzleClientFactory.php b/src/Infrastructure/Client/GuzzleClientFactory.php deleted file mode 100644 index e9980a5..0000000 --- a/src/Infrastructure/Client/GuzzleClientFactory.php +++ /dev/null @@ -1,46 +0,0 @@ -logger = new NullLogger(); - $this->apiToken = $apiToken; - $this->uri = $uri; - $this->proxy = $proxy; - } - - public function createClient(): ClientInterface - { - $client = new GuzzleClient($this->proxy); - $client = new GuzzleClientLoggerDecorator($client, $this->logger); - $client = new GuzzleClientBaseUriDecorator($client, $this->uri); - $client = new GuzzleClientAuthorizationHeaderDecorator($client, $this->apiToken); - $client = new GuzzleClientUserAgentHeaderDecorator($client); - $client = new GuzzleClientCorrelationIdHeaderDecorator($client); - - return $client; - } -} diff --git a/src/Infrastructure/Client/Decorator/GuzzleClientAcceptJsonHeaderDecorator.php b/src/Infrastructure/HttpClient/Decorator/AcceptJsonHeaderDecorator.php similarity index 83% rename from src/Infrastructure/Client/Decorator/GuzzleClientAcceptJsonHeaderDecorator.php rename to src/Infrastructure/HttpClient/Decorator/AcceptJsonHeaderDecorator.php index b0d1582..5997a90 100644 --- a/src/Infrastructure/Client/Decorator/GuzzleClientAcceptJsonHeaderDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/AcceptJsonHeaderDecorator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Infrastructure\Client\Decorator; +namespace Smsapi\Client\Infrastructure\HttpClient\Decorator; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; @@ -11,7 +11,7 @@ /** * @internal */ -class GuzzleClientAcceptJsonHeaderDecorator implements ClientInterface +class AcceptJsonHeaderDecorator implements ClientInterface { private $client; diff --git a/src/Infrastructure/Client/Decorator/GuzzleClientAuthorizationHeaderDecorator.php b/src/Infrastructure/HttpClient/Decorator/AuthorizationHeaderDecorator.php similarity index 85% rename from src/Infrastructure/Client/Decorator/GuzzleClientAuthorizationHeaderDecorator.php rename to src/Infrastructure/HttpClient/Decorator/AuthorizationHeaderDecorator.php index 116385e..78a353e 100644 --- a/src/Infrastructure/Client/Decorator/GuzzleClientAuthorizationHeaderDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/AuthorizationHeaderDecorator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Infrastructure\Client\Decorator; +namespace Smsapi\Client\Infrastructure\HttpClient\Decorator; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; @@ -11,7 +11,7 @@ /** * @internal */ -class GuzzleClientAuthorizationHeaderDecorator implements ClientInterface +class AuthorizationHeaderDecorator implements ClientInterface { private $client; private $apiToken; diff --git a/src/Infrastructure/Client/Decorator/GuzzleClientBaseUriDecorator.php b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php similarity index 89% rename from src/Infrastructure/Client/Decorator/GuzzleClientBaseUriDecorator.php rename to src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php index decf602..8ae2d3c 100644 --- a/src/Infrastructure/Client/Decorator/GuzzleClientBaseUriDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Infrastructure\Client\Decorator; +namespace Smsapi\Client\Infrastructure\HttpClient\Decorator; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; @@ -11,7 +11,7 @@ /** * @internal */ -class GuzzleClientBaseUriDecorator implements ClientInterface +class BaseUriDecorator implements ClientInterface { private $client; private $baseUri; diff --git a/src/Infrastructure/Client/Decorator/GuzzleClientCorrelationIdHeaderDecorator.php b/src/Infrastructure/HttpClient/Decorator/CorrelationIdHeaderDecorator.php similarity index 85% rename from src/Infrastructure/Client/Decorator/GuzzleClientCorrelationIdHeaderDecorator.php rename to src/Infrastructure/HttpClient/Decorator/CorrelationIdHeaderDecorator.php index 86ac269..f54a2e4 100644 --- a/src/Infrastructure/Client/Decorator/GuzzleClientCorrelationIdHeaderDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/CorrelationIdHeaderDecorator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Infrastructure\Client\Decorator; +namespace Smsapi\Client\Infrastructure\HttpClient\Decorator; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; @@ -11,7 +11,7 @@ /** * @internal */ -class GuzzleClientCorrelationIdHeaderDecorator implements ClientInterface +class CorrelationIdHeaderDecorator implements ClientInterface { private $client; diff --git a/src/Infrastructure/Client/Decorator/GuzzleClientUserAgentHeaderDecorator.php b/src/Infrastructure/HttpClient/Decorator/HttpClientUserAgentHeaderDecorator.php similarity index 75% rename from src/Infrastructure/Client/Decorator/GuzzleClientUserAgentHeaderDecorator.php rename to src/Infrastructure/HttpClient/Decorator/HttpClientUserAgentHeaderDecorator.php index b4610cd..6b86a4c 100644 --- a/src/Infrastructure/Client/Decorator/GuzzleClientUserAgentHeaderDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/HttpClientUserAgentHeaderDecorator.php @@ -2,9 +2,8 @@ declare(strict_types=1); -namespace Smsapi\Client\Infrastructure\Client\Decorator; +namespace Smsapi\Client\Infrastructure\HttpClient\Decorator; -use GuzzleHttp\ClientInterface as GuzzleClientInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -13,7 +12,7 @@ /** * @internal */ -class GuzzleClientUserAgentHeaderDecorator implements ClientInterface +class HttpClientUserAgentHeaderDecorator implements ClientInterface { private $client; @@ -37,9 +36,8 @@ private function addUserAgentHeader(RequestInterface $request): RequestInterface private function createUserAgent(): string { return sprintf( - 'smsapi/php-client:%s;guzzle:%s;php:%s', + 'smsapi/php-client:%s;php:%s', SmsapiClient::VERSION, - GuzzleClientInterface::VERSION, PHP_VERSION ); } diff --git a/src/Infrastructure/Client/Decorator/GuzzleClientLoggerDecorator.php b/src/Infrastructure/HttpClient/Decorator/LoggerDecorator.php similarity index 87% rename from src/Infrastructure/Client/Decorator/GuzzleClientLoggerDecorator.php rename to src/Infrastructure/HttpClient/Decorator/LoggerDecorator.php index f033c1a..926ce3f 100644 --- a/src/Infrastructure/Client/Decorator/GuzzleClientLoggerDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/LoggerDecorator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Infrastructure\Client\Decorator; +namespace Smsapi\Client\Infrastructure\HttpClient\Decorator; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; @@ -12,7 +12,7 @@ /** * @internal */ -class GuzzleClientLoggerDecorator implements ClientInterface +class LoggerDecorator implements ClientInterface { private $client; private $logger; diff --git a/src/Infrastructure/HttpClient/HttpClientFactory.php b/src/Infrastructure/HttpClient/HttpClientFactory.php new file mode 100644 index 0000000..2cbf467 --- /dev/null +++ b/src/Infrastructure/HttpClient/HttpClientFactory.php @@ -0,0 +1,43 @@ +logger = new NullLogger(); + $this->apiToken = $apiToken; + $this->uri = $uri; + } + + public function createClient(ClientInterface $externalClient): ClientInterface + { + $client = new LoggerDecorator($externalClient, $this->logger); + $client = new BaseUriDecorator($client, $this->uri); + $client = new AuthorizationHeaderDecorator($client, $this->apiToken); + $client = new HttpClientUserAgentHeaderDecorator($client); + $client = new CorrelationIdHeaderDecorator($client); + + return $client; + } +} diff --git a/src/Infrastructure/RequestAssembler/GuzzleRequestAssembler.php b/src/Infrastructure/RequestAssembler/GuzzleRequestAssembler.php deleted file mode 100644 index 4dff137..0000000 --- a/src/Infrastructure/RequestAssembler/GuzzleRequestAssembler.php +++ /dev/null @@ -1,25 +0,0 @@ -getMethod(), - $request->getUri(), - $request->getHeaders(), - $request->getBody() - ); - } -} diff --git a/src/Infrastructure/RequestAssembler/RequestAssembler.php b/src/Infrastructure/RequestAssembler/RequestAssembler.php new file mode 100644 index 0000000..1b76a01 --- /dev/null +++ b/src/Infrastructure/RequestAssembler/RequestAssembler.php @@ -0,0 +1,41 @@ +requestFactory = $requestFactory; + $this->streamFactory = $streamFactory; + } + + public function assemble(Request $requestDTO): RequestInterface + { + $request = $this->requestFactory->createRequest( + $requestDTO->getMethod(), + $requestDTO->getUri() + ); + + foreach ($requestDTO->getHeaders() as $header => $value) { + $request = $request->withHeader($header, $value); + } + + $request = $request->withBody($this->streamFactory->createStream($requestDTO->getBody())); + + return $request; + } +} diff --git a/src/Infrastructure/RequestExecutor/LegacyRequestExecutor.php b/src/Infrastructure/RequestExecutor/LegacyRequestExecutor.php index c260e47..8aaec38 100644 --- a/src/Infrastructure/RequestExecutor/LegacyRequestExecutor.php +++ b/src/Infrastructure/RequestExecutor/LegacyRequestExecutor.php @@ -5,7 +5,9 @@ namespace Smsapi\Client\Infrastructure\RequestExecutor; use Psr\Http\Client\ClientInterface; -use Smsapi\Client\Infrastructure\RequestAssembler\GuzzleRequestAssembler; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; +use Smsapi\Client\Infrastructure\RequestAssembler\RequestAssembler; use Smsapi\Client\Infrastructure\RequestMapper\LegacyRequestMapper; use Smsapi\Client\Infrastructure\ResponseMapper\LegacyResponseMapper; use stdClass; @@ -18,25 +20,28 @@ class LegacyRequestExecutor private $requestMapper; private $client; private $legacyResponseMapper; - private $requestAssembler; + private $requestFactory; + private $streamFactory; public function __construct( LegacyRequestMapper $requestMapper, ClientInterface $client, LegacyResponseMapper $legacyResponseMapper, - GuzzleRequestAssembler $requestAssembler + RequestFactoryInterface $requestFactory, + StreamFactoryInterface $streamFactory ) { $this->requestMapper = $requestMapper; $this->client = $client; $this->legacyResponseMapper = $legacyResponseMapper; - $this->requestAssembler = $requestAssembler; + $this->requestFactory = $requestFactory; + $this->streamFactory = $streamFactory; } public function request(string $path, array $builtInParameters, array $userParameters = []): stdClass { $request = $this->requestMapper->map($path, $builtInParameters, $userParameters); - $assembledRequest = $this->requestAssembler->assemble($request); + $assembledRequest = (new RequestAssembler($this->requestFactory, $this->streamFactory))->assemble($request); $response = $this->client->sendRequest($assembledRequest); diff --git a/src/Infrastructure/RequestExecutor/RequestExecutorFactory.php b/src/Infrastructure/RequestExecutor/RequestExecutorFactory.php index 19a1f3e..4be0532 100644 --- a/src/Infrastructure/RequestExecutor/RequestExecutorFactory.php +++ b/src/Infrastructure/RequestExecutor/RequestExecutorFactory.php @@ -5,10 +5,11 @@ namespace Smsapi\Client\Infrastructure\RequestExecutor; use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\NullLogger; -use Smsapi\Client\Infrastructure\Client\GuzzleClientFactory; -use Smsapi\Client\Infrastructure\RequestAssembler\GuzzleRequestAssembler; +use Smsapi\Client\Infrastructure\HttpClient\HttpClientFactory; use Smsapi\Client\Infrastructure\RequestMapper\Query\Formatter\ComplexParametersQueryFormatter; use Smsapi\Client\Infrastructure\ResponseMapper\LegacyResponseMapper; use Smsapi\Client\Infrastructure\RequestMapper\RestRequestMapper; @@ -25,19 +26,24 @@ class RequestExecutorFactory private $queryFormatter; private $jsonDecode; - private $requestAssembler; - private $guzzleClientFactory; + private $httpClientFactory; + private $requestFactory; + private $streamFactory; - public function __construct(GuzzleClientFactory $guzzleClientFactory) - { + public function __construct( + HttpClientFactory $httpClientFactory, + RequestFactoryInterface $requestFactory, + StreamFactoryInterface $streamFactory + ) { $this->logger = new NullLogger(); $this->queryFormatter = new ComplexParametersQueryFormatter(); $this->jsonDecode = new JsonDecode(); - $this->requestAssembler = new GuzzleRequestAssembler(); - $this->guzzleClientFactory = $guzzleClientFactory; + $this->httpClientFactory = $httpClientFactory; + $this->requestFactory = $requestFactory; + $this->streamFactory = $streamFactory; } - public function createRestRequestExecutor(): RestRequestExecutor + public function createRestRequestExecutor(ClientInterface $externalClient): RestRequestExecutor { $restRequestMapper = new RestRequestMapper($this->queryFormatter); $restResponseMapper = new RestResponseMapper($this->jsonDecode); @@ -45,13 +51,14 @@ public function createRestRequestExecutor(): RestRequestExecutor return new RestRequestExecutor( $restRequestMapper, - $this->createGuzzleClient(), + $this->createHttpClient($externalClient), $restResponseMapper, - $this->requestAssembler + $this->requestFactory, + $this->streamFactory ); } - public function createLegacyRequestExecutor(): LegacyRequestExecutor + public function createLegacyRequestExecutor(ClientInterface $externalClient): LegacyRequestExecutor { $legacyRequestMapper = new LegacyRequestMapper($this->queryFormatter); $legacyResponseMapper = new LegacyResponseMapper($this->jsonDecode); @@ -59,15 +66,16 @@ public function createLegacyRequestExecutor(): LegacyRequestExecutor return new LegacyRequestExecutor( $legacyRequestMapper, - $this->createGuzzleClient(), + $this->createHttpClient($externalClient), $legacyResponseMapper, - $this->requestAssembler + $this->requestFactory, + $this->streamFactory ); } - private function createGuzzleClient(): ClientInterface + private function createHttpClient(ClientInterface $externalHttpClient): ClientInterface { - $this->guzzleClientFactory->setLogger($this->logger); - return $this->guzzleClientFactory->createClient(); + $this->httpClientFactory->setLogger($this->logger); + return $this->httpClientFactory->createClient($externalHttpClient); } } diff --git a/src/Infrastructure/RequestExecutor/RestRequestExecutor.php b/src/Infrastructure/RequestExecutor/RestRequestExecutor.php index 5914b92..8665951 100644 --- a/src/Infrastructure/RequestExecutor/RestRequestExecutor.php +++ b/src/Infrastructure/RequestExecutor/RestRequestExecutor.php @@ -5,8 +5,10 @@ namespace Smsapi\Client\Infrastructure\RequestExecutor; use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; use Smsapi\Client\Infrastructure\Request; -use Smsapi\Client\Infrastructure\RequestAssembler\GuzzleRequestAssembler; +use Smsapi\Client\Infrastructure\RequestAssembler\RequestAssembler; use Smsapi\Client\Infrastructure\RequestMapper\RestRequestMapper; use Smsapi\Client\Infrastructure\ResponseMapper\RestResponseMapper; use stdClass; @@ -19,18 +21,21 @@ class RestRequestExecutor private $requestMapper; private $client; private $restResponseMapper; - private $requestAssembler; + private $requestFactory; + private $streamFactory; public function __construct( RestRequestMapper $requestMapper, ClientInterface $client, RestResponseMapper $restResponseMapper, - GuzzleRequestAssembler $guzzleRequestAssembler + RequestFactoryInterface $requestFactory, + StreamFactoryInterface $streamFactory ) { $this->requestMapper = $requestMapper; $this->client = $client; $this->restResponseMapper = $restResponseMapper; - $this->requestAssembler = $guzzleRequestAssembler; + $this->requestFactory = $requestFactory; + $this->streamFactory = $streamFactory; } public function create(string $path, array $builtInParameters, array $userParameters = []): stdClass @@ -68,7 +73,7 @@ public function info(string $path, array $builtInParameters, array $userParamete private function sendRequestAndMapResponse(Request $request): stdClass { - $assembledRequest = $this->requestAssembler->assemble($request); + $assembledRequest = (new RequestAssembler($this->requestFactory, $this->streamFactory))->assemble($request); $response = $this->client->sendRequest($assembledRequest); diff --git a/src/Service/HttpDefaultFeatures.php b/src/Service/HttpDefaultFeatures.php index 16a2690..cb9abf2 100644 --- a/src/Service/HttpDefaultFeatures.php +++ b/src/Service/HttpDefaultFeatures.php @@ -37,17 +37,21 @@ trait HttpDefaultFeatures public function pingFeature(): PingFeature { - return new PingHttpFeature($this->requestExecutorFactory->createRestRequestExecutor()); + return new PingHttpFeature($this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient)); } public function smsFeature(): SmsFeature { - return new SmsHttpFeature($this->requestExecutorFactory, $this->dataFactoryProvider); + return new SmsHttpFeature( + $this->externalHttpClient, + $this->requestExecutorFactory, + $this->dataFactoryProvider + ); } public function mfaFeature(): MfaFeature { - $restRequestExecutor = $this->requestExecutorFactory->createRestRequestExecutor(); + $restRequestExecutor = $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient); $mfaFactory = $this->dataFactoryProvider->provideMfaFactory(); return new MfaHttpFeature($restRequestExecutor, $mfaFactory); @@ -56,7 +60,7 @@ public function mfaFeature(): MfaFeature public function hlrFeature(): HlrFeature { return new HlrHttpFeature( - $this->requestExecutorFactory->createLegacyRequestExecutor(), + $this->requestExecutorFactory->createLegacyRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider->provideHlrFactory() ); } @@ -64,7 +68,7 @@ public function hlrFeature(): HlrFeature public function subusersFeature(): SubusersFeature { return new SubusersHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), + $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider->provideSubuserFactory() ); } @@ -72,7 +76,7 @@ public function subusersFeature(): SubusersFeature public function shortUrlFeature(): ShortUrlFeature { return new ShortUlrHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), + $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider->provideShortUrlLinkFactory() ); } @@ -80,7 +84,7 @@ public function shortUrlFeature(): ShortUrlFeature public function contactsFeature(): ContactsFeature { return new ContactsHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), + $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider ); } @@ -88,7 +92,7 @@ public function contactsFeature(): ContactsFeature public function pushFeature(): PushFeature { return new PushHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), + $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider->providePushShipmentFactory() ); } @@ -96,7 +100,7 @@ public function pushFeature(): PushFeature public function blacklistFeature(): BlacklistFeature { return new BlacklistHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), + $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider->provideBlacklistedPhoneNumberFactory() ); } diff --git a/src/Service/SmsapiComHttpService.php b/src/Service/SmsapiComHttpService.php index a32742a..218ac7a 100644 --- a/src/Service/SmsapiComHttpService.php +++ b/src/Service/SmsapiComHttpService.php @@ -4,6 +4,7 @@ namespace Smsapi\Client\Service; +use Psr\Http\Client\ClientInterface; use Smsapi\Client\Feature\Data\DataFactoryProvider; use Smsapi\Client\Feature\Profile\ProfileFeature; use Smsapi\Client\Feature\Profile\ProfileHttpFeature; @@ -18,13 +19,16 @@ class SmsapiComHttpService implements SmsapiComService { use HttpDefaultFeatures; + private $externalHttpClient; private $requestExecutorFactory; private $dataFactoryProvider; public function __construct( + ClientInterface $externalHttpClient, RequestExecutorFactory $requestExecutorFactory, DataFactoryProvider $dataFactoryProvider ) { + $this->externalHttpClient = $externalHttpClient; $this->requestExecutorFactory = $requestExecutorFactory; $this->dataFactoryProvider = $dataFactoryProvider; } @@ -32,7 +36,7 @@ public function __construct( public function profileFeature(): ProfileFeature { return new ProfileHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), + $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider ); } diff --git a/src/Service/SmsapiPlHttpService.php b/src/Service/SmsapiPlHttpService.php index 4ba8425..17f9772 100644 --- a/src/Service/SmsapiPlHttpService.php +++ b/src/Service/SmsapiPlHttpService.php @@ -4,6 +4,7 @@ namespace Smsapi\Client\Service; +use Psr\Http\Client\ClientInterface; use Smsapi\Client\Feature\Data\DataFactoryProvider; use Smsapi\Client\Feature\Mms\MmsFeature; use Smsapi\Client\Feature\Mms\MmsHttpFeature; @@ -20,13 +21,16 @@ class SmsapiPlHttpService implements SmsapiPlService { use HttpDefaultFeatures; + private $externalHttpClient; private $requestExecutorFactory; private $dataFactoryProvider; public function __construct( + ClientInterface $externalHttpClient, RequestExecutorFactory $requestExecutorFactory, DataFactoryProvider $dataFactoryProvider ) { + $this->externalHttpClient = $externalHttpClient; $this->requestExecutorFactory = $requestExecutorFactory; $this->dataFactoryProvider = $dataFactoryProvider; } @@ -34,7 +38,7 @@ public function __construct( public function mmsFeature(): MmsFeature { return new MmsHttpFeature( - $this->requestExecutorFactory->createLegacyRequestExecutor(), + $this->requestExecutorFactory->createLegacyRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider->provideMmsFactory() ); } @@ -42,7 +46,7 @@ public function mmsFeature(): MmsFeature public function vmsFeature(): VmsFeature { return new VmsHttpFeature( - $this->requestExecutorFactory->createLegacyRequestExecutor(), + $this->requestExecutorFactory->createLegacyRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider->provideVmsFactory() ); } @@ -50,7 +54,7 @@ public function vmsFeature(): VmsFeature public function profileFeature(): SmsapiPlProfileFeature { return new SmsapiPlProfileHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), + $this->requestExecutorFactory->createRestRequestExecutor($this->externalHttpClient), $this->dataFactoryProvider ); } diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index b7bd2c7..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -14,8 +14,6 @@ interface SmsapiClient extends LoggerAwareInterface { const VERSION = 'Unreleased'; - public function setProxy(string $proxy): self; - public function smsapiPlService(string $apiToken): SmsapiPlService; public function smsapiPlServiceWithUri(string $apiToken, string $uri): SmsapiPlService; diff --git a/src/SmsapiHttpClient.php b/src/SmsapiHttpClient.php index 9723bc6..00b8967 100644 --- a/src/SmsapiHttpClient.php +++ b/src/SmsapiHttpClient.php @@ -4,10 +4,13 @@ namespace Smsapi\Client; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\NullLogger; use Smsapi\Client\Feature\Data\DataFactoryProvider; -use Smsapi\Client\Infrastructure\Client\GuzzleClientFactory; +use Smsapi\Client\Infrastructure\HttpClient\HttpClientFactory; use Smsapi\Client\Infrastructure\RequestExecutor\RequestExecutorFactory; use Smsapi\Client\Service\SmsapiComService; use Smsapi\Client\Service\SmsapiComHttpService; @@ -21,22 +24,24 @@ class SmsapiHttpClient implements SmsapiClient { use LoggerAwareTrait; + private $httpClient; + private $requestFactory; + private $streamFactory; + private $smsapiPlUri = 'https://api.smsapi.pl'; private $smsapiComUri = 'https://api.smsapi.com'; - private $proxy = ''; private $dataFactoryProvider; - public function __construct() - { + public function __construct( + ClientInterface $httpClient, + RequestFactoryInterface $requestFactory, + StreamFactoryInterface $streamFactory + ) { + $this->httpClient = $httpClient; + $this->requestFactory = $requestFactory; $this->dataFactoryProvider = new DataFactoryProvider(); $this->logger = new NullLogger(); - } - - public function setProxy(string $proxy): SmsapiClient - { - $this->proxy = $proxy; - - return $this; + $this->streamFactory = $streamFactory; } public function smsapiPlService(string $apiToken): SmsapiPlService @@ -47,6 +52,7 @@ public function smsapiPlService(string $apiToken): SmsapiPlService public function smsapiPlServiceWithUri(string $apiToken, string $uri): SmsapiPlService { return new SmsapiPlHttpService( + $this->httpClient, $this->createRequestExecutorFactory($apiToken, $uri), $this->dataFactoryProvider ); @@ -60,6 +66,7 @@ public function smsapiComService(string $apiToken): SmsapiComService public function smsapiComServiceWithUri(string $apiToken, string $uri): SmsapiComService { return new SmsapiComHttpService( + $this->httpClient, $this->createRequestExecutorFactory($apiToken, $uri), $this->dataFactoryProvider ); @@ -67,8 +74,8 @@ public function smsapiComServiceWithUri(string $apiToken, string $uri): SmsapiCo private function createRequestExecutorFactory(string $apiToken, string $uri): RequestExecutorFactory { - $guzzleClientFactory = new GuzzleClientFactory($apiToken, $uri, $this->proxy); - $requestExecutorFactory = new RequestExecutorFactory($guzzleClientFactory); + $httpClientFactory = new HttpClientFactory($apiToken, $uri); + $requestExecutorFactory = new RequestExecutorFactory($httpClientFactory, $this->requestFactory, $this->streamFactory); $requestExecutorFactory->setLogger($this->logger); return $requestExecutorFactory; diff --git a/tests/Fixture/GuzzleClientFactoryMother.php b/tests/Fixture/GuzzleClientFactoryMother.php deleted file mode 100644 index 9fcfceb..0000000 --- a/tests/Fixture/GuzzleClientFactoryMother.php +++ /dev/null @@ -1,15 +0,0 @@ -proxy = $proxy; - } - public function sendRequest(RequestInterface $request): ResponseInterface { $guzzleClient = new Client([ RequestOptions::HTTP_ERRORS => false, - RequestOptions::PROXY => $this->proxy, ]); try { diff --git a/tests/Helper/HttpClient/HttpClientMock.php b/tests/Helper/HttpClient/HttpClientMock.php new file mode 100644 index 0000000..da1a39f --- /dev/null +++ b/tests/Helper/HttpClient/HttpClientMock.php @@ -0,0 +1,51 @@ +mockHandler = new MockHandler(); + } + + public function sendRequest(RequestInterface $request): ResponseInterface + { + $guzzleClient = new Client([ + 'handler' => HandlerStack::create($this->mockHandler) + ]); + + try { + return $guzzleClient->send($request); + } catch (GuzzleRequestException $e) { + throw RequestException::create($request, $e); + } catch (GuzzleTransferException $e) { + throw NetworkException::create($request, $e); + } catch (GuzzleException $e) { + throw ClientException::create($request, $e); + } + } + + public function mockResponse(int $statusCode, string $body) + { + $this->mockHandler->append(new Response($statusCode, [], $body)); + } +} \ No newline at end of file diff --git a/tests/Helper/HttpClient/RequestFactory.php b/tests/Helper/HttpClient/RequestFactory.php new file mode 100644 index 0000000..23f159c --- /dev/null +++ b/tests/Helper/HttpClient/RequestFactory.php @@ -0,0 +1,17 @@ +setLogger(new TestLogger()); diff --git a/tests/SmsapiClientUnitTestCase.php b/tests/SmsapiClientUnitTestCase.php index c7bffa5..78de430 100644 --- a/tests/SmsapiClientUnitTestCase.php +++ b/tests/SmsapiClientUnitTestCase.php @@ -3,15 +3,7 @@ namespace Smsapi\Client\Tests; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\Response; -use Psr\Http\Client\ClientInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; use Smsapi\Client\Feature\Data\DataFactoryProvider; -use Smsapi\Client\Infrastructure\RequestAssembler\GuzzleRequestAssembler; use Smsapi\Client\Infrastructure\RequestExecutor\LegacyRequestExecutor; use Smsapi\Client\Infrastructure\RequestExecutor\RequestExecutorFactory; use Smsapi\Client\Infrastructure\RequestExecutor\RestRequestExecutor; @@ -22,65 +14,61 @@ use Smsapi\Client\Infrastructure\ResponseMapper\LegacyResponseMapper; use Smsapi\Client\Infrastructure\ResponseMapper\RestResponseMapper; use Smsapi\Client\Service\SmsapiPlHttpService; +use Smsapi\Client\Tests\Helper\HttpClient\HttpClientMock; +use Smsapi\Client\Tests\Helper\HttpClient\RequestFactory; +use Smsapi\Client\Tests\Helper\HttpClient\StreamFactory; class SmsapiClientUnitTestCase extends SmsapiClientTestCase { - /** @var MockHandler */ - private $mockHandler; + /** @var HttpClientMock */ + private $httpClient; /** * @before */ public function prepare() { - $this->mockHandler = new MockHandler(); - - $guzzleHttp = new class($this->mockHandler) implements ClientInterface { - private $handler; - - public function __construct(MockHandler $handler) - { - $this->handler = $handler; - } - - public function sendRequest(RequestInterface $request): ResponseInterface - { - $guzzleClient = new Client(['handler' => HandlerStack::create($this->handler)]); - - return $guzzleClient->send($request); - } - }; + $this->httpClient = new HttpClientMock(); + $requestFactory = new RequestFactory(); + $streamFactory = new StreamFactory(); $queryFormatter = new ComplexParametersQueryFormatter(); $jsonDecode = new JsonDecode(); + /** @var RequestExecutorFactory $requestExecutorFactory */ $requestExecutorFactory = $this->prophesize(RequestExecutorFactory::class); $requestExecutorFactory - ->createLegacyRequestExecutor() + ->createLegacyRequestExecutor($this->httpClient) ->willReturn( new LegacyRequestExecutor( new LegacyRequestMapper($queryFormatter), - $guzzleHttp, + $this->httpClient, new LegacyResponseMapper($jsonDecode), - new GuzzleRequestAssembler() + $requestFactory, + $streamFactory ) ); $requestExecutorFactory - ->createRestRequestExecutor() + ->createRestRequestExecutor($this->httpClient) ->willReturn( new RestRequestExecutor( new RestRequestMapper($queryFormatter), - $guzzleHttp, + $this->httpClient, new RestResponseMapper($jsonDecode), - new GuzzleRequestAssembler() + $requestFactory, + $streamFactory ) ); - self::$smsapiService = new SmsapiPlHttpService($requestExecutorFactory->reveal(), new DataFactoryProvider()); + self::$smsapiService = new SmsapiPlHttpService( + $this->httpClient, + $requestExecutorFactory->reveal(), + new DataFactoryProvider() + ); } protected function mockResponse(int $statusCode, string $body) { - $this->mockHandler->append(new Response($statusCode, [], $body)); + $this->httpClient->mockResponse($statusCode, $body); } } diff --git a/tests/Unit/Infrastructure/RequestExecutor/GuzzleClientFactoryTest.php b/tests/Unit/Infrastructure/RequestExecutor/GuzzleClientFactoryTest.php deleted file mode 100644 index 02d99c5..0000000 --- a/tests/Unit/Infrastructure/RequestExecutor/GuzzleClientFactoryTest.php +++ /dev/null @@ -1,24 +0,0 @@ -createClient(); - - $this->assertInstanceOf(ClientInterface::class, $result); - } -} diff --git a/tests/Unit/Infrastructure/RequestExecutor/RequestExecutorFactoryTest.php b/tests/Unit/Infrastructure/RequestExecutor/RequestExecutorFactoryTest.php deleted file mode 100644 index 47befd6..0000000 --- a/tests/Unit/Infrastructure/RequestExecutor/RequestExecutorFactoryTest.php +++ /dev/null @@ -1,38 +0,0 @@ -createRestRequestExecutor(); - - $this->assertInstanceOf(RestRequestExecutor::class, $result); - } - - /** - * @test - */ - public function it_should_create_legacy_request_executor() - { - $requestExecutorFactory = new RequestExecutorFactory(GuzzleClientFactoryMother::any()); - - $result = $requestExecutorFactory->createLegacyRequestExecutor(); - - $this->assertInstanceOf(LegacyRequestExecutor::class, $result); - } -} From 3bf1969741da9bc2cd006aca46c0f533574d89b3 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 20 Oct 2020 14:38:27 +0200 Subject: [PATCH 02/93] Removes push feature --- CHANGELOG.md | 1 + composer.json | 1 - src/Feature/Data/DataFactoryProvider.php | 17 ----- src/Feature/Push/Bag/SendPushBag.php | 54 ------------- src/Feature/Push/Data/PushApp.php | 19 ----- src/Feature/Push/Data/PushAppFactory.php | 24 ------ src/Feature/Push/Data/PushShipment.php | 42 ----------- .../Push/Data/PushShipmentDispatchDetails.php | 19 ----- .../PushShipmentDispatchDetailsFactory.php | 21 ------ src/Feature/Push/Data/PushShipmentFactory.php | 50 ------------- .../Push/Data/PushShipmentFallback.php | 22 ------ .../Push/Data/PushShipmentFallbackFactory.php | 22 ------ src/Feature/Push/Data/PushShipmentPayload.php | 13 ---- .../Push/Data/PushShipmentPayloadFactory.php | 19 ----- src/Feature/Push/Data/PushShipmentSummary.php | 19 ----- .../Push/Data/PushShipmentSummaryFactory.php | 21 ------ src/Feature/Push/PushFeature.php | 16 ---- src/Feature/Push/PushHttpFeature.php | 37 --------- src/Service/HttpDefaultFeatures.php | 10 --- src/Service/SmsapiComService.php | 4 - src/Service/SmsapiPlService.php | 4 - tests/Unit/Feature/Push/PushFeatureTest.php | 75 ------------------- 22 files changed, 1 insertion(+), 509 deletions(-) delete mode 100644 src/Feature/Push/Bag/SendPushBag.php delete mode 100644 src/Feature/Push/Data/PushApp.php delete mode 100644 src/Feature/Push/Data/PushAppFactory.php delete mode 100644 src/Feature/Push/Data/PushShipment.php delete mode 100644 src/Feature/Push/Data/PushShipmentDispatchDetails.php delete mode 100644 src/Feature/Push/Data/PushShipmentDispatchDetailsFactory.php delete mode 100644 src/Feature/Push/Data/PushShipmentFactory.php delete mode 100644 src/Feature/Push/Data/PushShipmentFallback.php delete mode 100644 src/Feature/Push/Data/PushShipmentFallbackFactory.php delete mode 100644 src/Feature/Push/Data/PushShipmentPayload.php delete mode 100644 src/Feature/Push/Data/PushShipmentPayloadFactory.php delete mode 100644 src/Feature/Push/Data/PushShipmentSummary.php delete mode 100644 src/Feature/Push/Data/PushShipmentSummaryFactory.php delete mode 100644 src/Feature/Push/PushFeature.php delete mode 100644 src/Feature/Push/PushHttpFeature.php delete mode 100644 tests/Unit/Feature/Push/PushFeatureTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index e49a5ac..b76fba6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - `CreateContactBag::withPhone` marked as deprecated ### Removed +- `PushFeature` - `SendSmsBag::setIdx` - `DeleteSmsBag` - `FindSendernamesBag` diff --git a/composer.json b/composer.json index c63aa0a..15651a1 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,6 @@ "require-dev": { "phpunit/phpunit": "^6", "symfony/yaml": "^3", - "theodorejb/polycast": "^1", "marc-mabe/php-enum": "^3", "phing/phing": "^2.5", "doctrine/instantiator": "1.0.5", diff --git a/src/Feature/Data/DataFactoryProvider.php b/src/Feature/Data/DataFactoryProvider.php index 40f7a6c..567164e 100644 --- a/src/Feature/Data/DataFactoryProvider.php +++ b/src/Feature/Data/DataFactoryProvider.php @@ -18,12 +18,6 @@ use Smsapi\Client\Feature\Profile\Data\ProfilePriceCountryFactory; use Smsapi\Client\Feature\Profile\Data\ProfilePriceFactory; use Smsapi\Client\Feature\Profile\Data\ProfilePriceNetworkFactory; -use Smsapi\Client\Feature\Push\Data\PushAppFactory; -use Smsapi\Client\Feature\Push\Data\PushShipmentDispatchDetailsFactory; -use Smsapi\Client\Feature\Push\Data\PushShipmentFactory; -use Smsapi\Client\Feature\Push\Data\PushShipmentFallbackFactory; -use Smsapi\Client\Feature\Push\Data\PushShipmentPayloadFactory; -use Smsapi\Client\Feature\Push\Data\PushShipmentSummaryFactory; use Smsapi\Client\Feature\ShortUrl\Data\ShortUrlLinkFactory; use Smsapi\Client\Feature\Sms\Data\SmsFactory; use Smsapi\Client\Feature\Mfa\Data\MfaFactory; @@ -90,17 +84,6 @@ public function provideShortUrlLinkFactory(): ShortUrlLinkFactory return new ShortUrlLinkFactory(); } - public function providePushShipmentFactory(): PushShipmentFactory - { - return new PushShipmentFactory( - new PushAppFactory(), - new PushShipmentPayloadFactory(), - new PushShipmentSummaryFactory(), - new PushShipmentDispatchDetailsFactory(), - new PushShipmentFallbackFactory() - ); - } - public function provideContactFactory(): ContactFactory { return new ContactFactory($this->provideContactGroupFactory(), $this->provideConntactCustomFieldFactory()); diff --git a/src/Feature/Push/Bag/SendPushBag.php b/src/Feature/Push/Bag/SendPushBag.php deleted file mode 100644 index 61e2547..0000000 --- a/src/Feature/Push/Bag/SendPushBag.php +++ /dev/null @@ -1,54 +0,0 @@ -appId = $appId; - $this->data['alert'] = $alert; - } - - public function setFallback(string $message, string $from, int $delay): self - { - $this->fallback['message'] = $message; - $this->fallback['from'] = $from; - $this->fallback['delay'] = $delay; - - return $this; - } - - public function setAndroidData(string $title, string $url): self - { - $this->data['from'] = $title; - $this->data['delay'] = $url; - - return $this; - } - - public function setIosData(string $badge, string $sound, string $category, bool $contentAvailable): self - { - $this->data['badge'] = $badge; - $this->data['sound'] = $sound; - $this->data['category'] = $category; - $this->data['contentAvailable'] = $contentAvailable; - - return $this; - } -} diff --git a/src/Feature/Push/Data/PushApp.php b/src/Feature/Push/Data/PushApp.php deleted file mode 100644 index b73149a..0000000 --- a/src/Feature/Push/Data/PushApp.php +++ /dev/null @@ -1,19 +0,0 @@ -id = $object->id; - $pushApp->name = $object->name; - - if (isset($object->icon)) { - $pushApp->icon = $object->icon; - } - - return $pushApp; - } -} diff --git a/src/Feature/Push/Data/PushShipment.php b/src/Feature/Push/Data/PushShipment.php deleted file mode 100644 index 75c3dae..0000000 --- a/src/Feature/Push/Data/PushShipment.php +++ /dev/null @@ -1,42 +0,0 @@ -channels = $object->channels; - $details->deviceIds = $object->device_ids; - $details->deviceType = $object->device_type; - - return $details; - } -} diff --git a/src/Feature/Push/Data/PushShipmentFactory.php b/src/Feature/Push/Data/PushShipmentFactory.php deleted file mode 100644 index e391a7a..0000000 --- a/src/Feature/Push/Data/PushShipmentFactory.php +++ /dev/null @@ -1,50 +0,0 @@ -appFactory = $appFactory; - $this->payloadFactory = $payloadFactory; - $this->summaryFactory = $summaryFactory; - $this->detailsFactory = $detailsFactory; - $this->fallbackFactory = $fallbackFactory; - } - - public function createFromObject(stdClass $object): PushShipment - { - $pushShipment = new PushShipment(); - $pushShipment->id = $object->id; - $pushShipment->status = $object->status; - $pushShipment->dateCreated = new DateTime($object->date_created); - $pushShipment->scheduledDate = new DateTime($object->scheduled_date); - $pushShipment->app = $this->appFactory->createFromObject($object->app); - $pushShipment->payload = $this->payloadFactory->createFromObject($object->payload); - $pushShipment->summary = $this->summaryFactory->createFromObject($object->summary); - $pushShipment->dispatchDetails = $this->detailsFactory->createFromObject($object->dispatch_details); - $pushShipment->fallback = $this->fallbackFactory->createFromObject($object->fallback); - - return $pushShipment; - } -} diff --git a/src/Feature/Push/Data/PushShipmentFallback.php b/src/Feature/Push/Data/PushShipmentFallback.php deleted file mode 100644 index 2b05a0d..0000000 --- a/src/Feature/Push/Data/PushShipmentFallback.php +++ /dev/null @@ -1,22 +0,0 @@ -message = $object->message; - $fallback->from = $object->from; - $fallback->delay = $object->delay; - $fallback->status = $object->status; - - return $fallback; - } -} diff --git a/src/Feature/Push/Data/PushShipmentPayload.php b/src/Feature/Push/Data/PushShipmentPayload.php deleted file mode 100644 index e7a4feb..0000000 --- a/src/Feature/Push/Data/PushShipmentPayload.php +++ /dev/null @@ -1,13 +0,0 @@ -alert = $object->alert; - - return $payload; - } -} diff --git a/src/Feature/Push/Data/PushShipmentSummary.php b/src/Feature/Push/Data/PushShipmentSummary.php deleted file mode 100644 index 36cc8cf..0000000 --- a/src/Feature/Push/Data/PushShipmentSummary.php +++ /dev/null @@ -1,19 +0,0 @@ -points = (float)$object->points; - $summary->recipientsCount = $object->recipients_count; - $summary->errorCode = $object->error_code; - - return $summary; - } -} diff --git a/src/Feature/Push/PushFeature.php b/src/Feature/Push/PushFeature.php deleted file mode 100644 index bad467f..0000000 --- a/src/Feature/Push/PushFeature.php +++ /dev/null @@ -1,16 +0,0 @@ -restRequestExecutor = $restRequestExecutor; - $this->pushShipmentFactory = $pushShipmentFactory; - } - - /** - * @param SendPushBag $sendPushBag - * @return PushShipment - * @throws SmsapiClientException - */ - public function createPush(SendPushBag $sendPushBag): PushShipment - { - $result = $this->restRequestExecutor->create('push', (array)$sendPushBag); - - return $this->pushShipmentFactory->createFromObject($result); - } -} diff --git a/src/Service/HttpDefaultFeatures.php b/src/Service/HttpDefaultFeatures.php index 16a2690..f824a82 100644 --- a/src/Service/HttpDefaultFeatures.php +++ b/src/Service/HttpDefaultFeatures.php @@ -10,8 +10,6 @@ use Smsapi\Client\Feature\Data\DataFactoryProvider; use Smsapi\Client\Feature\Hlr\HlrFeature; use Smsapi\Client\Feature\Hlr\HlrHttpFeature; -use Smsapi\Client\Feature\Push\PushFeature; -use Smsapi\Client\Feature\Push\PushHttpFeature; use Smsapi\Client\Feature\ShortUrl\ShortUlrHttpFeature; use Smsapi\Client\Feature\ShortUrl\ShortUrlFeature; use Smsapi\Client\Feature\Mfa\MfaFeature; @@ -85,14 +83,6 @@ public function contactsFeature(): ContactsFeature ); } - public function pushFeature(): PushFeature - { - return new PushHttpFeature( - $this->requestExecutorFactory->createRestRequestExecutor(), - $this->dataFactoryProvider->providePushShipmentFactory() - ); - } - public function blacklistFeature(): BlacklistFeature { return new BlacklistHttpFeature( diff --git a/src/Service/SmsapiComService.php b/src/Service/SmsapiComService.php index ccb43cc..a86abed 100644 --- a/src/Service/SmsapiComService.php +++ b/src/Service/SmsapiComService.php @@ -9,7 +9,6 @@ use Smsapi\Client\Feature\Hlr\HlrFeature; use Smsapi\Client\Feature\Ping\PingFeature; use Smsapi\Client\Feature\Profile\ProfileFeature; -use Smsapi\Client\Feature\Push\PushFeature; use Smsapi\Client\Feature\ShortUrl\ShortUrlFeature; use Smsapi\Client\Feature\Mfa\MfaFeature; use Smsapi\Client\Feature\Sms\SmsFeature; @@ -36,8 +35,5 @@ public function shortUrlFeature(): ShortUrlFeature; public function contactsFeature(): ContactsFeature; - /** @deprecated */ - public function pushFeature(): PushFeature; - public function blacklistFeature(): BlacklistFeature; } diff --git a/src/Service/SmsapiPlService.php b/src/Service/SmsapiPlService.php index 7cf33f4..2f4e9b8 100644 --- a/src/Service/SmsapiPlService.php +++ b/src/Service/SmsapiPlService.php @@ -10,7 +10,6 @@ use Smsapi\Client\Feature\Mms\MmsFeature; use Smsapi\Client\Feature\Ping\PingFeature; use Smsapi\Client\Feature\Profile\SmsapiPlProfileFeature; -use Smsapi\Client\Feature\Push\PushFeature; use Smsapi\Client\Feature\ShortUrl\ShortUrlFeature; use Smsapi\Client\Feature\Mfa\MfaFeature; use Smsapi\Client\Feature\Sms\SmsFeature; @@ -38,9 +37,6 @@ public function shortUrlFeature(): ShortUrlFeature; public function contactsFeature(): ContactsFeature; - /** @deprecated */ - public function pushFeature(): PushFeature; - public function mmsFeature(): MmsFeature; public function vmsFeature(): VmsFeature; diff --git a/tests/Unit/Feature/Push/PushFeatureTest.php b/tests/Unit/Feature/Push/PushFeatureTest.php deleted file mode 100644 index a40bf6e..0000000 --- a/tests/Unit/Feature/Push/PushFeatureTest.php +++ /dev/null @@ -1,75 +0,0 @@ -mockResponse(ResponseHttpCode::OK, $body); - $pushShipment = json_decode($body); - $pushFeature = self::$smsapiService->pushFeature(); - $sendPushBag = new SendPushBag('1', $pushShipment->payload->alert); - - $result = $pushFeature->createPush($sendPushBag); - - $this->assertPushShipment($pushShipment, $result); - } - - private function assertPushShipment(stdClass $expected, PushShipment $actual) - { - $pushShipment = new PushShipment(); - $pushShipment->id = $expected->id; - $pushShipment->status = $expected->status; - $pushShipment->dateCreated = new DateTime($expected->date_created); - $pushShipment->scheduledDate = new DateTime($expected->scheduled_date); - - $pushShipment->app = new PushApp(); - $pushShipment->app->id = $expected->app->id; - $pushShipment->app->name = $expected->app->name; - $pushShipment->app->icon = $expected->app->icon; - - $pushShipment->payload = new PushShipmentPayload(); - $pushShipment->payload->alert = $expected->payload->alert; - - $pushShipment->summary = new PushShipmentSummary(); - $pushShipment->summary->points = to_float($expected->summary->points); - $pushShipment->summary->recipientsCount = $expected->summary->recipients_count; - $pushShipment->summary->errorCode = $expected->summary->error_code; - - $pushShipment->dispatchDetails = new PushShipmentDispatchDetails(); - $pushShipment->dispatchDetails->channels = $expected->dispatch_details->channels; - $pushShipment->dispatchDetails->deviceIds = $expected->dispatch_details->device_ids; - $pushShipment->dispatchDetails->deviceType = $expected->dispatch_details->device_type; - - $pushShipment->fallback = new PushShipmentFallback(); - $pushShipment->fallback->message = $expected->fallback->message; - $pushShipment->fallback->from = $expected->fallback->from; - $pushShipment->fallback->delay = $expected->fallback->delay; - $pushShipment->fallback->status = $expected->fallback->status; - - $this->assertEquals($pushShipment, $actual); - } -} From 0ce6f1535fb19c2a126468926d3af59ab42092a1 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 28 Oct 2020 17:09:14 +0100 Subject: [PATCH 03/93] Adds optional Guzzle adapter --- Makefile | 1 + README.md | 113 ++++++++++-------- composer.json | 6 +- .../Guzzle}/Exception/ClientException.php | 2 +- .../Guzzle}/Exception/NetworkException.php | 2 +- .../Guzzle}/Exception/RequestException.php | 2 +- src/Guzzle/GuzzleDiscovery.php | 17 +++ .../HttpClient => src/Guzzle}/HttpClient.php | 11 +- .../Guzzle}/RequestFactory.php | 5 +- src/Guzzle/SmsapiHttpClient.php | 54 +++++++++ .../Guzzle}/StreamFactory.php | 5 +- tests/Helper/HttpClient/HttpClientMock.php | 9 +- tests/SmsapiClientIntegrationTestCase.php | 7 +- tests/SmsapiClientUnitTestCase.php | 4 +- 14 files changed, 169 insertions(+), 69 deletions(-) rename {tests/Helper/HttpClient => src/Guzzle}/Exception/ClientException.php (90%) rename {tests/Helper/HttpClient => src/Guzzle}/Exception/NetworkException.php (75%) rename {tests/Helper/HttpClient => src/Guzzle}/Exception/RequestException.php (75%) create mode 100644 src/Guzzle/GuzzleDiscovery.php rename {tests/Helper/HttpClient => src/Guzzle}/HttpClient.php (79%) rename {tests/Helper/HttpClient => src/Guzzle}/RequestFactory.php (86%) create mode 100644 src/Guzzle/SmsapiHttpClient.php rename {tests/Helper/HttpClient => src/Guzzle}/StreamFactory.php (92%) diff --git a/Makefile b/Makefile index 1704bc8..b8c1708 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ help: prepare: ## load dependencies docker-compose run -T php /usr/bin/composer update + docker-compose run -T php /usr/bin/composer require --dev guzzlehttp/guzzle test: prepare ## run test docker-compose run -T php php vendor/bin/phing -f build.xml test diff --git a/README.md b/README.md index e94b4ff..d17447e 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,25 @@ Depending on which of SMSAPI service your account is, you should pick it calling Starting form version 3, SMSAPI PHP Client supports PSR-17 and PSR-18 compliant HTTP clients. That way this library is independent of client of your choice. -You have to provide your own HTTP client, request factory and stream factory to use our library. -All following examples consider you have HTTP client, request factory and stream factory well-defined in `bootstrap.php` file. +You have to provide HTTP client, request factory and stream factory to use our library. -### How to use *SMSAPI.COM* client? +For your convenience we provide an adapter for Guzzle. All yout have to do is to require *guzzlehttp/guzzle* dependency in your project. +Example below shows how to make use of that adapter (pay attention to namespace *Smsapi\Client\Guzzle*): + +```php +smsapiComService($apiToken); +$service = $client->smsapiComService($apiToken); ``` -### How to use *SMSAPI.PL* client? +### How to use *SMSAPI.PL* service? ```php smsapiPlService($apiToken); +$service = $client->smsapiPlService($apiToken); ``` -## How to use a custom URI? +## How to use a service with custom URI? ```php smsapiComServiceWithUri($apiToken, $uri); +$service = $client->smsapiComServiceWithUri($apiToken, $uri); ``` ## How to use service business features? -All following examples consider you have an account on SMSAPI.COM and client has been setup in `client.php` file. +All following examples consider you have an account on SMSAPI.COM and service has been setup in `service.php` file. ### How to use ping feature? @@ -125,10 +148,10 @@ declare(strict_types=1); use Smsapi\Client\Service\SmsapiComService; -/** @var SmsapiComService $client */ -require_once 'client.php'; +/** @var SmsapiComService $service */ +require_once 'service.php'; -$result = $client->pingFeature() +$result = $service->pingFeature() ->ping(); if ($result->smsapi) { @@ -148,12 +171,12 @@ declare(strict_types=1); use Smsapi\Client\Service\SmsapiComService; use Smsapi\Client\Feature\Sms\Bag\SendSmsBag; -/** @var SmsapiComService $client */ -require_once 'client.php'; +/** @var SmsapiComService $service */ +require_once 'service.php'; $sms = SendSmsBag::withMessage('someone phone number', 'some message'); -$client->smsFeature() +$service->smsFeature() ->sendSms($sms); ``` @@ -167,13 +190,13 @@ declare(strict_types=1); use Smsapi\Client\Service\SmsapiComService; use Smsapi\Client\Feature\Sms\Bag\SendSmsBag; -/** @var SmsapiComService $client */ -require_once 'client.php'; +/** @var SmsapiComService $service */ +require_once 'service.php'; $sms = SendSmsBag::withMessage('someone phone number', 'some message'); $sms->from = 'Test'; -$client->smsFeature() +$service->smsFeature() ->sendSms($sms); ``` @@ -216,21 +239,16 @@ Set logger to `SmsapiHttpClient` instance. declare(strict_types=1); -use Psr\Http\Client\ClientInterface; -use Psr\Http\Message\RequestFactoryInterface; -use Psr\Http\Message\StreamFactoryInterface; use Psr\Log\LoggerInterface; use Psr\Log\LoggerTrait; -use Smsapi\Client\SmsapiHttpClient; +use Smsapi\Client\SmsapiClient; require_once 'vendor/autoload.php'; /** - * @var ClientInterface $httpClient - * @var RequestFactoryInterface $requestFactory - * @var StreamFactoryInterface $streamFactory + * @var SmsapiClient $client */ -require_once 'bootstrap.php'; +require_once 'client.php'; $logger = new class() implements LoggerInterface { @@ -242,8 +260,7 @@ $logger = new class() implements LoggerInterface } }; -(new SmsapiHttpClient($httpClient, $requestFactory, $streamFactory)) - ->setLogger($logger); +$client->setLogger($logger); ``` ## Test package diff --git a/composer.json b/composer.json index a3a2e7a..08bd724 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,9 @@ "phing/phing": "^2.5", "doctrine/instantiator": "1.0.5", "phpdocumentor/reflection-docblock": "^4.3", - "phpdocumentor/type-resolver": "^0.5", - "guzzlehttp/guzzle": "^6" + "phpdocumentor/type-resolver": "^0.5" + }, + "suggest": { + "guzzlehttp/guzzle": "^6 || ^7" } } diff --git a/tests/Helper/HttpClient/Exception/ClientException.php b/src/Guzzle/Exception/ClientException.php similarity index 90% rename from tests/Helper/HttpClient/Exception/ClientException.php rename to src/Guzzle/Exception/ClientException.php index fc0972c..809aeb5 100644 --- a/tests/Helper/HttpClient/Exception/ClientException.php +++ b/src/Guzzle/Exception/ClientException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Tests\Helper\HttpClient\Exception; +namespace Smsapi\Client\Guzzle\Exception; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\RequestInterface; diff --git a/tests/Helper/HttpClient/Exception/NetworkException.php b/src/Guzzle/Exception/NetworkException.php similarity index 75% rename from tests/Helper/HttpClient/Exception/NetworkException.php rename to src/Guzzle/Exception/NetworkException.php index a253de3..ba17a22 100644 --- a/tests/Helper/HttpClient/Exception/NetworkException.php +++ b/src/Guzzle/Exception/NetworkException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Tests\Helper\HttpClient\Exception; +namespace Smsapi\Client\Guzzle\Exception; use Psr\Http\Client\NetworkExceptionInterface; diff --git a/tests/Helper/HttpClient/Exception/RequestException.php b/src/Guzzle/Exception/RequestException.php similarity index 75% rename from tests/Helper/HttpClient/Exception/RequestException.php rename to src/Guzzle/Exception/RequestException.php index e690d6c..d400dc1 100644 --- a/tests/Helper/HttpClient/Exception/RequestException.php +++ b/src/Guzzle/Exception/RequestException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Tests\Helper\HttpClient\Exception; +namespace Smsapi\Client\Guzzle\Exception; use Psr\Http\Client\RequestExceptionInterface; diff --git a/src/Guzzle/GuzzleDiscovery.php b/src/Guzzle/GuzzleDiscovery.php new file mode 100644 index 0000000..764179a --- /dev/null +++ b/src/Guzzle/GuzzleDiscovery.php @@ -0,0 +1,17 @@ +httpClient = new \Smsapi\Client\SmsapiHttpClient( + new HttpClient(), + new RequestFactory(), + new StreamFactory() + ); + } + + public function setLogger(LoggerInterface $logger) + { + $this->httpClient->setLogger($logger); + } + + public function smsapiPlService(string $apiToken): SmsapiPlService + { + return $this->httpClient->smsapiPlService($apiToken); + } + + public function smsapiPlServiceWithUri(string $apiToken, string $uri): SmsapiPlService + { + return $this->httpClient->smsapiPlServiceWithUri($apiToken, $uri); + } + + public function smsapiComService(string $apiToken): SmsapiComService + { + return $this->httpClient->smsapiComService($apiToken); + } + + public function smsapiComServiceWithUri(string $apiToken, string $uri): SmsapiComService + { + return $this->httpClient->smsapiComServiceWithUri($apiToken, $uri); + } +} \ No newline at end of file diff --git a/tests/Helper/HttpClient/StreamFactory.php b/src/Guzzle/StreamFactory.php similarity index 92% rename from tests/Helper/HttpClient/StreamFactory.php rename to src/Guzzle/StreamFactory.php index f87b0e1..23cbab3 100644 --- a/tests/Helper/HttpClient/StreamFactory.php +++ b/src/Guzzle/StreamFactory.php @@ -2,12 +2,15 @@ declare(strict_types=1); -namespace Smsapi\Client\Tests\Helper\HttpClient; +namespace Smsapi\Client\Guzzle; use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; +/** + * @internal + */ class StreamFactory implements StreamFactoryInterface { public function createStream(string $content = ''): StreamInterface diff --git a/tests/Helper/HttpClient/HttpClientMock.php b/tests/Helper/HttpClient/HttpClientMock.php index da1a39f..c32b34f 100644 --- a/tests/Helper/HttpClient/HttpClientMock.php +++ b/tests/Helper/HttpClient/HttpClientMock.php @@ -14,9 +14,10 @@ use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use Smsapi\Client\Tests\Helper\HttpClient\Exception\ClientException; -use Smsapi\Client\Tests\Helper\HttpClient\Exception\NetworkException; -use Smsapi\Client\Tests\Helper\HttpClient\Exception\RequestException; +use Smsapi\Client\Guzzle\Exception\ClientException; +use Smsapi\Client\Guzzle\Exception\NetworkException; +use Smsapi\Client\Guzzle\Exception\RequestException; +use Smsapi\Client\Guzzle\GuzzleDiscovery; class HttpClientMock implements ClientInterface { @@ -24,6 +25,8 @@ class HttpClientMock implements ClientInterface public function __construct() { + GuzzleDiscovery::run(); + $this->mockHandler = new MockHandler(); } diff --git a/tests/SmsapiClientIntegrationTestCase.php b/tests/SmsapiClientIntegrationTestCase.php index 0ecf702..3b069f8 100644 --- a/tests/SmsapiClientIntegrationTestCase.php +++ b/tests/SmsapiClientIntegrationTestCase.php @@ -4,12 +4,9 @@ namespace Smsapi\Client\Tests; use RuntimeException; +use Smsapi\Client\Guzzle\SmsapiHttpClient; use Smsapi\Client\Service\SmsapiComService; use Smsapi\Client\Service\SmsapiPlService; -use Smsapi\Client\SmsapiHttpClient; -use Smsapi\Client\Tests\Helper\HttpClient\HttpClient; -use Smsapi\Client\Tests\Helper\HttpClient\RequestFactory; -use Smsapi\Client\Tests\Helper\HttpClient\StreamFactory; class SmsapiClientIntegrationTestCase extends SmsapiClientTestCase { @@ -34,7 +31,7 @@ public static function prepare() throw new RuntimeException('Invalid API URI'); } - $smsapiHttpClient = new SmsapiHttpClient(new HttpClient(), new RequestFactory(), new StreamFactory()); + $smsapiHttpClient = new SmsapiHttpClient(); if (Config::get('logger')) { $smsapiHttpClient->setLogger(new TestLogger()); diff --git a/tests/SmsapiClientUnitTestCase.php b/tests/SmsapiClientUnitTestCase.php index 78de430..25359f2 100644 --- a/tests/SmsapiClientUnitTestCase.php +++ b/tests/SmsapiClientUnitTestCase.php @@ -4,6 +4,8 @@ namespace Smsapi\Client\Tests; use Smsapi\Client\Feature\Data\DataFactoryProvider; +use Smsapi\Client\Guzzle\RequestFactory; +use Smsapi\Client\Guzzle\StreamFactory; use Smsapi\Client\Infrastructure\RequestExecutor\LegacyRequestExecutor; use Smsapi\Client\Infrastructure\RequestExecutor\RequestExecutorFactory; use Smsapi\Client\Infrastructure\RequestExecutor\RestRequestExecutor; @@ -15,8 +17,6 @@ use Smsapi\Client\Infrastructure\ResponseMapper\RestResponseMapper; use Smsapi\Client\Service\SmsapiPlHttpService; use Smsapi\Client\Tests\Helper\HttpClient\HttpClientMock; -use Smsapi\Client\Tests\Helper\HttpClient\RequestFactory; -use Smsapi\Client\Tests\Helper\HttpClient\StreamFactory; class SmsapiClientUnitTestCase extends SmsapiClientTestCase { From c000986e678ae0aaa726d8544585c187146e4512 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Thu, 5 Nov 2020 08:50:19 +0100 Subject: [PATCH 04/93] Replaces optional Guzzle adapter with Curl adapter --- Makefile | 1 - README.md | 10 +- composer.json | 5 +- src/Curl/CurlDiscovery.php | 20 ++++ .../Exception/ClientException.php | 8 +- .../Exception/NetworkException.php | 2 +- .../Exception/RequestException.php | 2 +- src/Curl/HttpClient.php | 102 ++++++++++++++++++ src/{Guzzle => Curl}/RequestFactory.php | 2 +- src/{Guzzle => Curl}/SmsapiHttpClient.php | 4 +- src/{Guzzle => Curl}/StreamFactory.php | 2 +- src/Guzzle/GuzzleDiscovery.php | 17 --- src/Guzzle/HttpClient.php | 40 ------- tests/SmsapiClientIntegrationTestCase.php | 2 +- tests/SmsapiClientUnitTestCase.php | 4 +- 15 files changed, 143 insertions(+), 78 deletions(-) create mode 100644 src/Curl/CurlDiscovery.php rename src/{Guzzle => Curl}/Exception/ClientException.php (65%) rename src/{Guzzle => Curl}/Exception/NetworkException.php (81%) rename src/{Guzzle => Curl}/Exception/RequestException.php (81%) create mode 100644 src/Curl/HttpClient.php rename src/{Guzzle => Curl}/RequestFactory.php (91%) rename src/{Guzzle => Curl}/SmsapiHttpClient.php (95%) rename src/{Guzzle => Curl}/StreamFactory.php (95%) delete mode 100644 src/Guzzle/GuzzleDiscovery.php delete mode 100644 src/Guzzle/HttpClient.php diff --git a/Makefile b/Makefile index b8c1708..1704bc8 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,6 @@ help: prepare: ## load dependencies docker-compose run -T php /usr/bin/composer update - docker-compose run -T php /usr/bin/composer require --dev guzzlehttp/guzzle test: prepare ## run test docker-compose run -T php php vendor/bin/phing -f build.xml test diff --git a/README.md b/README.md index d17447e..9f10e9e 100644 --- a/README.md +++ b/README.md @@ -25,26 +25,26 @@ Depending on which of SMSAPI service your account is, you should pick it calling ### PSR-17 and PSR-18 -Starting form version 3, SMSAPI PHP Client supports PSR-17 and PSR-18 compliant HTTP clients. +Starting from version 3, SMSAPI PHP Client supports PSR-17 and PSR-18 compliant HTTP clients. That way this library is independent of client of your choice. You have to provide HTTP client, request factory and stream factory to use our library. -For your convenience we provide an adapter for Guzzle. All yout have to do is to require *guzzlehttp/guzzle* dependency in your project. -Example below shows how to make use of that adapter (pay attention to namespace *Smsapi\Client\Guzzle*): +For your convenience we provide an adapter for Curl. +Example below shows how to make use of that adapter (pay attention to namespace *Smsapi\Client\Curl*): ```php getMessage(), 0, $previous); + $exception = new self($message); $exception->request = $request; + return $exception; } diff --git a/src/Guzzle/Exception/NetworkException.php b/src/Curl/Exception/NetworkException.php similarity index 81% rename from src/Guzzle/Exception/NetworkException.php rename to src/Curl/Exception/NetworkException.php index ba17a22..a4b7421 100644 --- a/src/Guzzle/Exception/NetworkException.php +++ b/src/Curl/Exception/NetworkException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Guzzle\Exception; +namespace Smsapi\Client\Curl\Exception; use Psr\Http\Client\NetworkExceptionInterface; diff --git a/src/Guzzle/Exception/RequestException.php b/src/Curl/Exception/RequestException.php similarity index 81% rename from src/Guzzle/Exception/RequestException.php rename to src/Curl/Exception/RequestException.php index d400dc1..2ea1aa5 100644 --- a/src/Guzzle/Exception/RequestException.php +++ b/src/Curl/Exception/RequestException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Guzzle\Exception; +namespace Smsapi\Client\Curl\Exception; use Psr\Http\Client\RequestExceptionInterface; diff --git a/src/Curl/HttpClient.php b/src/Curl/HttpClient.php new file mode 100644 index 0000000..3a1fb53 --- /dev/null +++ b/src/Curl/HttpClient.php @@ -0,0 +1,102 @@ +prepareRequestHttpClient($request); + + $this->prepareRequestMethod($request, $httpClient); + $this->prepareRequestBody($request, $httpClient); + $this->prepareRequestHeaders($request, $httpClient); + $this->prepareResponseOptions($httpClient); + + $response = $this->execute($request, $httpClient); + + $this->closeHttpClient($httpClient); + + return $response; + } + + private function prepareRequestHttpClient(RequestInterface $request) + { + $url = sprintf("%s://%s%s", $request->getUri()->getScheme(), $request->getUri()->getHost(), $request->getRequestTarget()); + $httpClient = curl_init($url); + + if ($httpClient === false) { + throw NetworkException::withRequest( + 'Cannot prepare HTTP client: ' . curl_error($httpClient), + $request + ); + } + + return $httpClient; + } + + private function prepareRequestMethod(RequestInterface $request, $httpClient) + { + curl_setopt($httpClient, CURLOPT_CUSTOMREQUEST, $request->getMethod()); + } + + private function prepareRequestBody(RequestInterface $request, $httpClient) + { + curl_setopt($httpClient, CURLOPT_POSTFIELDS, (string)$request->getBody()); + } + + private function prepareRequestHeaders(RequestInterface $request, $httpClient) + { + $headers = ''; + foreach ($request->getHeaders() as $name => $values) { + $headers[] = $name . ': ' . implode(', ', $values); + } + + curl_setopt($httpClient, CURLOPT_HTTPHEADER, $headers); + } + + private function prepareResponseOptions($httpClient) + { + curl_setopt($httpClient, CURLOPT_HEADER, true); + curl_setopt($httpClient, CURLOPT_RETURNTRANSFER, true); + } + + private function execute(RequestInterface $request, $httpClient): ResponseInterface + { + $response = curl_exec($httpClient); + + if ($response === false) { + throw RequestException::withRequest( + 'Cannot send request: ' . curl_error($httpClient), + $request + ); + } + + $responseStatus = curl_getinfo($httpClient, CURLINFO_HTTP_CODE); + + $headerSize = curl_getinfo($httpClient, CURLINFO_HEADER_SIZE); + $headerString = substr($response, 0, $headerSize); + $headers = array_filter(explode("\n", $headerString), 'trim'); + + $body = substr($response, $headerSize); + + return new Response($responseStatus, $headers, $body); + } + + private function closeHttpClient($httpClient) + { + curl_close($httpClient); + } +} \ No newline at end of file diff --git a/src/Guzzle/RequestFactory.php b/src/Curl/RequestFactory.php similarity index 91% rename from src/Guzzle/RequestFactory.php rename to src/Curl/RequestFactory.php index a48c9a2..a9e353c 100644 --- a/src/Guzzle/RequestFactory.php +++ b/src/Curl/RequestFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Guzzle; +namespace Smsapi\Client\Curl; use GuzzleHttp\Psr7\Request; use Psr\Http\Message\RequestFactoryInterface; diff --git a/src/Guzzle/SmsapiHttpClient.php b/src/Curl/SmsapiHttpClient.php similarity index 95% rename from src/Guzzle/SmsapiHttpClient.php rename to src/Curl/SmsapiHttpClient.php index 177c69b..f7a1d94 100644 --- a/src/Guzzle/SmsapiHttpClient.php +++ b/src/Curl/SmsapiHttpClient.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Guzzle; +namespace Smsapi\Client\Curl; use Psr\Log\LoggerInterface; use Smsapi\Client\Service\SmsapiComService; @@ -18,7 +18,7 @@ class SmsapiHttpClient implements SmsapiClient public function __construct() { - GuzzleDiscovery::run(); + CurlDiscovery::run(); $this->httpClient = new \Smsapi\Client\SmsapiHttpClient( new HttpClient(), diff --git a/src/Guzzle/StreamFactory.php b/src/Curl/StreamFactory.php similarity index 95% rename from src/Guzzle/StreamFactory.php rename to src/Curl/StreamFactory.php index 23cbab3..42b1987 100644 --- a/src/Guzzle/StreamFactory.php +++ b/src/Curl/StreamFactory.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Guzzle; +namespace Smsapi\Client\Curl; use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\StreamFactoryInterface; diff --git a/src/Guzzle/GuzzleDiscovery.php b/src/Guzzle/GuzzleDiscovery.php deleted file mode 100644 index 764179a..0000000 --- a/src/Guzzle/GuzzleDiscovery.php +++ /dev/null @@ -1,17 +0,0 @@ - false, - ]); - - try { - return $guzzleClient->send($request); - } catch (GuzzleRequestException $e) { - throw RequestException::create($request, $e); - } catch (GuzzleTransferException $e) { - throw NetworkException::create($request, $e); - } catch (GuzzleException $e) { - throw ClientException::create($request, $e); - } - } -} \ No newline at end of file diff --git a/tests/SmsapiClientIntegrationTestCase.php b/tests/SmsapiClientIntegrationTestCase.php index 3b069f8..3571770 100644 --- a/tests/SmsapiClientIntegrationTestCase.php +++ b/tests/SmsapiClientIntegrationTestCase.php @@ -4,7 +4,7 @@ namespace Smsapi\Client\Tests; use RuntimeException; -use Smsapi\Client\Guzzle\SmsapiHttpClient; +use Smsapi\Client\Curl\SmsapiHttpClient; use Smsapi\Client\Service\SmsapiComService; use Smsapi\Client\Service\SmsapiPlService; diff --git a/tests/SmsapiClientUnitTestCase.php b/tests/SmsapiClientUnitTestCase.php index 25359f2..eb84c6e 100644 --- a/tests/SmsapiClientUnitTestCase.php +++ b/tests/SmsapiClientUnitTestCase.php @@ -4,8 +4,8 @@ namespace Smsapi\Client\Tests; use Smsapi\Client\Feature\Data\DataFactoryProvider; -use Smsapi\Client\Guzzle\RequestFactory; -use Smsapi\Client\Guzzle\StreamFactory; +use Smsapi\Client\Curl\RequestFactory; +use Smsapi\Client\Curl\StreamFactory; use Smsapi\Client\Infrastructure\RequestExecutor\LegacyRequestExecutor; use Smsapi\Client\Infrastructure\RequestExecutor\RequestExecutorFactory; use Smsapi\Client\Infrastructure\RequestExecutor\RestRequestExecutor; From b5f2a2bc21ed0797dd9d1da6b977c72f53791658 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Thu, 5 Nov 2020 11:19:56 +0100 Subject: [PATCH 05/93] Replaces optional Guzzle adapter with Curl adapter --- tests/Helper/HttpClient/HttpClientMock.php | 39 ++++------------------ 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/tests/Helper/HttpClient/HttpClientMock.php b/tests/Helper/HttpClient/HttpClientMock.php index c32b34f..68bba5f 100644 --- a/tests/Helper/HttpClient/HttpClientMock.php +++ b/tests/Helper/HttpClient/HttpClientMock.php @@ -4,51 +4,24 @@ namespace Smsapi\Client\Tests\Helper\HttpClient; -use GuzzleHttp\Client; -use GuzzleHttp\Exception\GuzzleException; -use GuzzleHttp\Exception\RequestException as GuzzleRequestException; -use GuzzleHttp\Exception\TransferException as GuzzleTransferException; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7\Response; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use Smsapi\Client\Guzzle\Exception\ClientException; -use Smsapi\Client\Guzzle\Exception\NetworkException; -use Smsapi\Client\Guzzle\Exception\RequestException; -use Smsapi\Client\Guzzle\GuzzleDiscovery; class HttpClientMock implements ClientInterface { - private $mockHandler; - - public function __construct() - { - GuzzleDiscovery::run(); - - $this->mockHandler = new MockHandler(); - } + private $responseStatusCode; + private $responseBody; public function sendRequest(RequestInterface $request): ResponseInterface { - $guzzleClient = new Client([ - 'handler' => HandlerStack::create($this->mockHandler) - ]); - - try { - return $guzzleClient->send($request); - } catch (GuzzleRequestException $e) { - throw RequestException::create($request, $e); - } catch (GuzzleTransferException $e) { - throw NetworkException::create($request, $e); - } catch (GuzzleException $e) { - throw ClientException::create($request, $e); - } + return new Response($this->responseStatusCode, [], $this->responseBody); } - public function mockResponse(int $statusCode, string $body) + public function mockResponse(int $responseStatusCode, string $responseBody) { - $this->mockHandler->append(new Response($statusCode, [], $body)); + $this->responseStatusCode = $responseStatusCode; + $this->responseBody = $responseBody; } } \ No newline at end of file From a56424fad00b4a147723600823560bdc90592ce7 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 6 Nov 2020 11:39:18 +0100 Subject: [PATCH 06/93] Replaces optional Guzzle adapter with Curl adapter --- src/Curl/HttpClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Curl/HttpClient.php b/src/Curl/HttpClient.php index 3a1fb53..d068cf5 100644 --- a/src/Curl/HttpClient.php +++ b/src/Curl/HttpClient.php @@ -59,7 +59,7 @@ private function prepareRequestBody(RequestInterface $request, $httpClient) private function prepareRequestHeaders(RequestInterface $request, $httpClient) { - $headers = ''; + $headers = []; foreach ($request->getHeaders() as $name => $values) { $headers[] = $name . ': ' . implode(', ', $values); } From 1f3ade0fd8f661f5a5cb848b17fc31ae1e6fcafd Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 6 Nov 2020 11:52:42 +0100 Subject: [PATCH 07/93] Fixes notice when base uri path not exists --- .../HttpClient/Decorator/BaseUriDecorator.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php index 8ae2d3c..4747292 100644 --- a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php @@ -35,9 +35,13 @@ private function prependBaseUri(RequestInterface $request): RequestInterface $baseUriParts = parse_url($this->baseUri); - $uri = $uri->withScheme($baseUriParts['scheme'] ?? ''); - $uri = $uri->withHost($baseUriParts['host'] ?? ''); - $uri = $uri->withPath($baseUriParts['path'] . $uri->getPath()); + $scheme = $baseUriParts['scheme'] ?? ''; + $host = $baseUriParts['host'] ?? ''; + $path = $baseUriParts['path'] ?? ''; + + $uri = $uri->withScheme($scheme); + $uri = $uri->withHost($host); + $uri = $uri->withPath($path . $uri->getPath()); return $request->withUri($uri); } From e04169602ba0100c9f0cbe1d494fe247d27145bf Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Nov 2020 15:06:41 +0100 Subject: [PATCH 08/93] Fixes contacts fields test namespace --- .../Feature/Contacts/Fields/ContactsFieldsFeatureTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/Feature/Contacts/Fields/ContactsFieldsFeatureTest.php b/tests/Integration/Feature/Contacts/Fields/ContactsFieldsFeatureTest.php index 09aae76..b365387 100644 --- a/tests/Integration/Feature/Contacts/Fields/ContactsFieldsFeatureTest.php +++ b/tests/Integration/Feature/Contacts/Fields/ContactsFieldsFeatureTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Smsapi\Client\Tests\Integration\Contacts; +namespace Smsapi\Client\Tests\Integration\Feature\Contacts\Fields; use Smsapi\Client\Feature\Contacts\Bag\CreateContactBag; use Smsapi\Client\Feature\Contacts\Bag\DeleteContactBag; From 27cd81e81733907b80df136d9cea8c068783c7fa Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Nov 2020 15:13:46 +0100 Subject: [PATCH 09/93] Simplifies FQNs --- src/Curl/CurlDiscovery.php | 4 +++- src/Curl/Exception/ClientException.php | 3 ++- src/Curl/StreamFactory.php | 5 +++-- src/Feature/Data/PointsFactory.php | 4 +++- src/SmsapiClientException.php | 4 +++- .../Feature/Contacts/Data/ContactFactoryTest.php | 12 +++++++----- .../BuiltInParametersQueryFormatterTest.php | 3 ++- .../ComplexParametersQueryFormatterTest.php | 3 ++- .../Formatter/UserParametersQueryFormatterTest.php | 3 ++- .../ResponseMapper/LegacyResponseMapperTest.php | 5 +++-- .../ResponseMapper/RestResponseMapperTest.php | 5 +++-- 11 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/Curl/CurlDiscovery.php b/src/Curl/CurlDiscovery.php index de2cf03..c5e49ed 100644 --- a/src/Curl/CurlDiscovery.php +++ b/src/Curl/CurlDiscovery.php @@ -4,6 +4,8 @@ namespace Smsapi\Client\Curl; +use RuntimeException; + /** * @internal */ @@ -12,7 +14,7 @@ class CurlDiscovery public static function run() { if (!function_exists('curl_init')) { - throw new \RuntimeException( + throw new RuntimeException( 'CURL not found' ); } diff --git a/src/Curl/Exception/ClientException.php b/src/Curl/Exception/ClientException.php index a81009a..4da31c7 100644 --- a/src/Curl/Exception/ClientException.php +++ b/src/Curl/Exception/ClientException.php @@ -4,13 +4,14 @@ namespace Smsapi\Client\Curl\Exception; +use Exception; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\RequestInterface; /** * @api */ -class ClientException extends \Exception implements ClientExceptionInterface +class ClientException extends Exception implements ClientExceptionInterface { private $request; diff --git a/src/Curl/StreamFactory.php b/src/Curl/StreamFactory.php index 42b1987..db5e2a3 100644 --- a/src/Curl/StreamFactory.php +++ b/src/Curl/StreamFactory.php @@ -7,6 +7,7 @@ use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; +use RuntimeException; /** * @internal @@ -20,11 +21,11 @@ public function createStream(string $content = ''): StreamInterface public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface { - throw new \RuntimeException('not implemented'); + throw new RuntimeException('not implemented'); } public function createStreamFromResource($resource): StreamInterface { - throw new \RuntimeException('not implemented'); + throw new RuntimeException('not implemented'); } } \ No newline at end of file diff --git a/src/Feature/Data/PointsFactory.php b/src/Feature/Data/PointsFactory.php index bb18c4f..9ead0d9 100644 --- a/src/Feature/Data/PointsFactory.php +++ b/src/Feature/Data/PointsFactory.php @@ -4,12 +4,14 @@ namespace Smsapi\Client\Feature\Data; +use stdClass; + /** * @internal */ class PointsFactory { - public function createFromObject(\stdClass $object): Points + public function createFromObject(stdClass $object): Points { $points = new Points(); $points->fromAccount = $object->from_account; diff --git a/src/SmsapiClientException.php b/src/SmsapiClientException.php index 07bd9b1..3581dea 100644 --- a/src/SmsapiClientException.php +++ b/src/SmsapiClientException.php @@ -3,9 +3,11 @@ namespace Smsapi\Client; +use Exception; + /** * @api */ -class SmsapiClientException extends \Exception +class SmsapiClientException extends Exception { } diff --git a/tests/Unit/Feature/Contacts/Data/ContactFactoryTest.php b/tests/Unit/Feature/Contacts/Data/ContactFactoryTest.php index bc690c5..e1166cf 100644 --- a/tests/Unit/Feature/Contacts/Data/ContactFactoryTest.php +++ b/tests/Unit/Feature/Contacts/Data/ContactFactoryTest.php @@ -4,11 +4,13 @@ namespace Smsapi\Client\Tests\Unit\Feature\Contacts\Data; +use DateTime; use PHPUnit\Framework\TestCase; use Smsapi\Client\Feature\Contacts\Data\ContactCustomFieldFactory; use Smsapi\Client\Feature\Contacts\Data\ContactFactory; use Smsapi\Client\Feature\Contacts\Data\ContactGroupFactory; use Smsapi\Client\Feature\Contacts\Groups\Permissions\Data\GroupPermissionFactory; +use stdClass; class ContactFactoryTest extends TestCase { @@ -27,7 +29,7 @@ protected function setUp() */ public function it_should_convert_mandatory_built_in_contact_fields() { - $contactData = new \stdClass(); + $contactData = new stdClass(); $contactData->id = 'any'; $contactData->date_created = '2020-05-11'; $contactData->date_updated = '2020-05-12'; @@ -39,8 +41,8 @@ public function it_should_convert_mandatory_built_in_contact_fields() $contact = $this->contactFactory->createFromObject($contactData); $this->assertEquals('any', $contact->id); - $this->assertEquals(new \DateTime('2020-05-11'), $contact->dateCreated); - $this->assertEquals(new \DateTime('2020-05-12'), $contact->dateUpdated); + $this->assertEquals(new DateTime('2020-05-11'), $contact->dateCreated); + $this->assertEquals(new DateTime('2020-05-12'), $contact->dateUpdated); $this->assertEquals('M', $contact->gender); } @@ -91,9 +93,9 @@ public function it_should_convert_custom_fields() $this->assertEquals('any2', $contact->customFields[1]->value); } - private function givenAnyContactData(): \stdClass + private function givenAnyContactData(): stdClass { - $contactData = new \stdClass(); + $contactData = new stdClass(); $contactData->id = 'any'; $contactData->date_created = '2020-05-11'; $contactData->date_updated = '2020-05-12'; diff --git a/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/BuiltInParametersQueryFormatterTest.php b/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/BuiltInParametersQueryFormatterTest.php index 95c0d43..9acd9d0 100644 --- a/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/BuiltInParametersQueryFormatterTest.php +++ b/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/BuiltInParametersQueryFormatterTest.php @@ -4,6 +4,7 @@ namespace Smsapi\Client\Tests\Unit\Infrastructure\RequestMapper\Query\Formatter; +use DateTime; use PHPUnit\Framework\TestCase; use Smsapi\Client\Infrastructure\RequestMapper\Query\Formatter\BuiltInParametersQueryFormatter; use Smsapi\Client\Infrastructure\RequestMapper\Query\QueryParametersData; @@ -72,7 +73,7 @@ public function it_should_change_camel_case_parameter_name_to_underscore() */ public function it_should_format_datetime_values() { - $date = new \DateTime(); + $date = new DateTime(); $dateEncoded = rawurlencode($date->format('c')); $builtInParameters = [ diff --git a/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/ComplexParametersQueryFormatterTest.php b/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/ComplexParametersQueryFormatterTest.php index 27d7dea..44973ce 100644 --- a/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/ComplexParametersQueryFormatterTest.php +++ b/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/ComplexParametersQueryFormatterTest.php @@ -4,6 +4,7 @@ namespace Smsapi\Client\Tests\Unit\Infrastructure\RequestMapper\Query\Formatter; +use DateTime; use PHPUnit\Framework\TestCase; use Smsapi\Client\Infrastructure\RequestMapper\Query\Formatter\ComplexParametersQueryFormatter; use Smsapi\Client\Infrastructure\RequestMapper\Query\QueryParametersData; @@ -153,7 +154,7 @@ public function it_should_not_change_camel_case_parameter_name_to_underscore() */ public function it_should_format_datetime_values() { - $date = new \DateTime(); + $date = new DateTime(); $dateEncoded = rawurlencode($date->format('c')); $builtInParameters = [ diff --git a/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/UserParametersQueryFormatterTest.php b/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/UserParametersQueryFormatterTest.php index f54bc88..91760f9 100644 --- a/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/UserParametersQueryFormatterTest.php +++ b/tests/Unit/Infrastructure/RequestMapper/Query/Formatter/UserParametersQueryFormatterTest.php @@ -4,6 +4,7 @@ namespace Smsapi\Client\Tests\Unit\Infrastructure\RequestMapper\Query\Formatter; +use DateTime; use PHPUnit\Framework\TestCase; use Smsapi\Client\Infrastructure\RequestMapper\Query\Formatter\UserParametersQueryFormatter; use Smsapi\Client\Infrastructure\RequestMapper\Query\QueryParametersData; @@ -73,7 +74,7 @@ public function it_should_not_change_camel_case_parameter_name_to_underscore() */ public function it_should_format_datetime_values() { - $date = new \DateTime(); + $date = new DateTime(); $dateEncoded = rawurlencode($date->format('c')); $userParameters = [ diff --git a/tests/Unit/Infrastructure/ResponseMapper/LegacyResponseMapperTest.php b/tests/Unit/Infrastructure/ResponseMapper/LegacyResponseMapperTest.php index 2eecaed..d29b739 100644 --- a/tests/Unit/Infrastructure/ResponseMapper/LegacyResponseMapperTest.php +++ b/tests/Unit/Infrastructure/ResponseMapper/LegacyResponseMapperTest.php @@ -6,6 +6,7 @@ use GuzzleHttp\Psr7\Response; use Smsapi\Client\Infrastructure\ResponseHttpCode; +use Smsapi\Client\Infrastructure\ResponseMapper\ApiErrorException; use Smsapi\Client\Infrastructure\ResponseMapper\JsonDecode; use Smsapi\Client\Infrastructure\ResponseMapper\LegacyResponseMapper; use Smsapi\Client\Tests\SmsapiClientUnitTestCase; @@ -40,7 +41,7 @@ public function it_should_return_decoded_body_on_ok() /** * @test - * @expectedException \Smsapi\Client\Infrastructure\ResponseMapper\ApiErrorException + * @expectedException ApiErrorException */ public function it_should_return_error_on_ok_with_message_and_error() { @@ -52,7 +53,7 @@ public function it_should_return_error_on_ok_with_message_and_error() /** * @test - * @expectedException \Smsapi\Client\Infrastructure\ResponseMapper\ApiErrorException + * @expectedException ApiErrorException */ public function it_should_throw_exception_on_unrecognized_status() { diff --git a/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php b/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php index db60d89..4c22082 100644 --- a/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php +++ b/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php @@ -6,6 +6,7 @@ use GuzzleHttp\Psr7\Response; use Smsapi\Client\Infrastructure\ResponseHttpCode; +use Smsapi\Client\Infrastructure\ResponseMapper\ApiErrorException; use Smsapi\Client\Infrastructure\ResponseMapper\JsonDecode; use Smsapi\Client\Infrastructure\ResponseMapper\RestResponseMapper; use Smsapi\Client\Tests\SmsapiClientUnitTestCase; @@ -81,7 +82,7 @@ public function it_should_return_empty_object_on_no_content() /** * @test - * @expectedException \Smsapi\Client\Infrastructure\ResponseMapper\ApiErrorException + * @expectedException ApiErrorException * @expectedExceptionMessage Service unavailable */ public function it_should_throw_exception_on_service_unavailable() @@ -93,7 +94,7 @@ public function it_should_throw_exception_on_service_unavailable() /** * @test - * @expectedException \Smsapi\Client\Infrastructure\ResponseMapper\ApiErrorException + * @expectedException ApiErrorException */ public function it_should_throw_exception_on_unrecognized_status() { From 51ee5dc8f05de8291353c244739cff9d1574efaf Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Nov 2020 15:15:49 +0100 Subject: [PATCH 10/93] Adds mbstring to dev required extensions --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 3c0ee1a..1a3a6c6 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "guzzlehttp/psr7": "^1" }, "require-dev": { + "ext-mbstring": "*", "phpunit/phpunit": "^6", "symfony/yaml": "^3", "marc-mabe/php-enum": "^3", From 34f49e13fd28be8addca227b98bf4601de166013 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Nov 2020 15:23:17 +0100 Subject: [PATCH 11/93] Replaces deprecated PHPUnit features --- .../ResponseMapper/LegacyResponseMapperTest.php | 4 ++-- .../ResponseMapper/RestResponseMapperTest.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Unit/Infrastructure/ResponseMapper/LegacyResponseMapperTest.php b/tests/Unit/Infrastructure/ResponseMapper/LegacyResponseMapperTest.php index d29b739..809e1ab 100644 --- a/tests/Unit/Infrastructure/ResponseMapper/LegacyResponseMapperTest.php +++ b/tests/Unit/Infrastructure/ResponseMapper/LegacyResponseMapperTest.php @@ -41,24 +41,24 @@ public function it_should_return_decoded_body_on_ok() /** * @test - * @expectedException ApiErrorException */ public function it_should_return_error_on_ok_with_message_and_error() { $bodyWithMessageAndError = '{"message":"some message","error":1}'; $responseWithOkMessageAndError = $this->createResponse(ResponseHttpCode::OK, $bodyWithMessageAndError); + $this->expectException(ApiErrorException::class); $this->legacyResponseMapper->map($responseWithOkMessageAndError); } /** * @test - * @expectedException ApiErrorException */ public function it_should_throw_exception_on_unrecognized_status() { $responseWithUnrecognizedStatus = new Response(400); + $this->expectException(ApiErrorException::class); $this->legacyResponseMapper->map($responseWithUnrecognizedStatus); } diff --git a/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php b/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php index 4c22082..dfbb087 100644 --- a/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php +++ b/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php @@ -82,24 +82,24 @@ public function it_should_return_empty_object_on_no_content() /** * @test - * @expectedException ApiErrorException - * @expectedExceptionMessage Service unavailable */ public function it_should_throw_exception_on_service_unavailable() { $responseWithServiceUnavailable = new Response(ResponseHttpCode::SERVICE_UNAVAILABLE); + $this->expectException(ApiErrorException::class); + $this->expectExceptionMessage("Service unavailable"); $this->restResponseMapper->map($responseWithServiceUnavailable); } /** * @test - * @expectedException ApiErrorException */ public function it_should_throw_exception_on_unrecognized_status() { $responseWithUnrecognizedStatus = new Response(400); + $this->expectException(ApiErrorException::class); $this->restResponseMapper->map($responseWithUnrecognizedStatus); } From 312cffb3ef2e4e339a31762f7821bb3e85f9e889 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Nov 2020 15:34:09 +0100 Subject: [PATCH 12/93] Removes unused imports --- src/Feature/Contacts/Groups/ContactsGroupsHttpFeature.php | 1 - src/Feature/Sms/SmsFeature.php | 1 - src/Feature/Sms/SmsHttpFeature.php | 2 -- src/Service/SmsapiComHttpService.php | 2 -- tests/Integration/Feature/Ping/PingFeatureTest.php | 1 - 5 files changed, 7 deletions(-) diff --git a/src/Feature/Contacts/Groups/ContactsGroupsHttpFeature.php b/src/Feature/Contacts/Groups/ContactsGroupsHttpFeature.php index 43799b8..da0066f 100644 --- a/src/Feature/Contacts/Groups/ContactsGroupsHttpFeature.php +++ b/src/Feature/Contacts/Groups/ContactsGroupsHttpFeature.php @@ -4,7 +4,6 @@ namespace Smsapi\Client\Feature\Contacts\Groups; -use Smsapi\Client\Feature\Contacts\Groups\Bag\FindGroupsBag; use Smsapi\Client\Feature\Data\DataFactoryProvider; use Smsapi\Client\Infrastructure\RequestExecutor\RestRequestExecutor; use Smsapi\Client\Feature\Contacts\Data\ContactGroup; diff --git a/src/Feature/Sms/SmsFeature.php b/src/Feature/Sms/SmsFeature.php index 8ccddf7..9f3c9fe 100644 --- a/src/Feature/Sms/SmsFeature.php +++ b/src/Feature/Sms/SmsFeature.php @@ -11,7 +11,6 @@ use Smsapi\Client\Feature\Sms\Bag\SendSmssBag; use Smsapi\Client\Feature\Sms\Bag\SendSmsToGroupBag; use Smsapi\Client\Feature\Sms\Data\Sms; -use Smsapi\Client\Feature\Mfa\MfaFeature; use Smsapi\Client\Feature\Sms\Sendernames\SendernamesFeature; /** diff --git a/src/Feature/Sms/SmsHttpFeature.php b/src/Feature/Sms/SmsHttpFeature.php index 185e53f..10dea8b 100644 --- a/src/Feature/Sms/SmsHttpFeature.php +++ b/src/Feature/Sms/SmsHttpFeature.php @@ -13,8 +13,6 @@ use Smsapi\Client\Feature\Sms\Bag\SendSmssBag; use Smsapi\Client\Feature\Sms\Bag\SendSmsToGroupBag; use Smsapi\Client\Feature\Sms\Data\Sms; -use Smsapi\Client\Feature\Mfa\MfaFeature; -use Smsapi\Client\Feature\Mfa\MfaHttpFeature; use Smsapi\Client\Feature\Sms\Sendernames\SendernamesFeature; use Smsapi\Client\Feature\Sms\Sendernames\SendernamesHttpFeature; use Smsapi\Client\Infrastructure\RequestExecutor\RequestExecutorFactory; diff --git a/src/Service/SmsapiComHttpService.php b/src/Service/SmsapiComHttpService.php index 218ac7a..39d5816 100644 --- a/src/Service/SmsapiComHttpService.php +++ b/src/Service/SmsapiComHttpService.php @@ -8,8 +8,6 @@ use Smsapi\Client\Feature\Data\DataFactoryProvider; use Smsapi\Client\Feature\Profile\ProfileFeature; use Smsapi\Client\Feature\Profile\ProfileHttpFeature; -use Smsapi\Client\Feature\Profile\SmsapiPlProfileFeature; -use Smsapi\Client\Feature\Profile\SmsapiPlProfileHttpFeature; use Smsapi\Client\Infrastructure\RequestExecutor\RequestExecutorFactory; /** diff --git a/tests/Integration/Feature/Ping/PingFeatureTest.php b/tests/Integration/Feature/Ping/PingFeatureTest.php index 548ac3f..11b8df1 100644 --- a/tests/Integration/Feature/Ping/PingFeatureTest.php +++ b/tests/Integration/Feature/Ping/PingFeatureTest.php @@ -3,7 +3,6 @@ namespace Smsapi\Client\Tests\Integration\Feature\Ping; -use Smsapi\Client\Feature\Ping\Data\Ping; use Smsapi\Client\Tests\SmsapiClientIntegrationTestCase; class PingFeatureTest extends SmsapiClientIntegrationTestCase From 114e6925e89b2f36c3dfda24adeabcff80a86954 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Nov 2020 15:38:44 +0100 Subject: [PATCH 13/93] Refactors version test regexp --- tests/Unit/SmsapiHttpClientTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/SmsapiHttpClientTest.php b/tests/Unit/SmsapiHttpClientTest.php index 6e08d17..b16d1be 100644 --- a/tests/Unit/SmsapiHttpClientTest.php +++ b/tests/Unit/SmsapiHttpClientTest.php @@ -24,7 +24,7 @@ private function grabVersionFromChangelog() { $changelog = file_get_contents(dirname(dirname(__DIR__)) . '/CHANGELOG.md'); - preg_match('/^## \[(?Unreleased|\d+.\d+.\d+)\]/m', $changelog, $matches); + preg_match('/^## \[(?Unreleased|\d+.\d+.\d+)]/m', $changelog, $matches); $this->assertArrayHasKey('version', $matches); From b43f3fac0ba99df192f75899bd508900b0a4187f Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Thu, 19 Nov 2020 09:58:31 +0100 Subject: [PATCH 14/93] Releases version 3.0.0 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11c56f9..b883462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.0] - 2020-11-19 ### Added - PSR-18 support - PSR-17 support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..d0d5a25 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.0'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 940bb9a7a92c2ed27939b6abf54f1bfbbcd1f8c6 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Wed, 25 Nov 2020 16:32:45 +0100 Subject: [PATCH 15/93] Make guzzzle psr7 optional dependency --- composer.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 1a3a6c6..85bd496 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,7 @@ "psr/log": "^1", "psr/http-message": "^1", "psr/http-client": "^1", - "psr/http-factory": "^1", - "guzzlehttp/psr7": "^1" + "psr/http-factory": "^1" }, "require-dev": { "ext-mbstring": "*", @@ -32,9 +31,12 @@ "phing/phing": "^2.5", "doctrine/instantiator": "1.0.5", "phpdocumentor/reflection-docblock": "^4.3", - "phpdocumentor/type-resolver": "^0.5" + "phpdocumentor/type-resolver": "^0.5", + "guzzlehttp/psr7": "^1", + "ext-curl": "*" }, "suggest": { - "ext-curl": "*" + "ext-curl": "To use Curl HttpClient", + "guzzlehttp/psr7": "To use Curl HttpClient and HTTP message factories" } } From 5ebb8cd11d347b389111e356fb276456deb2755e Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 4 Dec 2020 23:12:08 +0100 Subject: [PATCH 16/93] Adds more info how to use optional dependencies --- README.md | 7 +++++- src/Curl/{ => Discovery}/CurlDiscovery.php | 3 ++- .../Discovery/GuzzleHttpHelpersDiscovery.php | 23 +++++++++++++++++++ src/Curl/SmsapiHttpClient.php | 3 +++ 4 files changed, 34 insertions(+), 2 deletions(-) rename src/Curl/{ => Discovery}/CurlDiscovery.php (78%) create mode 100644 src/Curl/Discovery/GuzzleHttpHelpersDiscovery.php diff --git a/README.md b/README.md index ce0b596..4868c29 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,12 @@ Starting from version 3, SMSAPI PHP Client supports PSR-17 and PSR-18 compliant That way this library is independent of client of your choice. You have to provide HTTP client, request factory and stream factory to use our library. -For your convenience we provide an adapter for Curl. +For your convenience we provide an adapter for Curl. To use it you have to enable PHP curl extension and install some HTTP helpers: + +``` +composer require guzzlehttp/psr7:^1 +``` + Example below shows how to make use of that adapter (pay attention to namespace *Smsapi\Client\Curl*): ```php diff --git a/src/Curl/CurlDiscovery.php b/src/Curl/Discovery/CurlDiscovery.php similarity index 78% rename from src/Curl/CurlDiscovery.php rename to src/Curl/Discovery/CurlDiscovery.php index c5e49ed..065b9d4 100644 --- a/src/Curl/CurlDiscovery.php +++ b/src/Curl/Discovery/CurlDiscovery.php @@ -2,12 +2,13 @@ declare(strict_types=1); -namespace Smsapi\Client\Curl; +namespace Smsapi\Client\Curl\Discovery; use RuntimeException; /** * @internal + * @todo switch to composer-runtime-api */ class CurlDiscovery { diff --git a/src/Curl/Discovery/GuzzleHttpHelpersDiscovery.php b/src/Curl/Discovery/GuzzleHttpHelpersDiscovery.php new file mode 100644 index 0000000..b620c92 --- /dev/null +++ b/src/Curl/Discovery/GuzzleHttpHelpersDiscovery.php @@ -0,0 +1,23 @@ +httpClient = new \Smsapi\Client\SmsapiHttpClient( new HttpClient(), From bc508af722cc71a79bd59c606edeca7a73cc0073 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 8 Dec 2020 12:56:41 +0100 Subject: [PATCH 17/93] Releases version 3.0.1 --- CHANGELOG.md | 4 ++++ src/SmsapiClient.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b883462..3033e97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.0.1] - 2020-12-08 +### Changed +- Guzzle HTTP helpers marked as optional dependency + ## [3.0.0] - 2020-11-19 ### Added - PSR-18 support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index d0d5a25..c44b19b 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.0'; + const VERSION = '3.0.1'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 7083d77f2d9fa08b8c904cd48bc38ae09ceeafbb Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 27 Jan 2021 11:43:57 +0100 Subject: [PATCH 18/93] Removes phing from dev dependencies. Simplifies build process. --- Makefile | 4 ++-- README.md | 2 +- build.xml | 20 -------------------- composer.json | 1 - 4 files changed, 3 insertions(+), 24 deletions(-) delete mode 100644 build.xml diff --git a/Makefile b/Makefile index 1704bc8..199e534 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ prepare: ## load dependencies docker-compose run -T php /usr/bin/composer update test: prepare ## run test - docker-compose run -T php php vendor/bin/phing -f build.xml test + docker-compose run -T php php vendor/bin/phpunit --configuration phpunit.xml test-suite: prepare ## run test against suite, ex: make test-suite SUITE="unit" - docker-compose run -T php php vendor/bin/phing -f build.xml test -Dsuite=$(SUITE) \ No newline at end of file + docker-compose run -T php php vendor/bin/phpunit --configuration phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/README.md b/README.md index 4868c29..f79f55d 100644 --- a/README.md +++ b/README.md @@ -270,7 +270,7 @@ $client->setLogger($logger); ## Test package 1. Download package: `composer create-project smsapi/php-client` -2. Execute tests: `./vendor/bin/phing` +2. Execute tests: `make test` ## Docs & Infos * [SMSAPI.COM API documentation](https://www.smsapi.com/docs) diff --git a/build.xml b/build.xml deleted file mode 100644 index 8fde3ed..0000000 --- a/build.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/composer.json b/composer.json index 85bd496..19a41b2 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,6 @@ "phpunit/phpunit": "^6", "symfony/yaml": "^3", "marc-mabe/php-enum": "^3", - "phing/phing": "^2.5", "doctrine/instantiator": "1.0.5", "phpdocumentor/reflection-docblock": "^4.3", "phpdocumentor/type-resolver": "^0.5", From e8524a0d2ce28eb18a422c054a3ea6876fe90dea Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 27 Jan 2021 11:51:08 +0100 Subject: [PATCH 19/93] Removes php-enum from dev dependencies. --- composer.json | 1 - tests/Config.php | 5 ----- tests/ServiceName.php | 9 +-------- tests/SmsapiClientIntegrationTestCase.php | 5 +++-- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 19a41b2..fece637 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,6 @@ "ext-mbstring": "*", "phpunit/phpunit": "^6", "symfony/yaml": "^3", - "marc-mabe/php-enum": "^3", "doctrine/instantiator": "1.0.5", "phpdocumentor/reflection-docblock": "^4.3", "phpdocumentor/type-resolver": "^0.5", diff --git a/tests/Config.php b/tests/Config.php index 05e94b3..541ac50 100644 --- a/tests/Config.php +++ b/tests/Config.php @@ -20,9 +20,4 @@ public static function get(string $key) return $config[$key] ?? null; } - - public static function getServiceName(): ServiceName - { - return ServiceName::byValue(self::get('Service name')); - } } diff --git a/tests/ServiceName.php b/tests/ServiceName.php index 69f4eef..9a2dab5 100644 --- a/tests/ServiceName.php +++ b/tests/ServiceName.php @@ -3,14 +3,7 @@ namespace Smsapi\Client\Tests; -use MabeEnum\Enum; - -/** - * @method static ServiceName SMSAPI_PL - * @method static ServiceName SMSAPI_COM - * @method static ServiceName byValue($value) - */ -class ServiceName extends Enum +class ServiceName { const SMSAPI_PL = 'SMSAPI.PL'; const SMSAPI_COM = 'SMSAPI.COM'; diff --git a/tests/SmsapiClientIntegrationTestCase.php b/tests/SmsapiClientIntegrationTestCase.php index 3571770..6c547c8 100644 --- a/tests/SmsapiClientIntegrationTestCase.php +++ b/tests/SmsapiClientIntegrationTestCase.php @@ -37,9 +37,10 @@ public static function prepare() $smsapiHttpClient->setLogger(new TestLogger()); } - if (Config::getServiceName()->is(ServiceName::SMSAPI_PL)) { + $serviceName = Config::get('Service name'); + if ($serviceName === ServiceName::SMSAPI_PL) { self::$smsapiService = $smsapiHttpClient->smsapiPlServiceWithUri(self::$apiToken, $apiUri); - } elseif (Config::getServiceName()->is(ServiceName::SMSAPI_COM)) { + } elseif ($serviceName === ServiceName::SMSAPI_COM) { self::$smsapiService = $smsapiHttpClient->smsapiComServiceWithUri(self::$apiToken, $apiUri); } } From 52cb770c8dc96b3f89b46124fe82a20f713178e3 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 27 Jan 2021 12:15:03 +0100 Subject: [PATCH 20/93] Fixes sms content details tests --- tests/Integration/Feature/Sms/SmsFeatureTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/Integration/Feature/Sms/SmsFeatureTest.php b/tests/Integration/Feature/Sms/SmsFeatureTest.php index e9b056e..e78a420 100644 --- a/tests/Integration/Feature/Sms/SmsFeatureTest.php +++ b/tests/Integration/Feature/Sms/SmsFeatureTest.php @@ -48,7 +48,7 @@ public function it_should_send_sms_with_external_id() /** * @test */ - public function it_should_receive_details_for_single_sms() + public function it_should_receive_content_details_for_single_sms() { $smsFeature = self::$smsapiService->smsFeature(); $sendSmsBag = $this->givenSmsToSend(); @@ -107,16 +107,17 @@ public function it_should_send_flash_smss() /** * @test */ - public function it_should_not_receive_details_for_smss() + public function it_should_not_receive_content_details_for_smss() { $smsFeature = self::$smsapiService->smsFeature(); $sendSmsesBag = $this->givenSmssToSend(); $sendSmsesBag->test = true; + /** @var Sms[] $results */ $results = $smsFeature->sendSmss($sendSmsesBag); foreach ($results as $result) { - $this->assertNull($result->details); + $this->assertNull($result->content); } } From 3f324387f3a96283a210db934e81eafc30200897 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 27 Jan 2021 12:17:30 +0100 Subject: [PATCH 21/93] Fixes test method declaration issues --- .../Sms/SmsToContactsGroupFeatureTest.php | 10 ++++++++-- .../Contacts/Data/ContactFactoryTest.php | 20 +++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/tests/Integration/Feature/Sms/SmsToContactsGroupFeatureTest.php b/tests/Integration/Feature/Sms/SmsToContactsGroupFeatureTest.php index 9869b0e..0997dad 100644 --- a/tests/Integration/Feature/Sms/SmsToContactsGroupFeatureTest.php +++ b/tests/Integration/Feature/Sms/SmsToContactsGroupFeatureTest.php @@ -27,7 +27,10 @@ class SmsToContactsGroupFeatureTest extends SmsapiClientIntegrationTestCase /** @var ContactGroup */ private $contactGroup; - protected function setUp() + /** + * @before + */ + public function createContacts() { $this->phoneNumber = PhoneNumberFixture::anyValidMobile(); @@ -42,7 +45,10 @@ protected function setUp() self::$smsapiService->contactsFeature()->groupsFeature()->assignContactToGroup($assignContactToGroupBag); } - protected function tearDown() + /** + * @after + */ + public function removeContacts() { $contactsHelper = new ContactsHelper(self::$smsapiService->contactsFeature()); $contactsHelper->deleteContact($this->contact->id); diff --git a/tests/Unit/Feature/Contacts/Data/ContactFactoryTest.php b/tests/Unit/Feature/Contacts/Data/ContactFactoryTest.php index e1166cf..d281731 100644 --- a/tests/Unit/Feature/Contacts/Data/ContactFactoryTest.php +++ b/tests/Unit/Feature/Contacts/Data/ContactFactoryTest.php @@ -14,11 +14,9 @@ class ContactFactoryTest extends TestCase { - private $contactFactory; - - protected function setUp() + private function createContactsFactory() { - $this->contactFactory = new ContactFactory( + return new ContactFactory( new ContactGroupFactory(new GroupPermissionFactory()), new ContactCustomFieldFactory() ); @@ -38,7 +36,7 @@ public function it_should_convert_mandatory_built_in_contact_fields() $this->assertTrue(true); - $contact = $this->contactFactory->createFromObject($contactData); + $contact = $this->createContactsFactory()->createFromObject($contactData); $this->assertEquals('any', $contact->id); $this->assertEquals(new DateTime('2020-05-11'), $contact->dateCreated); @@ -52,26 +50,26 @@ public function it_should_convert_mandatory_built_in_contact_fields() public function it_should_convert_optional_built_in_contact_fields() { $contactData = $this->givenAnyContactData(); - $contact = $this->contactFactory->createFromObject($contactData); + $contact = $this->createContactsFactory()->createFromObject($contactData); $this->assertNull($contact->email); $this->assertNull($contact->phoneNumber); $this->assertNull($contact->country); $this->assertNull($contact->undeliveredMessages); $contactData->email = 'any@example.com'; - $contact = $this->contactFactory->createFromObject($contactData); + $contact = $this->createContactsFactory()->createFromObject($contactData); $this->assertEquals('any@example.com', $contact->email); $contactData->phone_number = '123123123'; - $contact = $this->contactFactory->createFromObject($contactData); + $contact = $this->createContactsFactory()->createFromObject($contactData); $this->assertEquals('123123123', $contact->phoneNumber); $contactData->country = 'any'; - $contact = $this->contactFactory->createFromObject($contactData); + $contact = $this->createContactsFactory()->createFromObject($contactData); $this->assertEquals('any', $contact->country); $contactData->undelivered_messages = 1; - $contact = $this->contactFactory->createFromObject($contactData); + $contact = $this->createContactsFactory()->createFromObject($contactData); $this->assertEquals(1, $contact->undeliveredMessages); } @@ -85,7 +83,7 @@ public function it_should_convert_custom_fields() $contactData->custom_field_1 = 'any1'; $contactData->custom_field_2 = 'any2'; - $contact = $this->contactFactory->createFromObject($contactData); + $contact = $this->createContactsFactory()->createFromObject($contactData); $this->assertEquals('custom_field_1', $contact->customFields[0]->name); $this->assertEquals('any1', $contact->customFields[0]->value); From 1f3515821ff076282a3df9a7ef33b823f4fc58eb Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 27 Jan 2021 12:26:14 +0100 Subject: [PATCH 22/93] Adds support for PHP 8 --- .travis.yml | 1 + Dockerfile.php8 | 17 +++++++++++++++++ composer.json | 10 +++++----- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 Dockerfile.php8 diff --git a/.travis.yml b/.travis.yml index 1edde00..6da4a7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ php: - '7.2' - '7.3' - '7.4' +- '8.0' before_script: - composer self-update - composer install diff --git a/Dockerfile.php8 b/Dockerfile.php8 new file mode 100644 index 0000000..c2916f9 --- /dev/null +++ b/Dockerfile.php8 @@ -0,0 +1,17 @@ +FROM composer:latest as composer +FROM php:8.0-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make + +RUN pecl install xdebug-3.0.2 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/composer.json b/composer.json index fece637..330fa8f 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": "^7", + "php": "^7 || ^8.0", "ext-json": "*", "psr/log": "^1", "psr/http-message": "^1", @@ -25,11 +25,11 @@ }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6", + "phpunit/phpunit": "^6 || ^8", "symfony/yaml": "^3", - "doctrine/instantiator": "1.0.5", - "phpdocumentor/reflection-docblock": "^4.3", - "phpdocumentor/type-resolver": "^0.5", + "doctrine/instantiator": "1.0.5 || ^1.4.0", + "phpdocumentor/reflection-docblock": "^4.3 || ^5.2.0", + "phpdocumentor/type-resolver": "^0.5 || ^1.3.0", "guzzlehttp/psr7": "^1", "ext-curl": "*" }, From 38c4168bc58f616550205feb464d9be984fff138 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 29 Jan 2021 13:29:05 +0100 Subject: [PATCH 23/93] Adds support for PHP 8 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3033e97..c67ebb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Added +- PHP-8 support + ## [3.0.1] - 2020-12-08 ### Changed - Guzzle HTTP helpers marked as optional dependency From 743d6631ffec40c19e50f77aefe22f323551ebbf Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 29 Jan 2021 13:29:52 +0100 Subject: [PATCH 24/93] Fixes guide how to test --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f79f55d..4f144c0 100644 --- a/README.md +++ b/README.md @@ -270,7 +270,7 @@ $client->setLogger($logger); ## Test package 1. Download package: `composer create-project smsapi/php-client` -2. Execute tests: `make test` +2. Execute tests: `./vendor/bin/phpunit --configuration phpunit.dist.xml` ## Docs & Infos * [SMSAPI.COM API documentation](https://www.smsapi.com/docs) From 30dd57d1c744f4dd0d907339c293bf932fb3a65b Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 29 Jan 2021 13:41:11 +0100 Subject: [PATCH 25/93] Adds support for PHP 8 --- src/SmsapiClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index c44b19b..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.1'; + const VERSION = 'Unreleased'; public function smsapiPlService(string $apiToken): SmsapiPlService; From dd5955b4cc497bc6b4f3315b82fb96d766233602 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 29 Jan 2021 13:46:06 +0100 Subject: [PATCH 26/93] Releases version 3.0.2 - resolves #96 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c67ebb6..6e26a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.2] - 2021-01-29 ### Added - PHP-8 support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..4590b54 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.2'; public function smsapiPlService(string $apiToken): SmsapiPlService; From fb2272a324a6b60b29086dbad42a910a57df2576 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 19 Jul 2021 09:04:01 +0200 Subject: [PATCH 27/93] Adds api token to test configuration example file --- tests-resources/config/config.dist.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests-resources/config/config.dist.yml b/tests-resources/config/config.dist.yml index c3da0b8..9d15135 100644 --- a/tests-resources/config/config.dist.yml +++ b/tests-resources/config/config.dist.yml @@ -1,3 +1,4 @@ Service name: SMSAPI.PL API URI: https://api.smsapi.pl +API token: 0000000000000000000000000000000000000000 logger: false From ab9b9fe3b430f2d6c3fe71bd6e7dc1abc915e79c Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 19 Jul 2021 11:15:03 +0200 Subject: [PATCH 28/93] Describes how to run tests --- Makefile | 8 +++++++- Makefile.php8 | 8 ++++++++ README.md | 39 ++++++++++++++++++++++++++++++++++++--- docker-compose.yml | 7 +++++++ 4 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 Makefile.php8 diff --git a/Makefile b/Makefile index 199e534..615ee88 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,13 @@ .PHONY: help help: - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + @grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + | sort \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + + +include Makefile.php8 + .DEFAULT_GOAL := help diff --git a/Makefile.php8 b/Makefile.php8 new file mode 100644 index 0000000..708010a --- /dev/null +++ b/Makefile.php8 @@ -0,0 +1,8 @@ +prepare-php8: ## load dependencies + docker-compose run -T php8 /usr/bin/composer update + +test-php8: prepare-php8 ## run test + docker-compose run -T php8 php vendor/bin/phpunit --configuration phpunit.xml + +test-suite-php8: prepare-php8 ## run test against suite, ex: make test-suite SUITE="unit" + docker-compose run -T php8 php vendor/bin/phpunit --configuration phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/README.md b/README.md index 4f144c0..58219b3 100644 --- a/README.md +++ b/README.md @@ -268,9 +268,42 @@ $logger = new class() implements LoggerInterface $client->setLogger($logger); ``` -## Test package -1. Download package: `composer create-project smsapi/php-client` -2. Execute tests: `./vendor/bin/phpunit --configuration phpunit.dist.xml` +## How to test package + +Copy `phpunit.dist.xml` to `phpunit.xml`. You may adjust it to your needs then. + +Copy `tests-resources/config/config.dist.yml` to `tests-resources/config/config.yml`. Fill in SMSAPI service connection data. + +### How to run unit tests + +Unit tests are included into package build process and run against its current version on every commit (see `.travis.yml`). +You can run those tests locally with ease using provided Docker configuration, simply run: + +```shell +make test-suite SUITE="unit" +``` + +### How to run integration tests + +Note that integration test works within an account you have configured in `tests-resources/config/config.yml`. +Although those test have been written to self-cleanup on exit, in case of failure some trash data may stay. +Use it with caution. + +```shell +make test-suite SUITE="integration" +``` + +### How to run feature tests + +Feature test groups are defined in `phpunit.dist.xml`. To run tests execute: + +```shell +make test-suite SUITE="feature-contacts" +``` + +### How to run tests against PHP8 + +To run any of mentioned above against PHP8 use make targets with `php8` suffix. See `Makefile.php8`. ## Docs & Infos * [SMSAPI.COM API documentation](https://www.smsapi.com/docs) diff --git a/docker-compose.yml b/docker-compose.yml index f669f77..f0636d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,3 +7,10 @@ services: - .:/app network_mode: host + php8: + build: + context: . + dockerfile: Dockerfile.php8 + volumes: + - .:/app + network_mode: host \ No newline at end of file From 4723a380eb179124d6c940218c8ea55beeb43d1b Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 19 Jul 2021 12:51:48 +0200 Subject: [PATCH 29/93] Makes all errors verbose --- phpunit.dist.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpunit.dist.xml b/phpunit.dist.xml index 95cb746..4719765 100644 --- a/phpunit.dist.xml +++ b/phpunit.dist.xml @@ -67,4 +67,10 @@ tests/Integration/Feature/Blacklist + + + + + + From 2567ef7ca7d77677b5405bcd9a30660eb9bb61ad Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 19 Jul 2021 13:23:07 +0200 Subject: [PATCH 30/93] Fixes Guzzle PSR7 lib incompatible URI paths --- CHANGELOG.md | 4 ++++ .../HttpClient/Decorator/BaseUriDecorator.php | 7 ++++--- src/SmsapiClient.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e26a30..07ec04e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Fixed +- Guzzle PSR7 incompatible URI paths, `The path of a URI with an authority must start with a slash "/" or be empty` + ## [3.0.2] - 2021-01-29 ### Added - PHP-8 support diff --git a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php index 4747292..75b50db 100644 --- a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php @@ -37,11 +37,12 @@ private function prependBaseUri(RequestInterface $request): RequestInterface $scheme = $baseUriParts['scheme'] ?? ''; $host = $baseUriParts['host'] ?? ''; - $path = $baseUriParts['path'] ?? ''; + $basePath = $baseUriParts['path'] ?? ''; + $basePath = rtrim($basePath, '/'); - $uri = $uri->withScheme($scheme); + $uri = $uri->withPath($basePath . '/' . $uri->getPath()); $uri = $uri->withHost($host); - $uri = $uri->withPath($path . $uri->getPath()); + $uri = $uri->withScheme($scheme); return $request->withUri($uri); } diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 4590b54..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.2'; + const VERSION = 'Unreleased'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 762a7fd977a1ad0d57e802e71ff21ac6abaf0e89 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 21 Jul 2021 14:06:02 +0200 Subject: [PATCH 31/93] Releases version 3.0.3 - resolves #99 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07ec04e..ab4c24c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.3] - 2021-07-21 ### Fixed - Guzzle PSR7 incompatible URI paths, `The path of a URI with an authority must start with a slash "/" or be empty` diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..a4b592a 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.3'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 2c9e2b0d9ebe8c41e449b997e23b70648cb89c79 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Wed, 15 Sep 2021 19:11:40 +0200 Subject: [PATCH 32/93] Update psr\log --- .gitignore | 1 + composer.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2a0d621..706bbf6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /composer.lock /phpunit.xml /composer.phar +.phpunit.result.cache diff --git a/composer.json b/composer.json index 330fa8f..67cee8b 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "php": "^7 || ^8.0", "ext-json": "*", - "psr/log": "^1", + "psr/log": "^1 || ^2 || ^3", "psr/http-message": "^1", "psr/http-client": "^1", "psr/http-factory": "^1" From c8b9a97c6a7dc586570c5c7efabc9ca246515cc2 Mon Sep 17 00:00:00 2001 From: SMSAPI Date: Thu, 13 Jan 2022 10:02:13 +0100 Subject: [PATCH 33/93] Update README.md Added info how to use smsapi.se and smsapi.bg services --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 58219b3..3f74457 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ $apiToken = '0000000000000000000000000000000000000000'; $service = $client->smsapiPlService($apiToken); ``` -## How to use a service with custom URI? +### How to use *SMSAPI.SE* or *SMSAPI.BG* services? ```php smsapiComServiceWithUri($apiToken, $uri); ``` @@ -308,7 +308,11 @@ To run any of mentioned above against PHP8 use make targets with `php8` suffix. ## Docs & Infos * [SMSAPI.COM API documentation](https://www.smsapi.com/docs) * [SMSAPI.PL API documentation](https://www.smsapi.pl/docs) -* [Repository on GitHub](https://github.com/smsapi/smsapi-php-client) -* [Package on Packagist](https://packagist.org/packages/smsapi/php-client) +* [SMSAPI.SE API documentation](https://www.smsapi.se/docs) +* [SMSAPI.BG API documentation](https://www.smsapi.bg/docs) * [SMSAPI.COM web page](https://smsapi.com) * [SMSAPI.PL web page](https://smsapi.pl) +* [SMSAPI.SE web page](https://smsapi.se) +* [SMSAPI.BG web page](https://smsapi.bg) +* [Repository on GitHub](https://github.com/smsapi/smsapi-php-client) +* [Package on Packagist](https://packagist.org/packages/smsapi/php-client) From 45a562708eca51003a6e54e61ca6fc30720b70f9 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Tue, 11 Jan 2022 16:37:59 +0100 Subject: [PATCH 34/93] Run test with github actions --- .github/workflows/tests.yml | 46 +++++++++++++++++++++++++++++++++++++ .travis.yml | 12 ---------- 2 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..33d583a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,46 @@ +name: Tests + +on: + push: + branches: + - main + - master + pull_request: + +jobs: + tests: + name: PHP ${{ matrix.php }} / ${{ matrix.dependency-version }} + runs-on: ubuntu-latest + strategy: + matrix: + php: + - 7.0 + - 7.1 + - 7.2 + - 7.3 + - 7.4 + - 8.0 + - 8.1 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-${{ matrix.php }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }} + + - name: Install dependencies + run: composer update --prefer-dist --no-interaction + + - name: Running unit tests + run: php vendor/bin/phpunit --configuration phpunit.dist.xml --testsuite unit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6da4a7b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: php -php: -- '7.0' -- '7.1' -- '7.2' -- '7.3' -- '7.4' -- '8.0' -before_script: -- composer self-update -- composer install -script: ./vendor/bin/phpunit --configuration phpunit.dist.xml --testsuite unit From 62dbcc85d0b04609303b81e5abd6dda75ba9f49c Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Fri, 14 Jan 2022 13:50:44 +0100 Subject: [PATCH 35/93] Fix for php 8 on integration tests --- src/Curl/SmsapiHttpClient.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Curl/SmsapiHttpClient.php b/src/Curl/SmsapiHttpClient.php index 349ac5d..c6cdbd6 100644 --- a/src/Curl/SmsapiHttpClient.php +++ b/src/Curl/SmsapiHttpClient.php @@ -4,6 +4,7 @@ namespace Smsapi\Client\Curl; +use Psr\Log\LoggerAwareTrait; use Psr\Log\LoggerInterface; use Smsapi\Client\Curl\Discovery\CurlDiscovery; use Smsapi\Client\Curl\Discovery\GuzzleHttpHelpersDiscovery; @@ -16,6 +17,8 @@ */ class SmsapiHttpClient implements SmsapiClient { + use LoggerAwareTrait; + private $httpClient; public function __construct() @@ -30,28 +33,30 @@ public function __construct() ); } - public function setLogger(LoggerInterface $logger) - { - $this->httpClient->setLogger($logger); - } - public function smsapiPlService(string $apiToken): SmsapiPlService { - return $this->httpClient->smsapiPlService($apiToken); + return $this->httpClient()->smsapiPlService($apiToken); } public function smsapiPlServiceWithUri(string $apiToken, string $uri): SmsapiPlService { - return $this->httpClient->smsapiPlServiceWithUri($apiToken, $uri); + return $this->httpClient()->smsapiPlServiceWithUri($apiToken, $uri); } public function smsapiComService(string $apiToken): SmsapiComService { - return $this->httpClient->smsapiComService($apiToken); + return $this->httpClient()->smsapiComService($apiToken); } public function smsapiComServiceWithUri(string $apiToken, string $uri): SmsapiComService { - return $this->httpClient->smsapiComServiceWithUri($apiToken, $uri); + return $this->httpClient()->smsapiComServiceWithUri($apiToken, $uri); + } + + private function httpClient(): \Smsapi\Client\SmsapiHttpClient + { + $this->httpClient->setLogger($this->logger); + + return $this->httpClient; } -} \ No newline at end of file +} From c9ffdb1dc562707e87d88fea28b91094fcb48ed1 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Fri, 14 Jan 2022 13:56:18 +0100 Subject: [PATCH 36/93] Check that logger is null before set --- src/Curl/SmsapiHttpClient.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Curl/SmsapiHttpClient.php b/src/Curl/SmsapiHttpClient.php index c6cdbd6..ddac39b 100644 --- a/src/Curl/SmsapiHttpClient.php +++ b/src/Curl/SmsapiHttpClient.php @@ -55,7 +55,9 @@ public function smsapiComServiceWithUri(string $apiToken, string $uri): SmsapiCo private function httpClient(): \Smsapi\Client\SmsapiHttpClient { - $this->httpClient->setLogger($this->logger); + if ($this->logger instanceof LoggerInterface) { + $this->httpClient->setLogger($this->logger); + } return $this->httpClient; } From d48a4625397d87413040b3dfd39830ed5867c06e Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Mon, 17 Jan 2022 14:30:32 +0100 Subject: [PATCH 37/93] Remove test logger --- tests-resources/config/config.dist.yml | 1 - tests-resources/config/config.yml.example | 1 - tests/SmsapiClientIntegrationTestCase.php | 4 --- tests/TestLogger.php | 37 ----------------------- 4 files changed, 43 deletions(-) delete mode 100644 tests/TestLogger.php diff --git a/tests-resources/config/config.dist.yml b/tests-resources/config/config.dist.yml index 9d15135..7f9437f 100644 --- a/tests-resources/config/config.dist.yml +++ b/tests-resources/config/config.dist.yml @@ -1,4 +1,3 @@ Service name: SMSAPI.PL API URI: https://api.smsapi.pl API token: 0000000000000000000000000000000000000000 -logger: false diff --git a/tests-resources/config/config.yml.example b/tests-resources/config/config.yml.example index ffbe66d..f93b66c 100644 --- a/tests-resources/config/config.yml.example +++ b/tests-resources/config/config.yml.example @@ -1,4 +1,3 @@ Service name: "SMSAPI.PL" OR "SMSAPI.COM" API token: 40-characters length string generated in SMSAPI Panel API URI: "https://api.smsapi.pl", "https://api.smsapi.com", "https://api2.smsapi.pl" or "https://api2.smsapi.com" -logger: true diff --git a/tests/SmsapiClientIntegrationTestCase.php b/tests/SmsapiClientIntegrationTestCase.php index 6c547c8..a3a5337 100644 --- a/tests/SmsapiClientIntegrationTestCase.php +++ b/tests/SmsapiClientIntegrationTestCase.php @@ -33,10 +33,6 @@ public static function prepare() $smsapiHttpClient = new SmsapiHttpClient(); - if (Config::get('logger')) { - $smsapiHttpClient->setLogger(new TestLogger()); - } - $serviceName = Config::get('Service name'); if ($serviceName === ServiceName::SMSAPI_PL) { self::$smsapiService = $smsapiHttpClient->smsapiPlServiceWithUri(self::$apiToken, $apiUri); diff --git a/tests/TestLogger.php b/tests/TestLogger.php deleted file mode 100644 index 3ff6519..0000000 --- a/tests/TestLogger.php +++ /dev/null @@ -1,37 +0,0 @@ - $value) { - if ($value instanceof RequestInterface) { - $context[$item] = [ - 'headers' => $value->getHeaders(), - 'uri' => $value->getUri()->__toString(), - 'method' => $value->getMethod(), - 'contents' => $value->getBody()->__toString(), - ]; - } elseif ($value instanceof ResponseInterface) { - $context[$item] = [ - 'headers' => $value->getHeaders(), - 'status_code' => $value->getStatusCode(), - 'contents' => $value->getBody()->__toString(), - ]; - } - } - - echo sprintf("[%s] %s (%s)\n", $level, $message, print_r($context)); - } -} From 615dc42d8b5497614b34ba4e1e2fc5a3f453a905 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 17 Jan 2022 16:18:56 +0100 Subject: [PATCH 38/93] Releases version 3.0.4 - resolves #100 --- CHANGELOG.md | 4 ++++ src/SmsapiClient.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab4c24c..1d8b9ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.0.4] - 2022-01-17 +### Added +- `psr/log` v2, v3 support + ## [3.0.3] - 2021-07-21 ### Fixed - Guzzle PSR7 incompatible URI paths, `The path of a URI with an authority must start with a slash "/" or be empty` diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index a4b592a..113101c 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.3'; + const VERSION = '3.0.4'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 09243027ae915915a5b33be593f7ec976c14c368 Mon Sep 17 00:00:00 2001 From: Kyryl Bogach Date: Tue, 22 Mar 2022 14:19:57 +0100 Subject: [PATCH 39/93] Fix headers parsing of HttpClient --- src/Curl/HttpClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Curl/HttpClient.php b/src/Curl/HttpClient.php index d068cf5..eaaaca1 100644 --- a/src/Curl/HttpClient.php +++ b/src/Curl/HttpClient.php @@ -88,7 +88,7 @@ private function execute(RequestInterface $request, $httpClient): ResponseInterf $headerSize = curl_getinfo($httpClient, CURLINFO_HEADER_SIZE); $headerString = substr($response, 0, $headerSize); - $headers = array_filter(explode("\n", $headerString), 'trim'); + $headers = array_filter(array_map('trim', explode("\n", $headerString))); $body = substr($response, $headerSize); @@ -99,4 +99,4 @@ private function closeHttpClient($httpClient) { curl_close($httpClient); } -} \ No newline at end of file +} From 12dea755fdc26861bdab26f092ab5b6e9bf4612d Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 23 Mar 2022 10:44:51 +0100 Subject: [PATCH 40/93] Releases version 3.0.5 - resolves #120 --- CHANGELOG.md | 4 ++++ src/SmsapiClient.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d8b9ae..c57859e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [3.0.5] - 2022-03-23 +### Fixed +- HTTP headers parsing, `HttpClient` issue + ## [3.0.4] - 2022-01-17 ### Added - `psr/log` v2, v3 support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 113101c..7561a9e 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.4'; + const VERSION = '3.0.5'; public function smsapiPlService(string $apiToken): SmsapiPlService; From b50149800640df360e535d8eaa57b005f2f184b1 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Thu, 24 Mar 2022 11:26:06 +0100 Subject: [PATCH 41/93] Fixes HTTP headers parsing of built-in HttpClient, PSR-7 compatibility issue --- CHANGELOG.md | 4 + src/Curl/HttpClient.php | 2 +- src/Curl/HttpHeadersParser.php | 23 +++++ .../HttpClient/Decorator/LoggerDecorator.php | 9 +- src/SmsapiClient.php | 2 +- tests/Unit/Curl/HttpHeadersParserTest.php | 85 +++++++++++++++++++ 6 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 src/Curl/HttpHeadersParser.php create mode 100644 tests/Unit/Curl/HttpHeadersParserTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c57859e..24a4711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Fixed +- HTTP headers parsing, PSR-7 compliant + ## [3.0.5] - 2022-03-23 ### Fixed - HTTP headers parsing, `HttpClient` issue diff --git a/src/Curl/HttpClient.php b/src/Curl/HttpClient.php index eaaaca1..b2f9af7 100644 --- a/src/Curl/HttpClient.php +++ b/src/Curl/HttpClient.php @@ -88,7 +88,7 @@ private function execute(RequestInterface $request, $httpClient): ResponseInterf $headerSize = curl_getinfo($httpClient, CURLINFO_HEADER_SIZE); $headerString = substr($response, 0, $headerSize); - $headers = array_filter(array_map('trim', explode("\n", $headerString))); + $headers = HttpHeadersParser::parse($headerString); $body = substr($response, $headerSize); diff --git a/src/Curl/HttpHeadersParser.php b/src/Curl/HttpHeadersParser.php new file mode 100644 index 0000000..9ae2d69 --- /dev/null +++ b/src/Curl/HttpHeadersParser.php @@ -0,0 +1,23 @@ +logger->info('Request', [ + 'request' => $request, 'method' => $request->getMethod(), 'uri' => $request->getUri(), + 'headers' => $request->getHeaders(), + 'body' => $request->getBody()->getContents(), ]); $response = $this->client->sendRequest($request); - $this->logger->info('Response', ['response' => $response]); + $this->logger->info('Response', [ + 'response' => $response, + 'headers' => $response->getHeaders(), + 'body' => $response->getBody()->getContents(), + ]); return $response; } diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 7561a9e..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.5'; + const VERSION = 'Unreleased'; public function smsapiPlService(string $apiToken): SmsapiPlService; diff --git a/tests/Unit/Curl/HttpHeadersParserTest.php b/tests/Unit/Curl/HttpHeadersParserTest.php new file mode 100644 index 0000000..cdfdbd8 --- /dev/null +++ b/tests/Unit/Curl/HttpHeadersParserTest.php @@ -0,0 +1,85 @@ +assertArrayNotHasKey('HTTP/1.1 202 OK', $headers); + $this->assertNotContains('HTTP/1.1 202 OK', $headers); + } + + /** + * @test + */ + public function not_bypass_non_http_status_line_first_line() + { + $rawHeaders = "Header1: any\r\nHeader2: any, other\r\n"; + + $headers = HttpHeadersParser::parse($rawHeaders); + + $this->assertArrayHasKey('Header1', $headers); + } + + /** + * @test + */ + public function bypass_empty_line() + { + $rawHeaders = "HTTP/1.1 202 OK\r\nHeader1: any\r\nHeader2: any, other\r\n\r\n"; + + $headers = HttpHeadersParser::parse($rawHeaders); + + $this->assertCount(2, array_keys($headers)); + } + + /** + * @test + */ + public function add_all_headers() + { + $rawHeaders = "HTTP/1.1 202 OK\r\nHeader1: any\r\nHeader2: any, other\r\n"; + + $headers = HttpHeadersParser::parse($rawHeaders); + + $this->assertArrayHasKey('Header1', $headers); + $this->assertArrayHasKey('Header2', $headers); + } + + /** + * @test + */ + public function add_single_value_headers() + { + $rawHeaders = "HTTP/1.1 202 OK\r\nHeader1: any\r\nHeader2: any, other\r\n"; + + $headers = HttpHeadersParser::parse($rawHeaders); + + $this->assertEquals('any', $headers['Header1']); + } + + /** + * @test + */ + public function add_multi_value_headers() + { + $rawHeaders = "HTTP/1.1 202 OK\r\nHeader1: any\r\nHeader2: any, other\r\n"; + + $headers = HttpHeadersParser::parse($rawHeaders); + + $this->assertEquals('any, other', $headers['Header2']); + } +} \ No newline at end of file From 499af0b02cb8e07aa4774d85cc295a66141b69a4 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 28 Mar 2022 11:58:20 +0200 Subject: [PATCH 42/93] Releases version 3.0.6 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24a4711..9e48f8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.6] - 2022-03-28 ### Fixed - HTTP headers parsing, PSR-7 compliant diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..6f6c0b5 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.6'; public function smsapiPlService(string $apiToken): SmsapiPlService; From bda0b2d948cf5fb56af4de486c93530f68584ae2 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 25 May 2022 16:21:54 +0200 Subject: [PATCH 43/93] Sets Composer to 2.2 LTS as Composer 2.3.0 dropped support for PHP <7.2.5. Mitigates CVE-2022-24828. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f1bf11c..2962bf0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM composer:latest as composer +FROM composer:2.2 as composer FROM php:7.0-cli-alpine RUN apk update && \ From d23aead0d6f27b71152c15c6eda8e866f99bef1f Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 4 Nov 2022 12:49:02 +0100 Subject: [PATCH 44/93] Fixes MFA feature integration tests --- tests/Integration/Feature/Mfa/MfaFeatureTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Integration/Feature/Mfa/MfaFeatureTest.php b/tests/Integration/Feature/Mfa/MfaFeatureTest.php index 7fdbc3c..1a01cfb 100644 --- a/tests/Integration/Feature/Mfa/MfaFeatureTest.php +++ b/tests/Integration/Feature/Mfa/MfaFeatureTest.php @@ -32,7 +32,7 @@ public function it_should_create_mfa() /** * @test */ - public function it_should_not_create_mfa_for_an_ivalid_mobile_phone_number() + public function it_should_not_create_mfa_for_an_invalid_mobile_phone_number() { //given $mfaFeature = self::$smsapiService->mfaFeature(); @@ -97,7 +97,7 @@ public function it_should_not_verify_invalid_code() { //given $mfaFeature = self::$smsapiService->mfaFeature(); - $verificationMfaBag = new VerificationMfaBag('123 456', PhoneNumberFixture::anyValidMobile()); + $verificationMfaBag = new VerificationMfaBag('invalid', PhoneNumberFixture::anyValidMobile()); //expect $this->expectException(SmsapiClientException::class); $this->expectExceptionMessage('MFA code has invalid format'); From d93ffcc77d51818a6aeff6f96f4130d58b1615e2 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 4 Nov 2022 13:02:42 +0100 Subject: [PATCH 45/93] Marks as unreleased --- CHANGELOG.md | 2 ++ src/SmsapiClient.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e48f8b..67f292b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + ## [3.0.6] - 2022-03-28 ### Fixed - HTTP headers parsing, PSR-7 compliant diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 6f6c0b5..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.6'; + const VERSION = 'Unreleased'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 8f755c5f3448ac5df44079953d2b3758b930a840 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 15 Nov 2022 11:40:11 +0100 Subject: [PATCH 46/93] Adds git attributes --- .gitattributes | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..cd2ecfe --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +/.github export-ignore +/tests export-ignore +/tests-resources export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.docker-compose.yml export-ignore +/Dockerfile export-ignore +/Dockerfile.php8 export-ignore +/Makefile export-ignore +/Makefile.php8 export-ignore +/phpcs.xml export-ignore +/phpunit.dist.xml export-ignore + +*.php diff=php \ No newline at end of file From a70a0fe737d6b22792eb3b3b4730bbcde55392a4 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 15 Nov 2022 12:30:55 +0100 Subject: [PATCH 47/93] Adds security advisories --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 67cee8b..f477dee 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,8 @@ "phpdocumentor/reflection-docblock": "^4.3 || ^5.2.0", "phpdocumentor/type-resolver": "^0.5 || ^1.3.0", "guzzlehttp/psr7": "^1", - "ext-curl": "*" + "ext-curl": "*", + "roave/security-advisories": "dev-latest" }, "suggest": { "ext-curl": "To use Curl HttpClient", From 205786d4ed1579117490af8058e62e62ec74dcb2 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 15 Nov 2022 15:50:26 +0100 Subject: [PATCH 48/93] Extracts build assets to separate directory --- .gitattributes | 8 +------ .github/workflows/tests.yml | 2 +- .gitignore | 1 - Makefile | 21 ------------------ Makefile.php8 | 8 ------- build/Makefile | 22 +++++++++++++++++++ build/docker-compose.yml | 17 ++++++++++++++ Dockerfile => build/php-7.0/Dockerfile | 0 build/php-7.0/Makefile | 10 +++++++++ Dockerfile.php8 => build/php-8.0/Dockerfile | 0 build/php-8.0/Makefile | 10 +++++++++ docker-compose.yml | 16 -------------- phpcs.xml | 17 -------------- .../phpunit.dist.xml | 0 14 files changed, 61 insertions(+), 71 deletions(-) delete mode 100644 Makefile delete mode 100644 Makefile.php8 create mode 100644 build/Makefile create mode 100644 build/docker-compose.yml rename Dockerfile => build/php-7.0/Dockerfile (100%) create mode 100644 build/php-7.0/Makefile rename Dockerfile.php8 => build/php-8.0/Dockerfile (100%) create mode 100644 build/php-8.0/Makefile delete mode 100644 docker-compose.yml delete mode 100644 phpcs.xml rename phpunit.dist.xml => tests-resources/phpunit.dist.xml (100%) diff --git a/.gitattributes b/.gitattributes index cd2ecfe..1754c28 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,14 +1,8 @@ /.github export-ignore +/build export-ignore /tests export-ignore /tests-resources export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.docker-compose.yml export-ignore -/Dockerfile export-ignore -/Dockerfile.php8 export-ignore -/Makefile export-ignore -/Makefile.php8 export-ignore -/phpcs.xml export-ignore -/phpunit.dist.xml export-ignore *.php diff=php \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 33d583a..6d4fa90 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,4 +43,4 @@ jobs: run: composer update --prefer-dist --no-interaction - name: Running unit tests - run: php vendor/bin/phpunit --configuration phpunit.dist.xml --testsuite unit + run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit diff --git a/.gitignore b/.gitignore index 706bbf6..0ba02c9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ /vendor /composer.lock /phpunit.xml -/composer.phar .phpunit.result.cache diff --git a/Makefile b/Makefile deleted file mode 100644 index 615ee88..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -.PHONY: help - -help: - @grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ - | sort \ - | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' - - -include Makefile.php8 - - -.DEFAULT_GOAL := help - -prepare: ## load dependencies - docker-compose run -T php /usr/bin/composer update - -test: prepare ## run test - docker-compose run -T php php vendor/bin/phpunit --configuration phpunit.xml - -test-suite: prepare ## run test against suite, ex: make test-suite SUITE="unit" - docker-compose run -T php php vendor/bin/phpunit --configuration phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/Makefile.php8 b/Makefile.php8 deleted file mode 100644 index 708010a..0000000 --- a/Makefile.php8 +++ /dev/null @@ -1,8 +0,0 @@ -prepare-php8: ## load dependencies - docker-compose run -T php8 /usr/bin/composer update - -test-php8: prepare-php8 ## run test - docker-compose run -T php8 php vendor/bin/phpunit --configuration phpunit.xml - -test-suite-php8: prepare-php8 ## run test against suite, ex: make test-suite SUITE="unit" - docker-compose run -T php8 php vendor/bin/phpunit --configuration phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/Makefile b/build/Makefile new file mode 100644 index 0000000..75050a5 --- /dev/null +++ b/build/Makefile @@ -0,0 +1,22 @@ +.PHONY: help build test + +include $(CURDIR)/php-7.0/Makefile +include $(CURDIR)/php-8.0/Makefile + +help: + @grep -hE '^[a-zA-Z0-9_.-]+:.*?## .*$$' $(MAKEFILE_LIST) \ + | sort \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +build: ## build php images + docker-compose build + +test: ## test all against all php images + $(MAKE) test-php-7.0 + $(MAKE) test-php-8.0 + +test-unit: ## test unit suite against all php images + $(MAKE) test-suite-php-7.0 SUITE=unit + $(MAKE) test-suite-php-8.0 SUITE=unit + +.DEFAULT_GOAL := help diff --git a/build/docker-compose.yml b/build/docker-compose.yml new file mode 100644 index 0000000..d65f1c9 --- /dev/null +++ b/build/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3.5' + +services: + + php-7.0: + build: + context: php-7.0 + volumes: + - ..:/app + network_mode: host + + php-8.0: + build: + context: php-8.0 + volumes: + - ..:/app + network_mode: host \ No newline at end of file diff --git a/Dockerfile b/build/php-7.0/Dockerfile similarity index 100% rename from Dockerfile rename to build/php-7.0/Dockerfile diff --git a/build/php-7.0/Makefile b/build/php-7.0/Makefile new file mode 100644 index 0000000..50000f8 --- /dev/null +++ b/build/php-7.0/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-7.0 test-php-7.0 test-suite-php-7.0 + +prepare-php-7.0: ## load dependencies with php 7.0 + docker-compose run -T php-7.0 /usr/bin/composer update + +test-php-7.0: prepare-php-7.0 ## run tests against php 7.0 + docker-compose run -T php-7.0 php vendor/bin/phpunit --configuration phpunit.xml + +test-suite-php-7.0: prepare-php-7.0 ## run suite tests against php 7.0, ex: make test-suite-php-7.0 SUITE="unit" + docker-compose run -T php-7.0 php vendor/bin/phpunit --configuration phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/Dockerfile.php8 b/build/php-8.0/Dockerfile similarity index 100% rename from Dockerfile.php8 rename to build/php-8.0/Dockerfile diff --git a/build/php-8.0/Makefile b/build/php-8.0/Makefile new file mode 100644 index 0000000..3e607df --- /dev/null +++ b/build/php-8.0/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-8.0 test-php-8.0 test-suite-php-8.0 + +prepare-php-8.0: ## load dependencies with php 8.0 + docker-compose run -T php-8.0 /usr/bin/composer update + +test-php-8.0: prepare-php-8.0 ## run tests against php 8.0 + docker-compose run -T php-8.0 php vendor/bin/phpunit --configuration phpunit.xml + +test-suite-php-8.0: prepare-php-8.0 ## run suite tests against php 8.0, ex: make test-suite-php-8.0 SUITE="unit" + docker-compose run -T php-8.0 php vendor/bin/phpunit --configuration phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index f0636d4..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3.5' - -services: - php: - build: . - volumes: - - .:/app - network_mode: host - - php8: - build: - context: . - dockerfile: Dockerfile.php8 - volumes: - - .:/app - network_mode: host \ No newline at end of file diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 1a5512f..0000000 --- a/phpcs.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - SMSAPI Coding Standard - - - - - */Standards/*/Tests/*\.(inc|css|js) - - - - - - **/tests/Unit/** - **/tests/Integration/** - - \ No newline at end of file diff --git a/phpunit.dist.xml b/tests-resources/phpunit.dist.xml similarity index 100% rename from phpunit.dist.xml rename to tests-resources/phpunit.dist.xml From 8ca3fa1f67ff1a6a2669146573bd6adadab2f6b8 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 15 Nov 2022 16:40:19 +0100 Subject: [PATCH 49/93] Extracts build assets to separate directory --- .gitignore | 2 +- build/php-7.0/Makefile | 4 ++-- build/php-8.0/Makefile | 4 ++-- tests-resources/phpunit.dist.xml | 38 ++++++++++++++++---------------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 0ba02c9..130e21e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /tests-resources/config/config.yml +/tests-resources/phpunit.xml /vendor /composer.lock -/phpunit.xml .phpunit.result.cache diff --git a/build/php-7.0/Makefile b/build/php-7.0/Makefile index 50000f8..9f16c05 100644 --- a/build/php-7.0/Makefile +++ b/build/php-7.0/Makefile @@ -4,7 +4,7 @@ prepare-php-7.0: ## load dependencies with php 7.0 docker-compose run -T php-7.0 /usr/bin/composer update test-php-7.0: prepare-php-7.0 ## run tests against php 7.0 - docker-compose run -T php-7.0 php vendor/bin/phpunit --configuration phpunit.xml + docker-compose run -T php-7.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-7.0: prepare-php-7.0 ## run suite tests against php 7.0, ex: make test-suite-php-7.0 SUITE="unit" - docker-compose run -T php-7.0 php vendor/bin/phpunit --configuration phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker-compose run -T php-7.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-8.0/Makefile b/build/php-8.0/Makefile index 3e607df..e834ead 100644 --- a/build/php-8.0/Makefile +++ b/build/php-8.0/Makefile @@ -4,7 +4,7 @@ prepare-php-8.0: ## load dependencies with php 8.0 docker-compose run -T php-8.0 /usr/bin/composer update test-php-8.0: prepare-php-8.0 ## run tests against php 8.0 - docker-compose run -T php-8.0 php vendor/bin/phpunit --configuration phpunit.xml + docker-compose run -T php-8.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-8.0: prepare-php-8.0 ## run suite tests against php 8.0, ex: make test-suite-php-8.0 SUITE="unit" - docker-compose run -T php-8.0 php vendor/bin/phpunit --configuration phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker-compose run -T php-8.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/tests-resources/phpunit.dist.xml b/tests-resources/phpunit.dist.xml index 4719765..4d4acd5 100644 --- a/tests-resources/phpunit.dist.xml +++ b/tests-resources/phpunit.dist.xml @@ -1,7 +1,7 @@ - tests + ../tests - tests/Unit + ../tests/Unit - tests/Integration + ../tests/Integration - tests/Integration/Feature/Contacts - tests/Unit/Feature/Contacts + ../tests/Integration/Feature/Contacts + ../tests/Unit/Feature/Contacts - tests/Integration/Feature/Hlr + ../tests/Integration/Feature/Hlr - tests/Integration/Feature/Mms + ../tests/Integration/Feature/Mms - tests/Integration/Feature/Ping + ../tests/Integration/Feature/Ping - tests/Integration/Feature/Profile + ../tests/Integration/Feature/Profile - tests/Unit/Feature/Push + ../tests/Unit/Feature/Push - tests/Integration/Feature/Sendernames + ../tests/Integration/Feature/Sendernames - tests/Integration/Feature/ShortUrl + ../tests/Integration/Feature/ShortUrl - tests/Integration/Feature/Sms - tests/Unit/Feature/Sms + ../tests/Integration/Feature/Sms + ../tests/Unit/Feature/Sms - tests/Integration/Feature/Mfa + ../tests/Integration/Feature/Mfa - tests/Integration/Feature/Subusers + ../tests/Integration/Feature/Subusers - tests/Integration/Feature/Vms + ../tests/Integration/Feature/Vms - tests/Integration/Feature/Blacklist + ../tests/Integration/Feature/Blacklist From 2be565fd19f3fc2ed412598e738e7e3c740fe3a8 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 16 Nov 2022 12:01:27 +0100 Subject: [PATCH 50/93] Fixes broken dev dependencies --- build/Makefile | 15 +++++++++++++++ build/docker-compose.yml | 35 +++++++++++++++++++++++++++++++++++ build/php-7.0/Dockerfile | 2 +- build/php-7.1/Dockerfile | 17 +++++++++++++++++ build/php-7.1/Makefile | 10 ++++++++++ build/php-7.2/Dockerfile | 17 +++++++++++++++++ build/php-7.2/Makefile | 10 ++++++++++ build/php-7.3/Dockerfile | 17 +++++++++++++++++ build/php-7.3/Makefile | 10 ++++++++++ build/php-7.4/Dockerfile | 17 +++++++++++++++++ build/php-7.4/Makefile | 10 ++++++++++ build/php-8.0/Dockerfile | 2 +- build/php-8.1/Dockerfile | 17 +++++++++++++++++ build/php-8.1/Makefile | 10 ++++++++++ composer.json | 5 +++-- 15 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 build/php-7.1/Dockerfile create mode 100644 build/php-7.1/Makefile create mode 100644 build/php-7.2/Dockerfile create mode 100644 build/php-7.2/Makefile create mode 100644 build/php-7.3/Dockerfile create mode 100644 build/php-7.3/Makefile create mode 100644 build/php-7.4/Dockerfile create mode 100644 build/php-7.4/Makefile create mode 100644 build/php-8.1/Dockerfile create mode 100644 build/php-8.1/Makefile diff --git a/build/Makefile b/build/Makefile index 75050a5..301709d 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,7 +1,12 @@ .PHONY: help build test include $(CURDIR)/php-7.0/Makefile +include $(CURDIR)/php-7.1/Makefile +include $(CURDIR)/php-7.2/Makefile +include $(CURDIR)/php-7.3/Makefile +include $(CURDIR)/php-7.4/Makefile include $(CURDIR)/php-8.0/Makefile +include $(CURDIR)/php-8.1/Makefile help: @grep -hE '^[a-zA-Z0-9_.-]+:.*?## .*$$' $(MAKEFILE_LIST) \ @@ -13,10 +18,20 @@ build: ## build php images test: ## test all against all php images $(MAKE) test-php-7.0 + $(MAKE) test-php-7.1 + $(MAKE) test-php-7.2 + $(MAKE) test-php-7.3 + $(MAKE) test-php-7.4 $(MAKE) test-php-8.0 + $(MAKE) test-php-8.1 test-unit: ## test unit suite against all php images $(MAKE) test-suite-php-7.0 SUITE=unit + $(MAKE) test-suite-php-7.1 SUITE=unit + $(MAKE) test-suite-php-7.2 SUITE=unit + $(MAKE) test-suite-php-7.3 SUITE=unit + $(MAKE) test-suite-php-7.4 SUITE=unit $(MAKE) test-suite-php-8.0 SUITE=unit + $(MAKE) test-suite-php-8.1 SUITE=unit .DEFAULT_GOAL := help diff --git a/build/docker-compose.yml b/build/docker-compose.yml index d65f1c9..4686555 100644 --- a/build/docker-compose.yml +++ b/build/docker-compose.yml @@ -9,9 +9,44 @@ services: - ..:/app network_mode: host + php-7.1: + build: + context: php-7.1 + volumes: + - ..:/app + network_mode: host + + php-7.2: + build: + context: php-7.2 + volumes: + - ..:/app + network_mode: host + + php-7.3: + build: + context: php-7.3 + volumes: + - ..:/app + network_mode: host + + php-7.4: + build: + context: php-7.4 + volumes: + - ..:/app + network_mode: host + php-8.0: build: context: php-8.0 volumes: - ..:/app + network_mode: host + + php-8.1: + build: + context: php-8.1 + volumes: + - ..:/app network_mode: host \ No newline at end of file diff --git a/build/php-7.0/Dockerfile b/build/php-7.0/Dockerfile index 2962bf0..4ca628f 100644 --- a/build/php-7.0/Dockerfile +++ b/build/php-7.0/Dockerfile @@ -8,7 +8,7 @@ RUN apk update && \ g++ \ make -RUN pecl install xdebug-2.7.2 && \ +RUN pecl install xdebug-2.8.1 && \ pecl clear-cache && \ docker-php-ext-enable xdebug diff --git a/build/php-7.1/Dockerfile b/build/php-7.1/Dockerfile new file mode 100644 index 0000000..690c835 --- /dev/null +++ b/build/php-7.1/Dockerfile @@ -0,0 +1,17 @@ +FROM composer:2.2 as composer +FROM php:7.1-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make + +RUN pecl install xdebug-2.9.8 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-7.1/Makefile b/build/php-7.1/Makefile new file mode 100644 index 0000000..b3a33d3 --- /dev/null +++ b/build/php-7.1/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-7.1 test-php-7.1 test-suite-php-7.1 + +prepare-php-7.1: ## load dependencies with php 7.1 + docker-compose run -T php-7.1 /usr/bin/composer update + +test-php-7.1: prepare-php-7.1 ## run tests against php 7.1 + docker-compose run -T php-7.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-7.1: prepare-php-7.1 ## run suite tests against php 7.1, ex: make test-suite-php-7.1 SUITE="unit" + docker-compose run -T php-7.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-7.2/Dockerfile b/build/php-7.2/Dockerfile new file mode 100644 index 0000000..0876175 --- /dev/null +++ b/build/php-7.2/Dockerfile @@ -0,0 +1,17 @@ +FROM composer:2.2 as composer +FROM php:7.2-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make + +RUN pecl install xdebug-2.9.8 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-7.2/Makefile b/build/php-7.2/Makefile new file mode 100644 index 0000000..46d4374 --- /dev/null +++ b/build/php-7.2/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-7.2 test-php-7.2 test-suite-php-7.2 + +prepare-php-7.2: ## load dependencies with php 7.2 + docker-compose run -T php-7.2 /usr/bin/composer update + +test-php-7.2: prepare-php-7.2 ## run tests against php 7.2 + docker-compose run -T php-7.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-7.2: prepare-php-7.2 ## run suite tests against php 7.2, ex: make test-suite-php-7.2 SUITE="unit" + docker-compose run -T php-7.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-7.3/Dockerfile b/build/php-7.3/Dockerfile new file mode 100644 index 0000000..e2dee2e --- /dev/null +++ b/build/php-7.3/Dockerfile @@ -0,0 +1,17 @@ +FROM composer:2.2 as composer +FROM php:7.3-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make + +RUN pecl install xdebug-2.9.8 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-7.3/Makefile b/build/php-7.3/Makefile new file mode 100644 index 0000000..d866e53 --- /dev/null +++ b/build/php-7.3/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-7.3 test-php-7.3 test-suite-php-7.3 + +prepare-php-7.3: ## load dependencies with php 7.3 + docker-compose run -T php-7.3 /usr/bin/composer update + +test-php-7.3: prepare-php-7.3 ## run tests against php 7.3 + docker-compose run -T php-7.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-7.3: prepare-php-7.3 ## run suite tests against php 7.3, ex: make test-suite-php-7.3 SUITE="unit" + docker-compose run -T php-7.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-7.4/Dockerfile b/build/php-7.4/Dockerfile new file mode 100644 index 0000000..24a17d3 --- /dev/null +++ b/build/php-7.4/Dockerfile @@ -0,0 +1,17 @@ +FROM composer:2.2 as composer +FROM php:7.4-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make + +RUN pecl install xdebug-2.9.8 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-7.4/Makefile b/build/php-7.4/Makefile new file mode 100644 index 0000000..412c121 --- /dev/null +++ b/build/php-7.4/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-7.4 test-php-7.4 test-suite-php-7.4 + +prepare-php-7.4: ## load dependencies with php 7.4 + docker-compose run -T php-7.4 /usr/bin/composer update + +test-php-7.4: prepare-php-7.4 ## run tests against php 7.4 + docker-compose run -T php-7.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-7.4: prepare-php-7.4 ## run suite tests against php 7.4, ex: make test-suite-php-7.4 SUITE="unit" + docker-compose run -T php-7.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-8.0/Dockerfile b/build/php-8.0/Dockerfile index c2916f9..b75744e 100644 --- a/build/php-8.0/Dockerfile +++ b/build/php-8.0/Dockerfile @@ -8,7 +8,7 @@ RUN apk update && \ g++ \ make -RUN pecl install xdebug-3.0.2 && \ +RUN pecl install xdebug-3.1.6 && \ pecl clear-cache && \ docker-php-ext-enable xdebug diff --git a/build/php-8.1/Dockerfile b/build/php-8.1/Dockerfile new file mode 100644 index 0000000..a68b5e2 --- /dev/null +++ b/build/php-8.1/Dockerfile @@ -0,0 +1,17 @@ +FROM composer:latest as composer +FROM php:8.1-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make + +RUN pecl install xdebug-3.1.6 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-8.1/Makefile b/build/php-8.1/Makefile new file mode 100644 index 0000000..517275d --- /dev/null +++ b/build/php-8.1/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-8.1 test-php-8.1 test-suite-php-8.1 + +prepare-php-8.1: ## load dependencies with php 8.1 + docker-compose run -T php-8.1 /usr/bin/composer update + +test-php-8.1: prepare-php-8.1 ## run tests against php 8.1 + docker-compose run -T php-8.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-8.1: prepare-php-8.1 ## run suite tests against php 8.1, ex: make test-suite-php-8.1 SUITE="unit" + docker-compose run -T php-8.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/composer.json b/composer.json index f477dee..d636efe 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": "^7 || ^8.0", + "php": "^7 || ~8.0 || ~8.1", "ext-json": "*", "psr/log": "^1 || ^2 || ^3", "psr/http-message": "^1", @@ -25,7 +25,8 @@ }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6 || ^8", + "phpunit/phpunit": "^6 || ~8.5", + "phpspec/prophecy": "^1.7", "symfony/yaml": "^3", "doctrine/instantiator": "1.0.5 || ^1.4.0", "phpdocumentor/reflection-docblock": "^4.3 || ^5.2.0", From 91cd562487b35d51bda497755a4d152a811d4e11 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 16 Nov 2022 13:58:13 +0100 Subject: [PATCH 51/93] Fixes dynamic property deprecations --- .github/workflows/tests.yml | 35 +++++++++++++++++-- CHANGELOG.md | 2 ++ build/Makefile | 3 ++ build/docker-compose.yml | 7 ++++ build/php-8.2/Dockerfile | 18 ++++++++++ build/php-8.2/Makefile | 10 ++++++ composer.json | 2 +- .../Bag/CreateBlacklistedPhoneNumberBag.php | 1 + .../Bag/DeleteBlacklistedPhoneNumberBag.php | 1 + .../Bag/FindBlacklistedPhoneNumbersBag.php | 1 + src/Feature/Contacts/Bag/CreateContactBag.php | 1 + src/Feature/Contacts/Bag/DeleteContactBag.php | 1 + src/Feature/Contacts/Bag/FindContactBag.php | 1 + src/Feature/Contacts/Bag/FindContactsBag.php | 1 + src/Feature/Contacts/Bag/UpdateContactBag.php | 1 + .../Fields/Bag/CreateContactFieldBag.php | 1 + .../Fields/Bag/DeleteContactFieldBag.php | 1 + .../Fields/Bag/FindContactFieldOptionsBag.php | 1 + .../Fields/Bag/UpdateContactFieldBag.php | 1 + .../Groups/Bag/AssignContactToGroupBag.php | 1 + .../Contacts/Groups/Bag/CreateGroupBag.php | 1 + .../Contacts/Groups/Bag/DeleteGroupBag.php | 1 + .../Groups/Bag/FindContactGroupBag.php | 1 + .../Groups/Bag/FindContactGroupsBag.php | 1 + .../Contacts/Groups/Bag/FindGroupBag.php | 1 + .../Groups/Bag/UnpinContactFromGroupBag.php | 1 + .../Contacts/Groups/Bag/UpdateGroupBag.php | 1 + .../Bag/AddContactToGroupByQueryBag.php | 1 + .../Members/Bag/FindContactInGroupBag.php | 1 + .../Bag/MoveContactToGroupByQueryBag.php | 1 + .../Members/Bag/PinContactToGroupBag.php | 1 + .../Members/Bag/UnpinContactFromGroupBag.php | 1 + .../Bag/UnpinContactFromGroupByQueryBag.php | 1 + .../Bag/CreateGroupPermissionBag.php | 1 + .../Bag/DeleteGroupPermissionBag.php | 1 + .../Bag/FindGroupPermissionBag.php | 1 + .../Bag/FindGroupPermissionsBag.php | 1 + .../Bag/UpdateGroupPermissionBag.php | 1 + src/Feature/Hlr/Bag/SendHlrBag.php | 1 + src/Feature/Mfa/Bag/CreateMfaBag.php | 1 + src/Feature/Mfa/Bag/VerificationMfaBag.php | 1 + src/Feature/Mms/Bag/SendMmsBag.php | 1 + .../ShortUrl/Bag/CreateShortUrlLinkBag.php | 3 +- .../Sms/Bag/DeleteScheduledSmssBag.php | 4 +++ src/Feature/Sms/Bag/ScheduleSmsBag.php | 1 + src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php | 1 + src/Feature/Sms/Bag/ScheduleSmssBag.php | 1 + src/Feature/Sms/Bag/SendSmsBag.php | 1 + src/Feature/Sms/Bag/SendSmsToGroupBag.php | 1 + src/Feature/Sms/Bag/SendSmssBag.php | 1 + .../Sendernames/Bag/CreateSendernameBag.php | 1 + .../Sendernames/Bag/DeleteSendernameBag.php | 1 + .../Sms/Sendernames/Bag/FindSendernameBag.php | 1 + .../Bag/MakeSendernameDefaultBag.php | 1 + src/Feature/Subusers/Bag/CreateSubuserBag.php | 1 + src/Feature/Subusers/Bag/DeleteSubuserBag.php | 1 + src/Feature/Subusers/Bag/UpdateSubuserBag.php | 1 + src/Feature/Vms/Bag/SendVmsBag.php | 1 + 58 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 build/php-8.2/Dockerfile create mode 100644 build/php-8.2/Makefile diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6d4fa90..a00ac7e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ on: jobs: tests: - name: PHP ${{ matrix.php }} / ${{ matrix.dependency-version }} + name: PHP ${{ matrix.php }} runs-on: ubuntu-latest strategy: matrix: @@ -37,10 +37,41 @@ jobs: uses: actions/cache@v2 with: path: ${{ steps.composer-cache.outputs.dir }} - key: composer-${{ runner.os }}-${{ matrix.php }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }} + key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.json') }} - name: Install dependencies run: composer update --prefer-dist --no-interaction - name: Running unit tests run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit + + tests-rc: + name: PHP ${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + matrix: + php: + - 8.2 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.json') }} + + - name: Install dependencies + run: composer update --prefer-dist --no-interaction --ignore-platform-req=PHP + + - name: Running unit tests + run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 67f292b..94cbde5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- dynamic property deprecations ## [3.0.6] - 2022-03-28 ### Fixed diff --git a/build/Makefile b/build/Makefile index 301709d..5f5b75e 100644 --- a/build/Makefile +++ b/build/Makefile @@ -7,6 +7,7 @@ include $(CURDIR)/php-7.3/Makefile include $(CURDIR)/php-7.4/Makefile include $(CURDIR)/php-8.0/Makefile include $(CURDIR)/php-8.1/Makefile +include $(CURDIR)/php-8.2/Makefile help: @grep -hE '^[a-zA-Z0-9_.-]+:.*?## .*$$' $(MAKEFILE_LIST) \ @@ -24,6 +25,7 @@ test: ## test all against all php images $(MAKE) test-php-7.4 $(MAKE) test-php-8.0 $(MAKE) test-php-8.1 + $(MAKE) test-php-8.2 test-unit: ## test unit suite against all php images $(MAKE) test-suite-php-7.0 SUITE=unit @@ -33,5 +35,6 @@ test-unit: ## test unit suite against all php images $(MAKE) test-suite-php-7.4 SUITE=unit $(MAKE) test-suite-php-8.0 SUITE=unit $(MAKE) test-suite-php-8.1 SUITE=unit + $(MAKE) test-suite-php-8.2 SUITE=unit .DEFAULT_GOAL := help diff --git a/build/docker-compose.yml b/build/docker-compose.yml index 4686555..400c527 100644 --- a/build/docker-compose.yml +++ b/build/docker-compose.yml @@ -49,4 +49,11 @@ services: context: php-8.1 volumes: - ..:/app + network_mode: host + + php-8.2: + build: + context: php-8.2 + volumes: + - ..:/app network_mode: host \ No newline at end of file diff --git a/build/php-8.2/Dockerfile b/build/php-8.2/Dockerfile new file mode 100644 index 0000000..7ddc48f --- /dev/null +++ b/build/php-8.2/Dockerfile @@ -0,0 +1,18 @@ +FROM composer:latest as composer +FROM php:8.2-rc-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make \ + linux-headers + +RUN pecl install xdebug-3.2.0RC2 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-8.2/Makefile b/build/php-8.2/Makefile new file mode 100644 index 0000000..7d07aca --- /dev/null +++ b/build/php-8.2/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-8.2 test-php-8.2 test-suite-php-8.2 + +prepare-php-8.2: ## load dependencies with php 8.2 + docker-compose run -T php-8.2 /usr/bin/composer update --ignore-platform-req=PHP + +test-php-8.2: prepare-php-8.2 ## run tests against php 8.2 + docker-compose run -T php-8.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-8.2: prepare-php-8.2 ## run suite tests against php 8.2, ex: make test-suite-php-8.2 SUITE="unit" + docker-compose run -T php-8.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/composer.json b/composer.json index d636efe..7b4119b 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": "^7 || ~8.0 || ~8.1", + "php": "^7 || ~8.0 || ~8.1 || ~8.2", "ext-json": "*", "psr/log": "^1 || ^2 || ^3", "psr/http-message": "^1", diff --git a/src/Feature/Blacklist/Bag/CreateBlacklistedPhoneNumberBag.php b/src/Feature/Blacklist/Bag/CreateBlacklistedPhoneNumberBag.php index f51be56..571ef95 100644 --- a/src/Feature/Blacklist/Bag/CreateBlacklistedPhoneNumberBag.php +++ b/src/Feature/Blacklist/Bag/CreateBlacklistedPhoneNumberBag.php @@ -10,6 +10,7 @@ * @api * @property DateTimeInterface $expireAt */ +#[\AllowDynamicProperties] class CreateBlacklistedPhoneNumberBag { /** @var string */ diff --git a/src/Feature/Blacklist/Bag/DeleteBlacklistedPhoneNumberBag.php b/src/Feature/Blacklist/Bag/DeleteBlacklistedPhoneNumberBag.php index cdeb83b..e7ebf9e 100644 --- a/src/Feature/Blacklist/Bag/DeleteBlacklistedPhoneNumberBag.php +++ b/src/Feature/Blacklist/Bag/DeleteBlacklistedPhoneNumberBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class DeleteBlacklistedPhoneNumberBag { /** @var string */ diff --git a/src/Feature/Blacklist/Bag/FindBlacklistedPhoneNumbersBag.php b/src/Feature/Blacklist/Bag/FindBlacklistedPhoneNumbersBag.php index 635f79f..4e3fbee 100644 --- a/src/Feature/Blacklist/Bag/FindBlacklistedPhoneNumbersBag.php +++ b/src/Feature/Blacklist/Bag/FindBlacklistedPhoneNumbersBag.php @@ -10,6 +10,7 @@ * @api * @property string $q */ +#[\AllowDynamicProperties] class FindBlacklistedPhoneNumbersBag { use PaginationBag; diff --git a/src/Feature/Contacts/Bag/CreateContactBag.php b/src/Feature/Contacts/Bag/CreateContactBag.php index 1c67efb..54ffd65 100644 --- a/src/Feature/Contacts/Bag/CreateContactBag.php +++ b/src/Feature/Contacts/Bag/CreateContactBag.php @@ -16,6 +16,7 @@ * @property string $city * @property string $source */ +#[\AllowDynamicProperties] class CreateContactBag { /** diff --git a/src/Feature/Contacts/Bag/DeleteContactBag.php b/src/Feature/Contacts/Bag/DeleteContactBag.php index dacee6d..a3363c0 100644 --- a/src/Feature/Contacts/Bag/DeleteContactBag.php +++ b/src/Feature/Contacts/Bag/DeleteContactBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class DeleteContactBag { diff --git a/src/Feature/Contacts/Bag/FindContactBag.php b/src/Feature/Contacts/Bag/FindContactBag.php index 6198a1d..157a6bb 100644 --- a/src/Feature/Contacts/Bag/FindContactBag.php +++ b/src/Feature/Contacts/Bag/FindContactBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindContactBag { diff --git a/src/Feature/Contacts/Bag/FindContactsBag.php b/src/Feature/Contacts/Bag/FindContactsBag.php index ea83eb2..e75445b 100644 --- a/src/Feature/Contacts/Bag/FindContactsBag.php +++ b/src/Feature/Contacts/Bag/FindContactsBag.php @@ -18,6 +18,7 @@ * @property string $gender * @property string $birthdayDate */ +#[\AllowDynamicProperties] class FindContactsBag { use PaginationBag; diff --git a/src/Feature/Contacts/Bag/UpdateContactBag.php b/src/Feature/Contacts/Bag/UpdateContactBag.php index bfeed43..4458055 100644 --- a/src/Feature/Contacts/Bag/UpdateContactBag.php +++ b/src/Feature/Contacts/Bag/UpdateContactBag.php @@ -16,6 +16,7 @@ * @property string $city * @property string $source */ +#[\AllowDynamicProperties] class UpdateContactBag { diff --git a/src/Feature/Contacts/Fields/Bag/CreateContactFieldBag.php b/src/Feature/Contacts/Fields/Bag/CreateContactFieldBag.php index 1a45b1c..2269dcc 100644 --- a/src/Feature/Contacts/Fields/Bag/CreateContactFieldBag.php +++ b/src/Feature/Contacts/Fields/Bag/CreateContactFieldBag.php @@ -8,6 +8,7 @@ * @api * @property string $type */ +#[\AllowDynamicProperties] class CreateContactFieldBag { diff --git a/src/Feature/Contacts/Fields/Bag/DeleteContactFieldBag.php b/src/Feature/Contacts/Fields/Bag/DeleteContactFieldBag.php index ecdaabb..cbbb706 100644 --- a/src/Feature/Contacts/Fields/Bag/DeleteContactFieldBag.php +++ b/src/Feature/Contacts/Fields/Bag/DeleteContactFieldBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class DeleteContactFieldBag { diff --git a/src/Feature/Contacts/Fields/Bag/FindContactFieldOptionsBag.php b/src/Feature/Contacts/Fields/Bag/FindContactFieldOptionsBag.php index e48acc9..adf4d6d 100644 --- a/src/Feature/Contacts/Fields/Bag/FindContactFieldOptionsBag.php +++ b/src/Feature/Contacts/Fields/Bag/FindContactFieldOptionsBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindContactFieldOptionsBag { diff --git a/src/Feature/Contacts/Fields/Bag/UpdateContactFieldBag.php b/src/Feature/Contacts/Fields/Bag/UpdateContactFieldBag.php index 1dd2024..0e5cdbd 100644 --- a/src/Feature/Contacts/Fields/Bag/UpdateContactFieldBag.php +++ b/src/Feature/Contacts/Fields/Bag/UpdateContactFieldBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class UpdateContactFieldBag { diff --git a/src/Feature/Contacts/Groups/Bag/AssignContactToGroupBag.php b/src/Feature/Contacts/Groups/Bag/AssignContactToGroupBag.php index f4124ad..b51723e 100644 --- a/src/Feature/Contacts/Groups/Bag/AssignContactToGroupBag.php +++ b/src/Feature/Contacts/Groups/Bag/AssignContactToGroupBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class AssignContactToGroupBag { diff --git a/src/Feature/Contacts/Groups/Bag/CreateGroupBag.php b/src/Feature/Contacts/Groups/Bag/CreateGroupBag.php index 4770a7c..80e934a 100644 --- a/src/Feature/Contacts/Groups/Bag/CreateGroupBag.php +++ b/src/Feature/Contacts/Groups/Bag/CreateGroupBag.php @@ -10,6 +10,7 @@ * @property string $idx * @property integer $contactExpireAfter */ +#[\AllowDynamicProperties] class CreateGroupBag { diff --git a/src/Feature/Contacts/Groups/Bag/DeleteGroupBag.php b/src/Feature/Contacts/Groups/Bag/DeleteGroupBag.php index d6f1bdf..cf7da05 100644 --- a/src/Feature/Contacts/Groups/Bag/DeleteGroupBag.php +++ b/src/Feature/Contacts/Groups/Bag/DeleteGroupBag.php @@ -8,6 +8,7 @@ * @api * @property bool $deleteContacts */ +#[\AllowDynamicProperties] class DeleteGroupBag { diff --git a/src/Feature/Contacts/Groups/Bag/FindContactGroupBag.php b/src/Feature/Contacts/Groups/Bag/FindContactGroupBag.php index 3c4c8e6..2ecfb43 100644 --- a/src/Feature/Contacts/Groups/Bag/FindContactGroupBag.php +++ b/src/Feature/Contacts/Groups/Bag/FindContactGroupBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindContactGroupBag { diff --git a/src/Feature/Contacts/Groups/Bag/FindContactGroupsBag.php b/src/Feature/Contacts/Groups/Bag/FindContactGroupsBag.php index 9ff20f4..053a7bc 100644 --- a/src/Feature/Contacts/Groups/Bag/FindContactGroupsBag.php +++ b/src/Feature/Contacts/Groups/Bag/FindContactGroupsBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindContactGroupsBag { diff --git a/src/Feature/Contacts/Groups/Bag/FindGroupBag.php b/src/Feature/Contacts/Groups/Bag/FindGroupBag.php index 3b17dd4..b169b8a 100644 --- a/src/Feature/Contacts/Groups/Bag/FindGroupBag.php +++ b/src/Feature/Contacts/Groups/Bag/FindGroupBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindGroupBag { diff --git a/src/Feature/Contacts/Groups/Bag/UnpinContactFromGroupBag.php b/src/Feature/Contacts/Groups/Bag/UnpinContactFromGroupBag.php index 550b81d..3b9000d 100644 --- a/src/Feature/Contacts/Groups/Bag/UnpinContactFromGroupBag.php +++ b/src/Feature/Contacts/Groups/Bag/UnpinContactFromGroupBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class UnpinContactFromGroupBag { diff --git a/src/Feature/Contacts/Groups/Bag/UpdateGroupBag.php b/src/Feature/Contacts/Groups/Bag/UpdateGroupBag.php index ca9a3e4..2eb918f 100644 --- a/src/Feature/Contacts/Groups/Bag/UpdateGroupBag.php +++ b/src/Feature/Contacts/Groups/Bag/UpdateGroupBag.php @@ -10,6 +10,7 @@ * @property string $idx * @property integer $contactExpireAfter */ +#[\AllowDynamicProperties] class UpdateGroupBag { diff --git a/src/Feature/Contacts/Groups/Members/Bag/AddContactToGroupByQueryBag.php b/src/Feature/Contacts/Groups/Members/Bag/AddContactToGroupByQueryBag.php index 5d63613..a8ee959 100644 --- a/src/Feature/Contacts/Groups/Members/Bag/AddContactToGroupByQueryBag.php +++ b/src/Feature/Contacts/Groups/Members/Bag/AddContactToGroupByQueryBag.php @@ -15,6 +15,7 @@ * @property string $gender * @property string $birthdayDate */ +#[\AllowDynamicProperties] class AddContactToGroupByQueryBag { diff --git a/src/Feature/Contacts/Groups/Members/Bag/FindContactInGroupBag.php b/src/Feature/Contacts/Groups/Members/Bag/FindContactInGroupBag.php index ffa7b02..9238eaa 100644 --- a/src/Feature/Contacts/Groups/Members/Bag/FindContactInGroupBag.php +++ b/src/Feature/Contacts/Groups/Members/Bag/FindContactInGroupBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindContactInGroupBag { diff --git a/src/Feature/Contacts/Groups/Members/Bag/MoveContactToGroupByQueryBag.php b/src/Feature/Contacts/Groups/Members/Bag/MoveContactToGroupByQueryBag.php index c7591b5..2d88a19 100644 --- a/src/Feature/Contacts/Groups/Members/Bag/MoveContactToGroupByQueryBag.php +++ b/src/Feature/Contacts/Groups/Members/Bag/MoveContactToGroupByQueryBag.php @@ -15,6 +15,7 @@ * @property string $gender * @property string $birthdayDate */ +#[\AllowDynamicProperties] class MoveContactToGroupByQueryBag { diff --git a/src/Feature/Contacts/Groups/Members/Bag/PinContactToGroupBag.php b/src/Feature/Contacts/Groups/Members/Bag/PinContactToGroupBag.php index be2f10a..9fe9cbb 100644 --- a/src/Feature/Contacts/Groups/Members/Bag/PinContactToGroupBag.php +++ b/src/Feature/Contacts/Groups/Members/Bag/PinContactToGroupBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class PinContactToGroupBag { diff --git a/src/Feature/Contacts/Groups/Members/Bag/UnpinContactFromGroupBag.php b/src/Feature/Contacts/Groups/Members/Bag/UnpinContactFromGroupBag.php index 992a168..50cde48 100644 --- a/src/Feature/Contacts/Groups/Members/Bag/UnpinContactFromGroupBag.php +++ b/src/Feature/Contacts/Groups/Members/Bag/UnpinContactFromGroupBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class UnpinContactFromGroupBag { diff --git a/src/Feature/Contacts/Groups/Members/Bag/UnpinContactFromGroupByQueryBag.php b/src/Feature/Contacts/Groups/Members/Bag/UnpinContactFromGroupByQueryBag.php index a7a8cd3..e36d5c8 100644 --- a/src/Feature/Contacts/Groups/Members/Bag/UnpinContactFromGroupByQueryBag.php +++ b/src/Feature/Contacts/Groups/Members/Bag/UnpinContactFromGroupByQueryBag.php @@ -15,6 +15,7 @@ * @property string $gender * @property string $birthdayDate */ +#[\AllowDynamicProperties] class UnpinContactFromGroupByQueryBag { diff --git a/src/Feature/Contacts/Groups/Permissions/Bag/CreateGroupPermissionBag.php b/src/Feature/Contacts/Groups/Permissions/Bag/CreateGroupPermissionBag.php index 6305d3e..e48404a 100644 --- a/src/Feature/Contacts/Groups/Permissions/Bag/CreateGroupPermissionBag.php +++ b/src/Feature/Contacts/Groups/Permissions/Bag/CreateGroupPermissionBag.php @@ -10,6 +10,7 @@ * @property string $write * @property string $send */ +#[\AllowDynamicProperties] class CreateGroupPermissionBag { diff --git a/src/Feature/Contacts/Groups/Permissions/Bag/DeleteGroupPermissionBag.php b/src/Feature/Contacts/Groups/Permissions/Bag/DeleteGroupPermissionBag.php index f6ba1f2..591cad1 100644 --- a/src/Feature/Contacts/Groups/Permissions/Bag/DeleteGroupPermissionBag.php +++ b/src/Feature/Contacts/Groups/Permissions/Bag/DeleteGroupPermissionBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class DeleteGroupPermissionBag { diff --git a/src/Feature/Contacts/Groups/Permissions/Bag/FindGroupPermissionBag.php b/src/Feature/Contacts/Groups/Permissions/Bag/FindGroupPermissionBag.php index 4c285e0..150efff 100644 --- a/src/Feature/Contacts/Groups/Permissions/Bag/FindGroupPermissionBag.php +++ b/src/Feature/Contacts/Groups/Permissions/Bag/FindGroupPermissionBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindGroupPermissionBag { diff --git a/src/Feature/Contacts/Groups/Permissions/Bag/FindGroupPermissionsBag.php b/src/Feature/Contacts/Groups/Permissions/Bag/FindGroupPermissionsBag.php index e7d2327..384d47e 100644 --- a/src/Feature/Contacts/Groups/Permissions/Bag/FindGroupPermissionsBag.php +++ b/src/Feature/Contacts/Groups/Permissions/Bag/FindGroupPermissionsBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindGroupPermissionsBag { diff --git a/src/Feature/Contacts/Groups/Permissions/Bag/UpdateGroupPermissionBag.php b/src/Feature/Contacts/Groups/Permissions/Bag/UpdateGroupPermissionBag.php index 4a807e4..54fd14e 100644 --- a/src/Feature/Contacts/Groups/Permissions/Bag/UpdateGroupPermissionBag.php +++ b/src/Feature/Contacts/Groups/Permissions/Bag/UpdateGroupPermissionBag.php @@ -10,6 +10,7 @@ * @property string $write * @property string $send */ +#[\AllowDynamicProperties] class UpdateGroupPermissionBag { diff --git a/src/Feature/Hlr/Bag/SendHlrBag.php b/src/Feature/Hlr/Bag/SendHlrBag.php index fa7428a..991fc60 100644 --- a/src/Feature/Hlr/Bag/SendHlrBag.php +++ b/src/Feature/Hlr/Bag/SendHlrBag.php @@ -8,6 +8,7 @@ * @api * @property string $idx */ +#[\AllowDynamicProperties] class SendHlrBag { diff --git a/src/Feature/Mfa/Bag/CreateMfaBag.php b/src/Feature/Mfa/Bag/CreateMfaBag.php index 05036be..bafdac6 100644 --- a/src/Feature/Mfa/Bag/CreateMfaBag.php +++ b/src/Feature/Mfa/Bag/CreateMfaBag.php @@ -10,6 +10,7 @@ * @property string $content * @property bool $fast */ +#[\AllowDynamicProperties] class CreateMfaBag { /** diff --git a/src/Feature/Mfa/Bag/VerificationMfaBag.php b/src/Feature/Mfa/Bag/VerificationMfaBag.php index f1c8a7c..ba371e4 100644 --- a/src/Feature/Mfa/Bag/VerificationMfaBag.php +++ b/src/Feature/Mfa/Bag/VerificationMfaBag.php @@ -7,6 +7,7 @@ /** * @api */ +#[\AllowDynamicProperties] class VerificationMfaBag { /** diff --git a/src/Feature/Mms/Bag/SendMmsBag.php b/src/Feature/Mms/Bag/SendMmsBag.php index e3ce33a..6db03e1 100644 --- a/src/Feature/Mms/Bag/SendMmsBag.php +++ b/src/Feature/Mms/Bag/SendMmsBag.php @@ -7,6 +7,7 @@ * @api * @property bool $test */ +#[\AllowDynamicProperties] class SendMmsBag { diff --git a/src/Feature/ShortUrl/Bag/CreateShortUrlLinkBag.php b/src/Feature/ShortUrl/Bag/CreateShortUrlLinkBag.php index 7452f19..05b5e94 100644 --- a/src/Feature/ShortUrl/Bag/CreateShortUrlLinkBag.php +++ b/src/Feature/ShortUrl/Bag/CreateShortUrlLinkBag.php @@ -14,12 +14,13 @@ * @property DateTimeInterface $expire * @property string $description */ +#[\AllowDynamicProperties] class CreateShortUrlLinkBag { public static function withUrl(string $url): self { - $bag = new self(); + $bag = new CreateShortUrlLinkBag(); $bag->url = $url; return $bag; } diff --git a/src/Feature/Sms/Bag/DeleteScheduledSmssBag.php b/src/Feature/Sms/Bag/DeleteScheduledSmssBag.php index 748a5e6..51f6a09 100644 --- a/src/Feature/Sms/Bag/DeleteScheduledSmssBag.php +++ b/src/Feature/Sms/Bag/DeleteScheduledSmssBag.php @@ -4,6 +4,10 @@ namespace Smsapi\Client\Feature\Sms\Bag; +/** + * @api + */ +#[\AllowDynamicProperties] class DeleteScheduledSmssBag { /** @var array */ diff --git a/src/Feature/Sms/Bag/ScheduleSmsBag.php b/src/Feature/Sms/Bag/ScheduleSmsBag.php index dc328e9..443bbb5 100644 --- a/src/Feature/Sms/Bag/ScheduleSmsBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmsBag.php @@ -25,6 +25,7 @@ * @property string $param3 * @property string $param4 */ +#[\AllowDynamicProperties] class ScheduleSmsBag { /** @var string */ diff --git a/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php b/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php index 0b39fa5..28e138d 100644 --- a/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php @@ -21,6 +21,7 @@ * @property string $notifyUrl * @property bool $test */ +#[\AllowDynamicProperties] class ScheduleSmsToGroupBag { diff --git a/src/Feature/Sms/Bag/ScheduleSmssBag.php b/src/Feature/Sms/Bag/ScheduleSmssBag.php index 3e5fd10..b6fda24 100644 --- a/src/Feature/Sms/Bag/ScheduleSmssBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmssBag.php @@ -26,6 +26,7 @@ * @property array $param3 * @property array $param4 */ +#[\AllowDynamicProperties] class ScheduleSmssBag { /** @var array */ diff --git a/src/Feature/Sms/Bag/SendSmsBag.php b/src/Feature/Sms/Bag/SendSmsBag.php index 181a00f..23b0400 100644 --- a/src/Feature/Sms/Bag/SendSmsBag.php +++ b/src/Feature/Sms/Bag/SendSmsBag.php @@ -25,6 +25,7 @@ * @property string $param3 * @property string $param4 */ +#[\AllowDynamicProperties] class SendSmsBag { /** @var string */ diff --git a/src/Feature/Sms/Bag/SendSmsToGroupBag.php b/src/Feature/Sms/Bag/SendSmsToGroupBag.php index 52adfdf..e462bbe 100644 --- a/src/Feature/Sms/Bag/SendSmsToGroupBag.php +++ b/src/Feature/Sms/Bag/SendSmsToGroupBag.php @@ -20,6 +20,7 @@ * @property string $notifyUrl * @property bool $test */ +#[\AllowDynamicProperties] class SendSmsToGroupBag { /** @var string */ diff --git a/src/Feature/Sms/Bag/SendSmssBag.php b/src/Feature/Sms/Bag/SendSmssBag.php index fddbf5b..53dc09b 100644 --- a/src/Feature/Sms/Bag/SendSmssBag.php +++ b/src/Feature/Sms/Bag/SendSmssBag.php @@ -26,6 +26,7 @@ * @property array $param3 * @property array $param4 */ +#[\AllowDynamicProperties] class SendSmssBag { /** @var array */ diff --git a/src/Feature/Sms/Sendernames/Bag/CreateSendernameBag.php b/src/Feature/Sms/Sendernames/Bag/CreateSendernameBag.php index 81d6f10..09d40c1 100644 --- a/src/Feature/Sms/Sendernames/Bag/CreateSendernameBag.php +++ b/src/Feature/Sms/Sendernames/Bag/CreateSendernameBag.php @@ -6,6 +6,7 @@ /** * @api */ +#[\AllowDynamicProperties] class CreateSendernameBag { public $sender; diff --git a/src/Feature/Sms/Sendernames/Bag/DeleteSendernameBag.php b/src/Feature/Sms/Sendernames/Bag/DeleteSendernameBag.php index 9f54dde..8e34293 100644 --- a/src/Feature/Sms/Sendernames/Bag/DeleteSendernameBag.php +++ b/src/Feature/Sms/Sendernames/Bag/DeleteSendernameBag.php @@ -6,6 +6,7 @@ /** * @api */ +#[\AllowDynamicProperties] class DeleteSendernameBag { public $sender; diff --git a/src/Feature/Sms/Sendernames/Bag/FindSendernameBag.php b/src/Feature/Sms/Sendernames/Bag/FindSendernameBag.php index cf4e58e..60abde0 100644 --- a/src/Feature/Sms/Sendernames/Bag/FindSendernameBag.php +++ b/src/Feature/Sms/Sendernames/Bag/FindSendernameBag.php @@ -6,6 +6,7 @@ /** * @api */ +#[\AllowDynamicProperties] class FindSendernameBag { public $sender; diff --git a/src/Feature/Sms/Sendernames/Bag/MakeSendernameDefaultBag.php b/src/Feature/Sms/Sendernames/Bag/MakeSendernameDefaultBag.php index 28539af..991e2d0 100644 --- a/src/Feature/Sms/Sendernames/Bag/MakeSendernameDefaultBag.php +++ b/src/Feature/Sms/Sendernames/Bag/MakeSendernameDefaultBag.php @@ -6,6 +6,7 @@ /** * @api */ +#[\AllowDynamicProperties] class MakeSendernameDefaultBag { public $sender; diff --git a/src/Feature/Subusers/Bag/CreateSubuserBag.php b/src/Feature/Subusers/Bag/CreateSubuserBag.php index 2ea4249..a45cb3c 100644 --- a/src/Feature/Subusers/Bag/CreateSubuserBag.php +++ b/src/Feature/Subusers/Bag/CreateSubuserBag.php @@ -8,6 +8,7 @@ * @property bool $active * @property string $description */ +#[\AllowDynamicProperties] class CreateSubuserBag { /** @var string */ diff --git a/src/Feature/Subusers/Bag/DeleteSubuserBag.php b/src/Feature/Subusers/Bag/DeleteSubuserBag.php index 65edc86..b5c741c 100644 --- a/src/Feature/Subusers/Bag/DeleteSubuserBag.php +++ b/src/Feature/Subusers/Bag/DeleteSubuserBag.php @@ -6,6 +6,7 @@ /** * @api */ +#[\AllowDynamicProperties] class DeleteSubuserBag { public $id; diff --git a/src/Feature/Subusers/Bag/UpdateSubuserBag.php b/src/Feature/Subusers/Bag/UpdateSubuserBag.php index f7eea08..fff8f26 100644 --- a/src/Feature/Subusers/Bag/UpdateSubuserBag.php +++ b/src/Feature/Subusers/Bag/UpdateSubuserBag.php @@ -11,6 +11,7 @@ * @property bool $active * @property string $description */ +#[\AllowDynamicProperties] class UpdateSubuserBag { /** @var string */ diff --git a/src/Feature/Vms/Bag/SendVmsBag.php b/src/Feature/Vms/Bag/SendVmsBag.php index a194a28..ef88cef 100644 --- a/src/Feature/Vms/Bag/SendVmsBag.php +++ b/src/Feature/Vms/Bag/SendVmsBag.php @@ -13,6 +13,7 @@ * @property bool $checkIdx * @property bool $test */ +#[\AllowDynamicProperties] class SendVmsBag { From 2a77cfac2adc3b52fe8764a30219d0e67dc9a2c1 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 21 Nov 2022 16:55:18 +0100 Subject: [PATCH 52/93] Releases version 3.0.7 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94cbde5..1c8226f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.7] - 2022-11-21 ### Fixed - dynamic property deprecations diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..f90669e 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.7'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 97bf28202df9be8626cfc5e1d709dc143b69a8c9 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 27 Mar 2023 10:27:19 +0200 Subject: [PATCH 53/93] Adds PHP 8.2 to tests platform matrix --- .github/workflows/tests.yml | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a00ac7e..aae4263 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,6 +21,7 @@ jobs: - 7.4 - 8.0 - 8.1 + - 8.2 steps: - name: Checkout uses: actions/checkout@v2 @@ -44,34 +45,3 @@ jobs: - name: Running unit tests run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit - - tests-rc: - name: PHP ${{ matrix.php }} - runs-on: ubuntu-latest - strategy: - matrix: - php: - - 8.2 - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - - - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.json') }} - - - name: Install dependencies - run: composer update --prefer-dist --no-interaction --ignore-platform-req=PHP - - - name: Running unit tests - run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit \ No newline at end of file From 9b507d40c5d346783700f818cb39047c15ce73e9 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 27 Mar 2023 10:29:39 +0200 Subject: [PATCH 54/93] Adds PHP 8.2 to tests platform matrix --- CHANGELOG.md | 2 ++ src/SmsapiClient.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c8226f..cb4e035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + ## [3.0.7] - 2022-11-21 ### Fixed - dynamic property deprecations diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index f90669e..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.7'; + const VERSION = 'Unreleased'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 54e538f71f0023c7e3e74ef0c1a091ccf8bf9fee Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 27 Mar 2023 10:58:44 +0200 Subject: [PATCH 55/93] Updates actions/checkout, NodeJS depreciation issue --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aae4263..6089cdc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,7 +24,7 @@ jobs: - 8.2 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 From a1a5a934f3244b7e6d7607c5ddf9ed38121ae1e2 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 27 Mar 2023 11:01:30 +0200 Subject: [PATCH 56/93] Updates actions/cache, NodeJS depreciation issue --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6089cdc..d8b9a6f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,7 +35,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.json') }} From 6bf1ba632b20c132ec8fba63deb58f44664e2f4a Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 27 Mar 2023 13:22:52 +0200 Subject: [PATCH 57/93] Updates composer cache GA, set-output depreciation issue --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d8b9a6f..204e766 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: php-version: ${{ matrix.php }} - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer dependencies uses: actions/cache@v3 From 96fef9c9bff8b279364548f79953dbf8b44f30dc Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 17 Apr 2023 13:43:56 +0200 Subject: [PATCH 58/93] Fixes build status badge --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f74457..bcd54ec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SMSAPI PHP Client -[![Build Status](https://travis-ci.org/smsapi/smsapi-php-client.svg?branch=master)](https://travis-ci.org/smsapi/smsapi-php-client) +[![Build Status](https://github.com/smsapi/smsapi-php-client/actions/workflows/tests.yml/badge.svg)](https://github.com/smsapi/smsapi-php-client/actions/workflows/tests.yml) [![Packagist - latest version](https://img.shields.io/packagist/v/smsapi/php-client.svg)](https://packagist.org/packages/smsapi/php-client) [![Packagist - downloads](https://img.shields.io/packagist/dt/smsapi/php-client.svg)](https://packagist.org/packages/smsapi/php-client) [![Packagist - license](https://img.shields.io/packagist/l/smsapi/php-client.svg)](https://packagist.org/packages/smsapi/php-client) @@ -276,7 +276,7 @@ Copy `tests-resources/config/config.dist.yml` to `tests-resources/config/config. ### How to run unit tests -Unit tests are included into package build process and run against its current version on every commit (see `.travis.yml`). +Unit tests are included into package build process and run against its current version on every commit (see workflow Tests). You can run those tests locally with ease using provided Docker configuration, simply run: ```shell From fb1973e21e755ce489b451a78f079850c8a4ebf9 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 3 Oct 2023 15:35:22 +0200 Subject: [PATCH 59/93] Removes xdebug from PHP 7.0 test image. PHP 7.0 compatible xdebug has been removed from PECL. Cannot find replacement. --- build/php-7.0/Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build/php-7.0/Dockerfile b/build/php-7.0/Dockerfile index 4ca628f..ed516f7 100644 --- a/build/php-7.0/Dockerfile +++ b/build/php-7.0/Dockerfile @@ -8,10 +8,6 @@ RUN apk update && \ g++ \ make -RUN pecl install xdebug-2.8.1 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug - COPY --from=composer /usr/bin/composer /usr/bin/composer WORKDIR /app/ \ No newline at end of file From 267e149ffe5a325c6afae737a762124f9958ea47 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 3 Oct 2023 15:37:44 +0200 Subject: [PATCH 60/93] Upgrades PHP image and related xdebug for PHP 8.2 test image to stable version --- build/php-8.2/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/php-8.2/Dockerfile b/build/php-8.2/Dockerfile index 7ddc48f..9092d51 100644 --- a/build/php-8.2/Dockerfile +++ b/build/php-8.2/Dockerfile @@ -1,5 +1,5 @@ FROM composer:latest as composer -FROM php:8.2-rc-cli-alpine +FROM php:8.2-cli-alpine RUN apk update && \ apk upgrade && \ @@ -9,7 +9,7 @@ RUN apk update && \ make \ linux-headers -RUN pecl install xdebug-3.2.0RC2 && \ +RUN pecl install xdebug-3.2.2 && \ pecl clear-cache && \ docker-php-ext-enable xdebug From 0416ecb87f16ddce1efa55dab0982ce85016f76c Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 4 Oct 2023 10:10:51 +0200 Subject: [PATCH 61/93] Runs test against incoming PHP 8.3 --- .github/workflows/tests.yml | 31 +++++++++++++++++++++++++++++++ build/Makefile | 3 +++ build/docker-compose.yml | 7 +++++++ build/php-8.3/Dockerfile | 18 ++++++++++++++++++ build/php-8.3/Makefile | 10 ++++++++++ 5 files changed, 69 insertions(+) create mode 100644 build/php-8.3/Dockerfile create mode 100644 build/php-8.3/Makefile diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 204e766..95f3d3e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,3 +45,34 @@ jobs: - name: Running unit tests run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit + + tests-rc: + name: PHP ${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + matrix: + php: + - 8.3 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.json') }} + + - name: Install dependencies + run: composer update --prefer-dist --no-interaction --ignore-platform-req=PHP + + - name: Running unit tests + run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit \ No newline at end of file diff --git a/build/Makefile b/build/Makefile index 5f5b75e..21b9005 100644 --- a/build/Makefile +++ b/build/Makefile @@ -8,6 +8,7 @@ include $(CURDIR)/php-7.4/Makefile include $(CURDIR)/php-8.0/Makefile include $(CURDIR)/php-8.1/Makefile include $(CURDIR)/php-8.2/Makefile +include $(CURDIR)/php-8.3/Makefile help: @grep -hE '^[a-zA-Z0-9_.-]+:.*?## .*$$' $(MAKEFILE_LIST) \ @@ -26,6 +27,7 @@ test: ## test all against all php images $(MAKE) test-php-8.0 $(MAKE) test-php-8.1 $(MAKE) test-php-8.2 + $(MAKE) test-php-8.3 test-unit: ## test unit suite against all php images $(MAKE) test-suite-php-7.0 SUITE=unit @@ -36,5 +38,6 @@ test-unit: ## test unit suite against all php images $(MAKE) test-suite-php-8.0 SUITE=unit $(MAKE) test-suite-php-8.1 SUITE=unit $(MAKE) test-suite-php-8.2 SUITE=unit + $(MAKE) test-suite-php-8.3 SUITE=unit .DEFAULT_GOAL := help diff --git a/build/docker-compose.yml b/build/docker-compose.yml index 400c527..af9fe64 100644 --- a/build/docker-compose.yml +++ b/build/docker-compose.yml @@ -56,4 +56,11 @@ services: context: php-8.2 volumes: - ..:/app + network_mode: host + + php-8.3: + build: + context: php-8.3 + volumes: + - ..:/app network_mode: host \ No newline at end of file diff --git a/build/php-8.3/Dockerfile b/build/php-8.3/Dockerfile new file mode 100644 index 0000000..7291d69 --- /dev/null +++ b/build/php-8.3/Dockerfile @@ -0,0 +1,18 @@ +FROM composer:latest as composer +FROM php:8.3-rc-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make \ + linux-headers + +RUN pecl install xdebug-3.3.0alpha2 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-8.3/Makefile b/build/php-8.3/Makefile new file mode 100644 index 0000000..edb5c99 --- /dev/null +++ b/build/php-8.3/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-8.3 test-php-8.3 test-suite-php-8.3 + +prepare-php-8.3: ## load dependencies with php 8.3 + docker-compose run -T php-8.3 /usr/bin/composer update --ignore-platform-req=PHP + +test-php-8.3: prepare-php-8.3 ## run tests against php 8.3 + docker-compose run -T php-8.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-8.3: prepare-php-8.3 ## run suite tests against php 8.3, ex: make test-suite-php-8.3 SUITE="unit" + docker-compose run -T php-8.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file From b2b3566184f80b41fed2cf55d995fc0924d2ae55 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 4 Oct 2023 10:20:45 +0200 Subject: [PATCH 62/93] Updates actions/checkout and actions/cache, NodeJS depreciation issue --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 95f3d3e..847ff95 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,7 +55,7 @@ jobs: - 8.3 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -66,7 +66,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.json') }} From cc82b08b2d35b57341cad803b29b840e010536fe Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 4 Oct 2023 10:22:25 +0200 Subject: [PATCH 63/93] Updates composer cache GA, set-output depreciation issue --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 847ff95..c2a5899 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -63,7 +63,7 @@ jobs: php-version: ${{ matrix.php }} - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Cache Composer dependencies uses: actions/cache@v3 From 573e787815fa68d2c179c5c9f328cb022ea1cef2 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Oct 2023 15:42:11 +0200 Subject: [PATCH 64/93] Refactors PHP 8.2 tests --- build/php-8.2/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/php-8.2/Makefile b/build/php-8.2/Makefile index 7d07aca..c7788aa 100644 --- a/build/php-8.2/Makefile +++ b/build/php-8.2/Makefile @@ -1,7 +1,7 @@ .PHONY: prepare-php-8.2 test-php-8.2 test-suite-php-8.2 prepare-php-8.2: ## load dependencies with php 8.2 - docker-compose run -T php-8.2 /usr/bin/composer update --ignore-platform-req=PHP + docker-compose run -T php-8.2 /usr/bin/composer update test-php-8.2: prepare-php-8.2 ## run tests against php 8.2 docker-compose run -T php-8.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml From 145c5236d9f2a259e42f75958ad1fab5896dd726 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Oct 2023 15:59:47 +0200 Subject: [PATCH 65/93] Adds psr/http-message v2 support --- CHANGELOG.md | 2 ++ composer.json | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb4e035..2222f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- `psr/http-message` v2 support ## [3.0.7] - 2022-11-21 ### Fixed diff --git a/composer.json b/composer.json index 7b4119b..bbb4849 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": "^7 || ~8.0 || ~8.1 || ~8.2", "ext-json": "*", "psr/log": "^1 || ^2 || ^3", - "psr/http-message": "^1", + "psr/http-message": "~1.0 || ~1.1 || ~2.0", "psr/http-client": "^1", "psr/http-factory": "^1" }, @@ -31,7 +31,7 @@ "doctrine/instantiator": "1.0.5 || ^1.4.0", "phpdocumentor/reflection-docblock": "^4.3 || ^5.2.0", "phpdocumentor/type-resolver": "^0.5 || ^1.3.0", - "guzzlehttp/psr7": "^1", + "guzzlehttp/psr7": "^1 || ^2", "ext-curl": "*", "roave/security-advisories": "dev-latest" }, From b01e39e56c0f36eec43f57097fdac69b3defb366 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 18 Oct 2023 16:04:30 +0200 Subject: [PATCH 66/93] Releases version 3.0.8 - resolves #125 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2222f60..46ea11a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.8] ### Added - `psr/http-message` v2 support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..f7bed2e 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.8'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 7ddf1b6c86a0c6d2690956f01e3a101a2a81e9f4 Mon Sep 17 00:00:00 2001 From: Adam Lozynski <58483602+lozynskiadam@users.noreply.github.com> Date: Wed, 3 Jan 2024 17:13:52 +0100 Subject: [PATCH 67/93] Handling responses with request timeout status --- src/Infrastructure/ResponseHttpCode.php | 1 + src/Infrastructure/ResponseMapper/RestResponseMapper.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/Infrastructure/ResponseHttpCode.php b/src/Infrastructure/ResponseHttpCode.php index 2c201f5..4ef42b5 100644 --- a/src/Infrastructure/ResponseHttpCode.php +++ b/src/Infrastructure/ResponseHttpCode.php @@ -13,5 +13,6 @@ class ResponseHttpCode const CREATED = 201; const ACCEPTED = 202; const NO_CONTENT = 204; + const REQUEST_TIMEOUT = 408; const SERVICE_UNAVAILABLE = 503; } diff --git a/src/Infrastructure/ResponseMapper/RestResponseMapper.php b/src/Infrastructure/ResponseMapper/RestResponseMapper.php index fff15e3..04106a3 100644 --- a/src/Infrastructure/ResponseMapper/RestResponseMapper.php +++ b/src/Infrastructure/ResponseMapper/RestResponseMapper.php @@ -40,6 +40,8 @@ public function map(ResponseInterface $response): stdClass return new stdClass(); } elseif ($statusCode == ResponseHttpCode::SERVICE_UNAVAILABLE) { throw ApiErrorException::withMessageAndStatusCode('Service unavailable', $statusCode); + } elseif ($statusCode == ResponseHttpCode::REQUEST_TIMEOUT) { + throw ApiErrorException::withMessageAndStatusCode('Request timed out', $statusCode); } elseif ($contents) { $object = $this->jsonDecode->decode($contents); From 3970c2b9d27bae03e037691bbb6fd15fda6ba950 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 9 Jan 2024 14:45:51 +0100 Subject: [PATCH 68/93] Releases version 3.0.9 - resolves #126 --- CHANGELOG.md | 6 +++++- src/SmsapiClient.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46ea11a..09f118c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [3.0.8] +## [3.0.9] - 2024-01-09 +### Fixed +- expired MFA code verification + +## [3.0.8] - 2023-10-18 ### Added - `psr/http-message` v2 support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index f7bed2e..c40e21a 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.8'; + const VERSION = '3.0.9'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 93d11f4384230eada1a264f0f4c4727dd6136287 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 10 Jan 2024 11:16:21 +0100 Subject: [PATCH 69/93] Adds request timeout response test --- CHANGELOG.md | 2 ++ src/SmsapiClient.php | 2 +- .../ResponseMapper/RestResponseMapperTest.php | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f118c..5b709a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + ## [3.0.9] - 2024-01-09 ### Fixed - expired MFA code verification diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index c40e21a..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.9'; + const VERSION = 'Unreleased'; public function smsapiPlService(string $apiToken): SmsapiPlService; diff --git a/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php b/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php index dfbb087..9419e90 100644 --- a/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php +++ b/tests/Unit/Infrastructure/ResponseMapper/RestResponseMapperTest.php @@ -92,6 +92,18 @@ public function it_should_throw_exception_on_service_unavailable() $this->restResponseMapper->map($responseWithServiceUnavailable); } + /** + * @test + */ + public function it_should_throw_exception_on_request_timeout() + { + $responseWithServiceUnavailable = new Response(ResponseHttpCode::REQUEST_TIMEOUT); + + $this->expectException(ApiErrorException::class); + $this->expectExceptionMessage("Request timed out"); + $this->restResponseMapper->map($responseWithServiceUnavailable); + } + /** * @test */ From dfadc9682e3df3f4f0a7d23a9a82f0bc45deabff Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 10 Jan 2024 14:01:16 +0100 Subject: [PATCH 70/93] Splits legacy request mapper test --- .../RequestMapper/LegacyRequestMapperTest.php | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/Unit/Infrastructure/RequestMapper/LegacyRequestMapperTest.php b/tests/Unit/Infrastructure/RequestMapper/LegacyRequestMapperTest.php index 63f910f..da06d89 100644 --- a/tests/Unit/Infrastructure/RequestMapper/LegacyRequestMapperTest.php +++ b/tests/Unit/Infrastructure/RequestMapper/LegacyRequestMapperTest.php @@ -25,10 +25,30 @@ public function init() /** * @test */ - public function it_should_create_post_request_with_parameters() + public function it_should_use_path_as_request_uri() { $path = 'anyPath'; + $request = $this->mapper->map($path, []); + + $this->assertEquals($path, $request->getUri()); + } + + /** + * @test + */ + public function it_should_send_request_as_post() + { + $request = $this->mapper->map('anyPath', []); + + $this->assertEquals(RequestHttpMethod::POST, $request->getMethod()); + } + + /** + * @test + */ + public function it_should_create_request_with_parameters() + { $builtInParameters = [ 'any1' => 'any', ]; @@ -36,10 +56,7 @@ public function it_should_create_post_request_with_parameters() 'any2' => 'any', ]; - $request = $this->mapper->map($path, $builtInParameters, $userParameters); - - $this->assertEquals($path, $request->getUri()); - $this->assertEquals(RequestHttpMethod::POST, $request->getMethod()); + $request = $this->mapper->map('anyPath', $builtInParameters, $userParameters); $this->assertEquals('any1=any&format=json&any2=any', $request->getBody()); } From 0f159fce9fb0daccbd56cfeb59b7c2dbff4ba1ec Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 10 Jan 2024 14:19:44 +0100 Subject: [PATCH 71/93] Assures that legacy request's format=json parameter occur as first in POST table --- .../RequestMapper/LegacyRequestMapper.php | 4 +- .../RequestMapper/LegacyRequestMapperTest.php | 43 ++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/Infrastructure/RequestMapper/LegacyRequestMapper.php b/src/Infrastructure/RequestMapper/LegacyRequestMapper.php index c59e314..b881e30 100644 --- a/src/Infrastructure/RequestMapper/LegacyRequestMapper.php +++ b/src/Infrastructure/RequestMapper/LegacyRequestMapper.php @@ -34,9 +34,7 @@ private function createRequest( array $builtInParameters, array $userParameters ): Request { - $builtInParameters['format'] = 'json'; - - $parameters = new QueryParametersData($builtInParameters, $userParameters); + $parameters = new QueryParametersData(['format' => 'json'] + $builtInParameters, $userParameters); return new Request($method, $path, $this->queryFormatter->format($parameters)); } diff --git a/tests/Unit/Infrastructure/RequestMapper/LegacyRequestMapperTest.php b/tests/Unit/Infrastructure/RequestMapper/LegacyRequestMapperTest.php index da06d89..9b5246a 100644 --- a/tests/Unit/Infrastructure/RequestMapper/LegacyRequestMapperTest.php +++ b/tests/Unit/Infrastructure/RequestMapper/LegacyRequestMapperTest.php @@ -47,7 +47,46 @@ public function it_should_send_request_as_post() /** * @test */ - public function it_should_create_request_with_parameters() + public function it_should_always_set_format_json_parameter() + { + $builtInParameters = []; + $userParameters = []; + + $request = $this->mapper->map('anyPath', $builtInParameters, $userParameters); + + $this->assertEquals('format=json', $request->getBody()); + } + + /** + * @test + */ + public function it_should_prepend_format_parameter_to_built_in_parameters_when_none() + { + $builtInParameters = []; + $userParameters = ['any2' => 'any']; + + $request = $this->mapper->map('anyPath', $builtInParameters, $userParameters); + + $this->assertEquals('format=json&any2=any', $request->getBody()); + } + + /** + * @test + */ + public function it_should_prepend_format_parameter_to_built_in_parameters_when_set() + { + $builtInParameters = ['any1' => 'any']; + $userParameters = []; + + $request = $this->mapper->map('anyPath', $builtInParameters, $userParameters); + + $this->assertEquals('format=json&any1=any', $request->getBody()); + } + + /** + * @test + */ + public function it_should_merge_both_built_in_and_user_parameters() { $builtInParameters = [ 'any1' => 'any', @@ -58,6 +97,6 @@ public function it_should_create_request_with_parameters() $request = $this->mapper->map('anyPath', $builtInParameters, $userParameters); - $this->assertEquals('any1=any&format=json&any2=any', $request->getBody()); + $this->assertEquals('format=json&any1=any&any2=any', $request->getBody()); } } From c8dec1c88f3d4bcac83cf16f78fb2f77d2563645 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 10 Jan 2024 14:46:54 +0100 Subject: [PATCH 72/93] Fixes sending/scheduling smses in large amount --- CHANGELOG.md | 2 ++ src/Feature/Sms/Bag/ScheduleSmssBag.php | 2 +- src/Feature/Sms/Bag/SendSmssBag.php | 2 +- src/Feature/Sms/SmsHttpFeature.php | 5 ++++ tests/Fixture/PhoneNumberFixture.php | 5 ++++ .../Feature/Sms/SmsFeatureTest.php | 30 ++++++++----------- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b709a1..b5b892d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- sending/scheduling smses in large amount ## [3.0.9] - 2024-01-09 ### Fixed diff --git a/src/Feature/Sms/Bag/ScheduleSmssBag.php b/src/Feature/Sms/Bag/ScheduleSmssBag.php index b6fda24..6d2afc3 100644 --- a/src/Feature/Sms/Bag/ScheduleSmssBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmssBag.php @@ -29,7 +29,7 @@ #[\AllowDynamicProperties] class ScheduleSmssBag { - /** @var array */ + /** @var array|string */ public $to; /** @var DateTimeInterface */ diff --git a/src/Feature/Sms/Bag/SendSmssBag.php b/src/Feature/Sms/Bag/SendSmssBag.php index 53dc09b..5a48c72 100644 --- a/src/Feature/Sms/Bag/SendSmssBag.php +++ b/src/Feature/Sms/Bag/SendSmssBag.php @@ -29,7 +29,7 @@ #[\AllowDynamicProperties] class SendSmssBag { - /** @var array */ + /** @var array|string */ public $to; /** @var string */ diff --git a/src/Feature/Sms/SmsHttpFeature.php b/src/Feature/Sms/SmsHttpFeature.php index 10dea8b..b2e2299 100644 --- a/src/Feature/Sms/SmsHttpFeature.php +++ b/src/Feature/Sms/SmsHttpFeature.php @@ -110,6 +110,8 @@ public function sendFlashSmsToGroup(SendSmsToGroupBag $sendSmsToGroupBag): array public function sendSmss(SendSmssBag $sendSmssBag): array { + $sendSmssBag->to = implode(',', $sendSmssBag->to); + return array_map( [$this->dataFactoryProvider->provideSmsFactory(), 'createFromObject'], $this->makeRequest($sendSmssBag)->list @@ -118,6 +120,8 @@ public function sendSmss(SendSmssBag $sendSmssBag): array public function sendFlashSmss(SendSmssBag $sendSmssBag): array { + $sendSmssBag->to = implode(',', $sendSmssBag->to); + return array_map( [$this->dataFactoryProvider->provideSmsFactory(), 'createFromObject'], $this->makeRequest($sendSmssBag)->list @@ -146,6 +150,7 @@ public function scheduleSms(ScheduleSmsBag $scheduleSmsBag): Sms public function scheduleSmss(ScheduleSmssBag $scheduleSmssBag): array { + $scheduleSmssBag->to = implode(',', $scheduleSmssBag->to); $scheduleSmssBag->dateValidate = true; return array_map( diff --git a/tests/Fixture/PhoneNumberFixture.php b/tests/Fixture/PhoneNumberFixture.php index 2ab2941..9f06e1f 100644 --- a/tests/Fixture/PhoneNumberFixture.php +++ b/tests/Fixture/PhoneNumberFixture.php @@ -20,4 +20,9 @@ public static function anyValidMobile(): string { return (string)((int)self::$validMobile + self::$i++); } + + public static function xValidMobile(int $x): array + { + return array_map(function () {return self::anyValidMobile();}, range(1, $x)); + } } diff --git a/tests/Integration/Feature/Sms/SmsFeatureTest.php b/tests/Integration/Feature/Sms/SmsFeatureTest.php index e78a420..c5051f8 100644 --- a/tests/Integration/Feature/Sms/SmsFeatureTest.php +++ b/tests/Integration/Feature/Sms/SmsFeatureTest.php @@ -82,12 +82,12 @@ public function it_should_send_flash_sms() public function it_should_send_smss() { $smsFeature = self::$smsapiService->smsFeature(); - $sendSmssBag = $this->givenSmssToSend(); + $sendSmssBag = $this->givenSmssToSend(2); $sendSmssBag->test = true; $results = $smsFeature->sendSmss($sendSmssBag); - $this->assertCount(count($sendSmssBag->to), $results); + $this->assertCount(2, $results); } /** @@ -96,12 +96,12 @@ public function it_should_send_smss() public function it_should_send_flash_smss() { $smsFeature = self::$smsapiService->smsFeature(); - $sendSmssBag = $this->givenSmssToSend(); + $sendSmssBag = $this->givenSmssToSend(2); $sendSmssBag->test = true; $results = $smsFeature->sendFlashSmss($sendSmssBag); - $this->assertCount(count($sendSmssBag->to), $results); + $this->assertCount(2, $results); } /** @@ -110,7 +110,7 @@ public function it_should_send_flash_smss() public function it_should_not_receive_content_details_for_smss() { $smsFeature = self::$smsapiService->smsFeature(); - $sendSmsesBag = $this->givenSmssToSend(); + $sendSmsesBag = $this->givenSmssToSend(2); $sendSmsesBag->test = true; /** @var Sms[] $results */ @@ -142,12 +142,12 @@ public function it_should_schedule_sms() public function it_should_schedule_smss() { $smsFeature = self::$smsapiService->smsFeature(); - $scheduleSmssBag = $this->givenSmssToSchedule(); + $scheduleSmssBag = $this->givenSmssToSchedule(2); $scheduleSmssBag->test = true; $results = $smsFeature->scheduleSmss($scheduleSmssBag); - $this->assertCount(count($scheduleSmssBag->to), $results); + $this->assertCount(2, $results); } /** @@ -171,7 +171,7 @@ public function it_should_schedule_flash_sms() public function it_should_delete_scheduled_smss() { $smsFeature = self::$smsapiService->smsFeature(); - $scheduleSmssBag = $this->givenSmssToSchedule(); + $scheduleSmssBag = $this->givenSmssToSchedule(2); $results = $smsFeature->scheduleSmss($scheduleSmssBag); $smsIds = array_map(function (Sms $sms) { @@ -190,12 +190,9 @@ private function givenSmsToSend(): SendSmsBag return SendSmsBag::withMessage($someReceiver, 'some message'); } - private function givenSmssToSend(): SendSmssBag + private function givenSmssToSend(int $x): SendSmssBag { - $receivers = [ - PhoneNumberFixture::anyValidMobile(), - PhoneNumberFixture::anyValidMobile(), - ]; + $receivers = PhoneNumberFixture::xValidMobile($x); return SendSmssBag::withMessage($receivers, 'some message'); } @@ -206,13 +203,10 @@ private function givenSmsToSchedule(): ScheduleSmsBag return ScheduleSmsBag::withMessage($someDate, $someReceiver, 'some message'); } - private function givenSmssToSchedule(): ScheduleSmssBag + private function givenSmssToSchedule(int $x): ScheduleSmssBag { $someDate = new DateTime('+1 day noon'); - $receivers = [ - PhoneNumberFixture::anyValidMobile(), - PhoneNumberFixture::anyValidMobile(), - ]; + $receivers = PhoneNumberFixture::xValidMobile($x); return ScheduleSmssBag::withMessage($someDate, $receivers, 'some message'); } } From b228a1eba6a9bf9f38e5017bc012c0e4e9161715 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Thu, 11 Jan 2024 15:04:54 +0100 Subject: [PATCH 73/93] Adds PHP 8.3 support --- .github/workflows/tests.yml | 32 +------------------------------- CHANGELOG.md | 2 ++ build/php-8.3/Dockerfile | 4 ++-- composer.json | 2 +- 4 files changed, 6 insertions(+), 34 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c2a5899..ab815b5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,6 +22,7 @@ jobs: - 8.0 - 8.1 - 8.2 + - 8.3 steps: - name: Checkout uses: actions/checkout@v3 @@ -45,34 +46,3 @@ jobs: - name: Running unit tests run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit - - tests-rc: - name: PHP ${{ matrix.php }} - runs-on: ubuntu-latest - strategy: - matrix: - php: - - 8.3 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - - - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache Composer dependencies - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: composer-${{ runner.os }}-${{ matrix.php }}-${{ hashFiles('composer.json') }} - - - name: Install dependencies - run: composer update --prefer-dist --no-interaction --ignore-platform-req=PHP - - - name: Running unit tests - run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b709a1..3b9d65e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- PHP-8.3 support ## [3.0.9] - 2024-01-09 ### Fixed diff --git a/build/php-8.3/Dockerfile b/build/php-8.3/Dockerfile index 7291d69..97fdde4 100644 --- a/build/php-8.3/Dockerfile +++ b/build/php-8.3/Dockerfile @@ -1,5 +1,5 @@ FROM composer:latest as composer -FROM php:8.3-rc-cli-alpine +FROM php:8.3-cli-alpine RUN apk update && \ apk upgrade && \ @@ -9,7 +9,7 @@ RUN apk update && \ make \ linux-headers -RUN pecl install xdebug-3.3.0alpha2 && \ +RUN pecl install xdebug-3.3.1 && \ pecl clear-cache && \ docker-php-ext-enable xdebug diff --git a/composer.json b/composer.json index bbb4849..31269cb 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": "^7 || ~8.0 || ~8.1 || ~8.2", + "php": "^7 || ~8.0 || ~8.1 || ~8.2 || ~8.3", "ext-json": "*", "psr/log": "^1 || ^2 || ^3", "psr/http-message": "~1.0 || ~1.1 || ~2.0", From f6aaf36713b7e70a78c6f8622c6911ffaa376a67 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 15 Jan 2024 10:25:00 +0100 Subject: [PATCH 74/93] Changes request parameters documentation. Explains usage of optional parameters. --- README.md | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index bcd54ec..95ef8f3 100644 --- a/README.md +++ b/README.md @@ -185,50 +185,59 @@ $service->smsFeature() ->sendSms($sms); ``` -### How to send a SMS with optional from field? +### How to use request parameters? + +Request parameters are represented in a form of data transfer object. +DTOs can be found by searching for 'bag' postfixed classes. +Each bag may contain required and optional parameters. + +#### Required parameters + +Required parameters are that class public properties, usually accessible via some form of a setter or named constructor. +Each parameter can be also set directly by setting bag property, as in example: + +##### How to change SMS encoding? ```php from = 'Test'; +$sms->encoding = 'utf-8'; -$service->smsFeature() - ->sendSms($sms); ``` -For more usage examples take a look at client test suite. +#### Optional parameters -### How to use optional request parameters? +Some of request's optional parameters have been described by docblock's '@property' annotation. +You can always add any not documented here optional parameter by setting dynamic property to 'bag'. +Camel case property names are being converted to snake case on the fly. -Request parameters are represented in a form of data transfer object. -DTOs can be found by searching for 'bag' postfixed classes. -Each bag may contain required and optional parameters. -Required parameters are that class public properties, usually accessible via some form of a setter or named constructor. -Optional parameters are described by docblock's '@property' annotation. - -Each parameter can be also set directly by setting bag property, as in example: +##### How to send a SMS with optional from field? ```php encoding = 'utf-8'; +$sms->from = 'Test'; +$service->smsFeature() + ->sendSms($sms); ``` +For more usage examples take a look at client test suite. + ## How to use additional features? ### How to use proxy server? From da69e9ec19a641c5bc77158f34fd14b312ebbfe7 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 15 Jan 2024 11:24:02 +0100 Subject: [PATCH 75/93] Adds time restriction sms bag optional request parameter helpers --- CHANGELOG.md | 7 +++++++ src/Feature/Sms/Bag/ScheduleSmsBag.php | 1 + src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php | 1 + src/Feature/Sms/Bag/ScheduleSmssBag.php | 1 + src/Feature/Sms/Bag/SendSmsBag.php | 1 + src/Feature/Sms/Bag/SendSmsToGroupBag.php | 1 + src/Feature/Sms/Bag/SendSmssBag.php | 1 + 7 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b709a1..976f370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- `SendSmsBag::$timeRestriction` optional parameter +- `SendSmssBag::$timeRestriction` optional parameter +- `SendSmsToGroupBag::$timeRestriction` optional parameter +- `ScheduleSmsBag::$timeRestriction` optional parameter +- `ScheduleSmssBag::$timeRestriction` optional parameter +- `ScheduleSmsToGroupBag::$timeRestriction` optional parameter ## [3.0.9] - 2024-01-09 ### Fixed diff --git a/src/Feature/Sms/Bag/ScheduleSmsBag.php b/src/Feature/Sms/Bag/ScheduleSmsBag.php index 443bbb5..69257d4 100644 --- a/src/Feature/Sms/Bag/ScheduleSmsBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmsBag.php @@ -24,6 +24,7 @@ * @property string $param2 * @property string $param3 * @property string $param4 + * @property string $timeRestriction */ #[\AllowDynamicProperties] class ScheduleSmsBag diff --git a/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php b/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php index 28e138d..3412f21 100644 --- a/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php @@ -20,6 +20,7 @@ * @property bool $normalize * @property string $notifyUrl * @property bool $test + * @property string $timeRestriction */ #[\AllowDynamicProperties] class ScheduleSmsToGroupBag diff --git a/src/Feature/Sms/Bag/ScheduleSmssBag.php b/src/Feature/Sms/Bag/ScheduleSmssBag.php index b6fda24..0706d54 100644 --- a/src/Feature/Sms/Bag/ScheduleSmssBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmssBag.php @@ -25,6 +25,7 @@ * @property array $param2 * @property array $param3 * @property array $param4 + * @property string $timeRestriction */ #[\AllowDynamicProperties] class ScheduleSmssBag diff --git a/src/Feature/Sms/Bag/SendSmsBag.php b/src/Feature/Sms/Bag/SendSmsBag.php index 23b0400..1391c37 100644 --- a/src/Feature/Sms/Bag/SendSmsBag.php +++ b/src/Feature/Sms/Bag/SendSmsBag.php @@ -24,6 +24,7 @@ * @property string $param2 * @property string $param3 * @property string $param4 + * @property string $timeRestriction */ #[\AllowDynamicProperties] class SendSmsBag diff --git a/src/Feature/Sms/Bag/SendSmsToGroupBag.php b/src/Feature/Sms/Bag/SendSmsToGroupBag.php index e462bbe..98b944e 100644 --- a/src/Feature/Sms/Bag/SendSmsToGroupBag.php +++ b/src/Feature/Sms/Bag/SendSmsToGroupBag.php @@ -19,6 +19,7 @@ * @property bool $normalize * @property string $notifyUrl * @property bool $test + * @property string $timeRestriction */ #[\AllowDynamicProperties] class SendSmsToGroupBag diff --git a/src/Feature/Sms/Bag/SendSmssBag.php b/src/Feature/Sms/Bag/SendSmssBag.php index 53dc09b..da677e3 100644 --- a/src/Feature/Sms/Bag/SendSmssBag.php +++ b/src/Feature/Sms/Bag/SendSmssBag.php @@ -25,6 +25,7 @@ * @property array $param2 * @property array $param3 * @property array $param4 + * @property string $timeRestriction */ #[\AllowDynamicProperties] class SendSmssBag From 188cd3992cf50c3983c5f8cc9d24c4ad7266a7d9 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 16 Jan 2024 14:50:00 +0100 Subject: [PATCH 76/93] Releases version 3.0.10 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dcaf74..2d75618 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.10] - 2024-01-16 ### Added - PHP-8.3 support - `SendSmsBag::$timeRestriction` optional parameter diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..babace9 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.10'; public function smsapiPlService(string $apiToken): SmsapiPlService; From b53c3d13946fb556cd5472e44cd02f9cab711962 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Thu, 21 Mar 2024 10:47:09 +0100 Subject: [PATCH 77/93] Adds base URI decorator tests --- .../HttpClient/HttpClientRequestSpy.php | 27 +++ .../Decorator/BaseUriDecoratorTest.php | 210 ++++++++++++++++++ 2 files changed, 237 insertions(+) create mode 100644 tests/Helper/HttpClient/HttpClientRequestSpy.php create mode 100644 tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php diff --git a/tests/Helper/HttpClient/HttpClientRequestSpy.php b/tests/Helper/HttpClient/HttpClientRequestSpy.php new file mode 100644 index 0000000..375e984 --- /dev/null +++ b/tests/Helper/HttpClient/HttpClientRequestSpy.php @@ -0,0 +1,27 @@ +lastSentRequest = $request; + + return new Response(); + } + + public function getLastSentRequest(): RequestInterface + { + return $this->lastSentRequest; + } +} \ No newline at end of file diff --git a/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php b/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php new file mode 100644 index 0000000..06dea5a --- /dev/null +++ b/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php @@ -0,0 +1,210 @@ +sendRequestToAnyEndpoint($decorator); + + $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); + $this->assertEquals($expectedRequestSchema, $sentRequestSpy->getLastSentRequest()->getUri()->getScheme()); + } + + /** + * @test + * @testWith + * ["example.com", "example.com/endpoint"] + * ["example.com/base/", "example.com/base/endpoint"] + * ["example.com:80", "//example.com/endpoint"] + * ["example.com:80/base/", "//example.com/base/endpoint"] + */ + public function send_request_without_base_schema(string $baseUri, string $expectedRequestUri) + { + $sentRequestSpy = new HttpClientRequestSpy(); + $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); + + $this->sendRequestToAnyEndpoint($decorator); + + $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); + $this->assertEquals('', $sentRequestSpy->getLastSentRequest()->getUri()->getScheme()); + } + + /** + * @test + * @testWith + * ["any://example.com", "any://example.com/endpoint", "example.com"] + * ["any://example.com:80", "any://example.com/endpoint", "example.com"] + * ["any://example", "any://example/endpoint", "example"] + * ["any://example:80", "any://example/endpoint", "example"] + * ["example.com", "example.com/endpoint", ""] + * ["example.com:80", "//example.com/endpoint", "example.com"] + * ["example", "example/endpoint", ""] + * ["example:80", "//example/endpoint", "example"] + * ["example.com/base/", "example.com/base/endpoint", ""] + * ["example.com:80/base/", "//example.com/base/endpoint", "example.com"] + * ["example/base/", "example/base/endpoint", ""] + * ["example:80/base/", "//example/base/endpoint", "example"] + */ + public function send_request_with_base_host(string $baseUri, string $expectedRequestUri, string $expectedRequestHost) + { + $sentRequestSpy = new HttpClientRequestSpy(); + $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); + + $this->sendRequestToAnyEndpoint($decorator); + + $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); + $this->assertEquals($expectedRequestHost, $sentRequestSpy->getLastSentRequest()->getUri()->getHost()); + } + + /** + * @test + * @testWith + * ["any://", "/endpoint"] + * ["any:///", "/endpoint"] + * ["any://:80/", "/endpoint"] + */ + public function send_request_without_base_host(string $baseUri, string $expectedRequestUri) + { + $sentRequestSpy = new HttpClientRequestSpy(); + $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); + + $this->sendRequestToAnyEndpoint($decorator); + + $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); + $this->assertEquals('', $sentRequestSpy->getLastSentRequest()->getUri()->getHost()); + } + + /** + * @test + * @testWith + * ["any://example.com:80", "any://example.com/endpoint", ""] + * ["any://example:80", "any://example/endpoint", ""] + * ["example.com:80", "//example.com/endpoint", ""] + * ["example:80", "//example/endpoint", ""] + * ["example.com:80/base/", "//example.com/base/endpoint", ""] + * ["example:80/base/", "//example/base/endpoint", ""] + */ + public function send_request_with_base_port(string $baseUri, string $expectedRequestUri, string $expectedRequestPort) + { + $sentRequestSpy = new HttpClientRequestSpy(); + $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); + + $this->sendRequestToAnyEndpoint($decorator); + + $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); + $this->assertEquals($expectedRequestPort, $sentRequestSpy->getLastSentRequest()->getUri()->getPort()); + } + + /** + * @test + * @testWith + * ["any://example.com", "any://example.com/endpoint"] + * ["any://example", "any://example/endpoint"] + * ["any://example.com/base", "any://example.com/base/endpoint"] + * ["any://example/base", "any://example/base/endpoint"] + * ["example.com", "example.com/endpoint"] + * ["example", "example/endpoint"] + * ["example.com/base/", "example.com/base/endpoint"] + * ["example/base/", "example/base/endpoint"] + */ + public function send_request_without_base_port(string $baseUri, string $expectedRequestUri) + { + $sentRequestSpy = new HttpClientRequestSpy(); + $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); + + $this->sendRequestToAnyEndpoint($decorator); + + $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); + $this->assertEquals('', $sentRequestSpy->getLastSentRequest()->getUri()->getPort()); + } + + /** + * @test + * @testWith + * ["any://example.com/base", "any://example.com/base/endpoint", "/base/endpoint"] + * ["any://example/base", "any://example/base/endpoint", "/base/endpoint"] + * ["example.com/base", "example.com/base/endpoint", "example.com/base/endpoint"] + * ["example/base", "example/base/endpoint", "example/base/endpoint"] + * ["any://example.com:80/base/", "any://example.com/base/endpoint", "/base/endpoint"] + * ["any://example:80/base", "any://example/base/endpoint", "/base/endpoint"] + * ["example.com:80/base", "//example.com/base/endpoint", "/base/endpoint"] + * ["example:80/base", "//example/base/endpoint", "/base/endpoint"] + * ["any://example.com/base/", "any://example.com/base/endpoint", "/base/endpoint"] + * ["any://example/base/", "any://example/base/endpoint", "/base/endpoint"] + * ["example.com/base/", "example.com/base/endpoint", "example.com/base/endpoint"] + * ["example/base/", "example/base/endpoint", "example/base/endpoint"] + * ["any://example.com:80/base/", "any://example.com/base/endpoint", "/base/endpoint"] + * ["any://example:80/base", "any://example/base/endpoint", "/base/endpoint"] + * ["example.com:80/base/", "//example.com/base/endpoint", "/base/endpoint"] + * ["example:80/base/", "//example/base/endpoint", "/base/endpoint"] + */ + public function send_request_with_base_path(string $baseUri, string $expectedRequestUri, string $expectedRequestPath) + { + $sentRequestSpy = new HttpClientRequestSpy(); + $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); + + $this->sendRequestToAnyEndpoint($decorator); + + $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); + $this->assertEquals($expectedRequestPath, $sentRequestSpy->getLastSentRequest()->getUri()->getPath()); + } + + /** + * @test + * @testWith + * ["any://example.com", "any://example.com/endpoint", "/endpoint"] + * ["any://example", "any://example/endpoint", "/endpoint"] + * ["example.com", "example.com/endpoint", "example.com/endpoint"] + * ["example", "example/endpoint", "example/endpoint"] + * ["any://example.com:80", "any://example.com/endpoint", "/endpoint"] + * ["any://example:80", "any://example/endpoint", "/endpoint"] + * ["example.com:80", "//example.com/endpoint", "/endpoint"] + * ["example:80", "//example/endpoint", "/endpoint"] + * ["any://example.com/", "any://example.com/endpoint", "/endpoint"] + * ["any://example/", "any://example/endpoint", "/endpoint"] + * ["example.com/", "example.com/endpoint", "example.com/endpoint"] + * ["example/", "example/endpoint", "example/endpoint"] + * ["any://example.com:80/", "any://example.com/endpoint", "/endpoint"] + * ["any://example:80/", "any://example/endpoint", "/endpoint"] + * ["example.com:80/", "//example.com/endpoint", "/endpoint"] + * ["example:80/", "//example/endpoint", "/endpoint"] + */ + public function send_request_without_base_path(string $baseUri, string $expectedRequestUri, string $expectedRequestPath) + { + $sentRequestSpy = new HttpClientRequestSpy(); + $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); + + $this->sendRequestToAnyEndpoint($decorator); + + $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); + $this->assertEquals($expectedRequestPath, $sentRequestSpy->getLastSentRequest()->getUri()->getPath()); + } + + private function sendRequestToAnyEndpoint(BaseUriDecorator $decorator) + { + $request = new Request('ANY', 'endpoint'); + $decorator->sendRequest($request); + } +} \ No newline at end of file From f753335225d591062877485660d8ff2de2c6c1f2 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Thu, 21 Mar 2024 13:42:29 +0100 Subject: [PATCH 78/93] Adds service url scheme and host validation --- CHANGELOG.md | 7 +++ src/Curl/Exception/ClientException.php | 21 ++----- src/Curl/Exception/NetworkException.php | 6 +- src/Curl/Exception/RequestException.php | 6 +- src/Curl/HttpClient.php | 4 +- .../HttpClient/ClientException.php | 30 +++++++++ .../HttpClient/Decorator/BaseUriDecorator.php | 5 ++ .../HttpClient/NetworkException.php | 15 +++++ .../HttpClient/RequestException.php | 15 +++++ src/SmsapiClient.php | 2 +- tests/SmsapiClientIntegrationTestCase.php | 4 -- .../Decorator/BaseUriDecoratorTest.php | 62 +++---------------- 12 files changed, 94 insertions(+), 83 deletions(-) create mode 100644 src/Infrastructure/HttpClient/ClientException.php create mode 100644 src/Infrastructure/HttpClient/NetworkException.php create mode 100644 src/Infrastructure/HttpClient/RequestException.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d75618..a46c0c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Added +- service url scheme and host validation + +### Changed +- PSR-18 HTTP client related exceptions namespace moved + ## [3.0.10] - 2024-01-16 ### Added - PHP-8.3 support diff --git a/src/Curl/Exception/ClientException.php b/src/Curl/Exception/ClientException.php index 4da31c7..0d2726a 100644 --- a/src/Curl/Exception/ClientException.php +++ b/src/Curl/Exception/ClientException.php @@ -4,27 +4,14 @@ namespace Smsapi\Client\Curl\Exception; -use Exception; -use Psr\Http\Client\ClientExceptionInterface; -use Psr\Http\Message\RequestInterface; +use Smsapi\Client\Infrastructure\HttpClient\ClientException as HttpClientException; /** * @api + * @deprecated + * @see HttpClientException */ -class ClientException extends Exception implements ClientExceptionInterface +class ClientException extends HttpClientException { - private $request; - public static function withRequest(string $message, RequestInterface $request): self - { - $exception = new self($message); - $exception->request = $request; - - return $exception; - } - - public function getRequest(): RequestInterface - { - return $this->request; - } } \ No newline at end of file diff --git a/src/Curl/Exception/NetworkException.php b/src/Curl/Exception/NetworkException.php index a4b7421..9d1729a 100644 --- a/src/Curl/Exception/NetworkException.php +++ b/src/Curl/Exception/NetworkException.php @@ -4,12 +4,14 @@ namespace Smsapi\Client\Curl\Exception; -use Psr\Http\Client\NetworkExceptionInterface; +use Smsapi\Client\Infrastructure\HttpClient\NetworkException as HttpClientNetworkException; /** * @api + * @deprecated + * @see HttpClientNetworkException */ -class NetworkException extends ClientException implements NetworkExceptionInterface +class NetworkException extends HttpClientNetworkException { } \ No newline at end of file diff --git a/src/Curl/Exception/RequestException.php b/src/Curl/Exception/RequestException.php index 2ea1aa5..0b96f1e 100644 --- a/src/Curl/Exception/RequestException.php +++ b/src/Curl/Exception/RequestException.php @@ -4,12 +4,14 @@ namespace Smsapi\Client\Curl\Exception; -use Psr\Http\Client\RequestExceptionInterface; +use Smsapi\Client\Infrastructure\HttpClient\RequestException as HttpClientRequestException; /** * @api + * @deprecated + * @see HttpClientRequestException */ -class RequestException extends ClientException implements RequestExceptionInterface +class RequestException extends HttpClientRequestException { } \ No newline at end of file diff --git a/src/Curl/HttpClient.php b/src/Curl/HttpClient.php index b2f9af7..2ef3ca6 100644 --- a/src/Curl/HttpClient.php +++ b/src/Curl/HttpClient.php @@ -8,8 +8,8 @@ use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use Smsapi\Client\Curl\Exception\NetworkException; -use Smsapi\Client\Curl\Exception\RequestException; +use Smsapi\Client\Infrastructure\HttpClient\NetworkException; +use Smsapi\Client\Infrastructure\HttpClient\RequestException; /** * @internal diff --git a/src/Infrastructure/HttpClient/ClientException.php b/src/Infrastructure/HttpClient/ClientException.php new file mode 100644 index 0000000..a17f164 --- /dev/null +++ b/src/Infrastructure/HttpClient/ClientException.php @@ -0,0 +1,30 @@ +request = $request; + + return $exception; + } + + public function getRequest(): RequestInterface + { + return $this->request; + } +} \ No newline at end of file diff --git a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php index 75b50db..f2f4ae0 100644 --- a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php @@ -7,6 +7,7 @@ use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use Smsapi\Client\Infrastructure\HttpClient\RequestException; /** * @internal @@ -37,6 +38,10 @@ private function prependBaseUri(RequestInterface $request): RequestInterface $scheme = $baseUriParts['scheme'] ?? ''; $host = $baseUriParts['host'] ?? ''; + if (!$scheme || !$host) { + throw RequestException::withRequest("Base URI has no scheme or host", $request); + } + $basePath = $baseUriParts['path'] ?? ''; $basePath = rtrim($basePath, '/'); diff --git a/src/Infrastructure/HttpClient/NetworkException.php b/src/Infrastructure/HttpClient/NetworkException.php new file mode 100644 index 0000000..8464188 --- /dev/null +++ b/src/Infrastructure/HttpClient/NetworkException.php @@ -0,0 +1,15 @@ +expectException(RequestException::class); + $this->expectExceptionMessage('Base URI has no scheme or host'); $this->sendRequestToAnyEndpoint($decorator); - - $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); - $this->assertEquals('', $sentRequestSpy->getLastSentRequest()->getUri()->getScheme()); } /** @@ -58,14 +61,6 @@ public function send_request_without_base_schema(string $baseUri, string $expect * ["any://example.com:80", "any://example.com/endpoint", "example.com"] * ["any://example", "any://example/endpoint", "example"] * ["any://example:80", "any://example/endpoint", "example"] - * ["example.com", "example.com/endpoint", ""] - * ["example.com:80", "//example.com/endpoint", "example.com"] - * ["example", "example/endpoint", ""] - * ["example:80", "//example/endpoint", "example"] - * ["example.com/base/", "example.com/base/endpoint", ""] - * ["example.com:80/base/", "//example.com/base/endpoint", "example.com"] - * ["example/base/", "example/base/endpoint", ""] - * ["example:80/base/", "//example/base/endpoint", "example"] */ public function send_request_with_base_host(string $baseUri, string $expectedRequestUri, string $expectedRequestHost) { @@ -78,33 +73,11 @@ public function send_request_with_base_host(string $baseUri, string $expectedReq $this->assertEquals($expectedRequestHost, $sentRequestSpy->getLastSentRequest()->getUri()->getHost()); } - /** - * @test - * @testWith - * ["any://", "/endpoint"] - * ["any:///", "/endpoint"] - * ["any://:80/", "/endpoint"] - */ - public function send_request_without_base_host(string $baseUri, string $expectedRequestUri) - { - $sentRequestSpy = new HttpClientRequestSpy(); - $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); - - $this->sendRequestToAnyEndpoint($decorator); - - $this->assertEquals($expectedRequestUri, (string)$sentRequestSpy->getLastSentRequest()->getUri()); - $this->assertEquals('', $sentRequestSpy->getLastSentRequest()->getUri()->getHost()); - } - /** * @test * @testWith * ["any://example.com:80", "any://example.com/endpoint", ""] * ["any://example:80", "any://example/endpoint", ""] - * ["example.com:80", "//example.com/endpoint", ""] - * ["example:80", "//example/endpoint", ""] - * ["example.com:80/base/", "//example.com/base/endpoint", ""] - * ["example:80/base/", "//example/base/endpoint", ""] */ public function send_request_with_base_port(string $baseUri, string $expectedRequestUri, string $expectedRequestPort) { @@ -124,10 +97,6 @@ public function send_request_with_base_port(string $baseUri, string $expectedReq * ["any://example", "any://example/endpoint"] * ["any://example.com/base", "any://example.com/base/endpoint"] * ["any://example/base", "any://example/base/endpoint"] - * ["example.com", "example.com/endpoint"] - * ["example", "example/endpoint"] - * ["example.com/base/", "example.com/base/endpoint"] - * ["example/base/", "example/base/endpoint"] */ public function send_request_without_base_port(string $baseUri, string $expectedRequestUri) { @@ -144,21 +113,12 @@ public function send_request_without_base_port(string $baseUri, string $expected * @test * @testWith * ["any://example.com/base", "any://example.com/base/endpoint", "/base/endpoint"] - * ["any://example/base", "any://example/base/endpoint", "/base/endpoint"] - * ["example.com/base", "example.com/base/endpoint", "example.com/base/endpoint"] - * ["example/base", "example/base/endpoint", "example/base/endpoint"] * ["any://example.com:80/base/", "any://example.com/base/endpoint", "/base/endpoint"] * ["any://example:80/base", "any://example/base/endpoint", "/base/endpoint"] - * ["example.com:80/base", "//example.com/base/endpoint", "/base/endpoint"] - * ["example:80/base", "//example/base/endpoint", "/base/endpoint"] * ["any://example.com/base/", "any://example.com/base/endpoint", "/base/endpoint"] * ["any://example/base/", "any://example/base/endpoint", "/base/endpoint"] - * ["example.com/base/", "example.com/base/endpoint", "example.com/base/endpoint"] - * ["example/base/", "example/base/endpoint", "example/base/endpoint"] * ["any://example.com:80/base/", "any://example.com/base/endpoint", "/base/endpoint"] * ["any://example:80/base", "any://example/base/endpoint", "/base/endpoint"] - * ["example.com:80/base/", "//example.com/base/endpoint", "/base/endpoint"] - * ["example:80/base/", "//example/base/endpoint", "/base/endpoint"] */ public function send_request_with_base_path(string $baseUri, string $expectedRequestUri, string $expectedRequestPath) { @@ -176,20 +136,12 @@ public function send_request_with_base_path(string $baseUri, string $expectedReq * @testWith * ["any://example.com", "any://example.com/endpoint", "/endpoint"] * ["any://example", "any://example/endpoint", "/endpoint"] - * ["example.com", "example.com/endpoint", "example.com/endpoint"] - * ["example", "example/endpoint", "example/endpoint"] * ["any://example.com:80", "any://example.com/endpoint", "/endpoint"] * ["any://example:80", "any://example/endpoint", "/endpoint"] - * ["example.com:80", "//example.com/endpoint", "/endpoint"] - * ["example:80", "//example/endpoint", "/endpoint"] * ["any://example.com/", "any://example.com/endpoint", "/endpoint"] * ["any://example/", "any://example/endpoint", "/endpoint"] - * ["example.com/", "example.com/endpoint", "example.com/endpoint"] - * ["example/", "example/endpoint", "example/endpoint"] * ["any://example.com:80/", "any://example.com/endpoint", "/endpoint"] * ["any://example:80/", "any://example/endpoint", "/endpoint"] - * ["example.com:80/", "//example.com/endpoint", "/endpoint"] - * ["example:80/", "//example/endpoint", "/endpoint"] */ public function send_request_without_base_path(string $baseUri, string $expectedRequestUri, string $expectedRequestPath) { From ac878bc13cc9ee0500301e59fe1b230afa130fa9 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 22 Mar 2024 14:20:27 +0100 Subject: [PATCH 79/93] Adds service url scheme and host validation --- .../HttpClient/Decorator/BaseUriDecorator.php | 8 ++++---- .../HttpClient/Decorator/BaseUriDecoratorTest.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php index f2f4ae0..1fa91f9 100644 --- a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php @@ -34,14 +34,14 @@ private function prependBaseUri(RequestInterface $request): RequestInterface { $uri = $request->getUri(); + if (!filter_var($this->baseUri, FILTER_VALIDATE_URL)) { + throw RequestException::withRequest("Invalid Base URI", $request); + } + $baseUriParts = parse_url($this->baseUri); $scheme = $baseUriParts['scheme'] ?? ''; $host = $baseUriParts['host'] ?? ''; - if (!$scheme || !$host) { - throw RequestException::withRequest("Base URI has no scheme or host", $request); - } - $basePath = $baseUriParts['path'] ?? ''; $basePath = rtrim($basePath, '/'); diff --git a/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php b/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php index 61260ef..f5f1c59 100644 --- a/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php +++ b/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php @@ -44,13 +44,13 @@ public function send_request_with_base_schema(string $baseUri, string $expectedR * ["any:///"] * ["any://:80/"] */ - public function send_request_without_base_schema_or_host(string $baseUri) + public function dont_send_request_without_base_schema_or_host(string $baseUri) { $sentRequestSpy = new HttpClientRequestSpy(); $decorator = new BaseUriDecorator($sentRequestSpy, $baseUri); $this->expectException(RequestException::class); - $this->expectExceptionMessage('Base URI has no scheme or host'); + $this->expectExceptionMessage('Invalid Base URI'); $this->sendRequestToAnyEndpoint($decorator); } From 37a0550d954b299f80a7ae539dff14c4d34111b9 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 22 Mar 2024 14:57:21 +0100 Subject: [PATCH 80/93] Adds service url scheme and host validation --- .../HttpClient/Decorator/BaseUriDecoratorTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php b/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php index f5f1c59..677852f 100644 --- a/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php +++ b/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php @@ -36,10 +36,10 @@ public function send_request_with_base_schema(string $baseUri, string $expectedR /** * @test * @testWith - * ["example.com", "example.com/endpoint"] - * ["example.com/base/", "example.com/base/endpoint"] - * ["example.com:80", "//example.com/endpoint"] - * ["example.com:80/base/", "//example.com/base/endpoint"] + * ["example.com"] + * ["example.com/base/"] + * ["example.com:80"] + * ["example.com:80/base/"] * ["any://"] * ["any:///"] * ["any://:80/"] From 6d4b6200bea41043554aa82b9958556c4b07eace Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 22 Mar 2024 15:36:00 +0100 Subject: [PATCH 81/93] Adds service url with port support --- CHANGELOG.md | 1 + src/Curl/HttpClient.php | 8 +++++- .../HttpClient/Decorator/BaseUriDecorator.php | 2 ++ .../Decorator/BaseUriDecoratorTest.php | 28 +++++++++---------- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a46c0c1..b9497f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] ### Added - service url scheme and host validation +- service url with port support ### Changed - PSR-18 HTTP client related exceptions namespace moved diff --git a/src/Curl/HttpClient.php b/src/Curl/HttpClient.php index 2ef3ca6..7bfadcb 100644 --- a/src/Curl/HttpClient.php +++ b/src/Curl/HttpClient.php @@ -34,7 +34,13 @@ public function sendRequest(RequestInterface $request): ResponseInterface private function prepareRequestHttpClient(RequestInterface $request) { - $url = sprintf("%s://%s%s", $request->getUri()->getScheme(), $request->getUri()->getHost(), $request->getRequestTarget()); + $url = strtr("{scheme}://{host}{port}{path}", [ + '{scheme}' => $request->getUri()->getScheme(), + '{host}' => $request->getUri()->getHost(), + '{port}' => $request->getUri()->getPort() ? ':' . $request->getUri()->getPort() : '', + '{path}' => $request->getRequestTarget() + ]); + $httpClient = curl_init($url); if ($httpClient === false) { diff --git a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php index 1fa91f9..79cc2fc 100644 --- a/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php +++ b/src/Infrastructure/HttpClient/Decorator/BaseUriDecorator.php @@ -42,10 +42,12 @@ private function prependBaseUri(RequestInterface $request): RequestInterface $scheme = $baseUriParts['scheme'] ?? ''; $host = $baseUriParts['host'] ?? ''; + $port = $baseUriParts['port'] ?? null; $basePath = $baseUriParts['path'] ?? ''; $basePath = rtrim($basePath, '/'); $uri = $uri->withPath($basePath . '/' . $uri->getPath()); + $uri = $uri->withPort($port); $uri = $uri->withHost($host); $uri = $uri->withScheme($scheme); diff --git a/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php b/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php index 677852f..0e538bd 100644 --- a/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php +++ b/tests/Unit/Infrastructure/HttpClient/Decorator/BaseUriDecoratorTest.php @@ -19,8 +19,8 @@ class BaseUriDecoratorTest extends TestCase * ["http://example.com", "http://example.com/endpoint", "http"] * ["any://example.com", "any://example.com/endpoint", "any"] * ["any://example.com/base/", "any://example.com/base/endpoint", "any"] - * ["any://example.com:80", "any://example.com/endpoint", "any"] - * ["any://example.com:80/base/", "any://example.com/base/endpoint", "any"] + * ["any://example.com:80", "any://example.com:80/endpoint", "any"] + * ["any://example.com:80/base/", "any://example.com:80/base/endpoint", "any"] */ public function send_request_with_base_schema(string $baseUri, string $expectedRequestUri, string $expectedRequestSchema) { @@ -58,9 +58,9 @@ public function dont_send_request_without_base_schema_or_host(string $baseUri) * @test * @testWith * ["any://example.com", "any://example.com/endpoint", "example.com"] - * ["any://example.com:80", "any://example.com/endpoint", "example.com"] + * ["any://example.com:80", "any://example.com:80/endpoint", "example.com"] * ["any://example", "any://example/endpoint", "example"] - * ["any://example:80", "any://example/endpoint", "example"] + * ["any://example:80", "any://example:80/endpoint", "example"] */ public function send_request_with_base_host(string $baseUri, string $expectedRequestUri, string $expectedRequestHost) { @@ -76,8 +76,8 @@ public function send_request_with_base_host(string $baseUri, string $expectedReq /** * @test * @testWith - * ["any://example.com:80", "any://example.com/endpoint", ""] - * ["any://example:80", "any://example/endpoint", ""] + * ["any://example.com:80", "any://example.com:80/endpoint", "80"] + * ["any://example:80", "any://example:80/endpoint", "80"] */ public function send_request_with_base_port(string $baseUri, string $expectedRequestUri, string $expectedRequestPort) { @@ -113,12 +113,12 @@ public function send_request_without_base_port(string $baseUri, string $expected * @test * @testWith * ["any://example.com/base", "any://example.com/base/endpoint", "/base/endpoint"] - * ["any://example.com:80/base/", "any://example.com/base/endpoint", "/base/endpoint"] - * ["any://example:80/base", "any://example/base/endpoint", "/base/endpoint"] + * ["any://example.com:80/base/", "any://example.com:80/base/endpoint", "/base/endpoint"] + * ["any://example:80/base", "any://example:80/base/endpoint", "/base/endpoint"] * ["any://example.com/base/", "any://example.com/base/endpoint", "/base/endpoint"] * ["any://example/base/", "any://example/base/endpoint", "/base/endpoint"] - * ["any://example.com:80/base/", "any://example.com/base/endpoint", "/base/endpoint"] - * ["any://example:80/base", "any://example/base/endpoint", "/base/endpoint"] + * ["any://example.com:80/base/", "any://example.com:80/base/endpoint", "/base/endpoint"] + * ["any://example:80/base", "any://example:80/base/endpoint", "/base/endpoint"] */ public function send_request_with_base_path(string $baseUri, string $expectedRequestUri, string $expectedRequestPath) { @@ -136,12 +136,12 @@ public function send_request_with_base_path(string $baseUri, string $expectedReq * @testWith * ["any://example.com", "any://example.com/endpoint", "/endpoint"] * ["any://example", "any://example/endpoint", "/endpoint"] - * ["any://example.com:80", "any://example.com/endpoint", "/endpoint"] - * ["any://example:80", "any://example/endpoint", "/endpoint"] + * ["any://example.com:80", "any://example.com:80/endpoint", "/endpoint"] + * ["any://example:80", "any://example:80/endpoint", "/endpoint"] * ["any://example.com/", "any://example.com/endpoint", "/endpoint"] * ["any://example/", "any://example/endpoint", "/endpoint"] - * ["any://example.com:80/", "any://example.com/endpoint", "/endpoint"] - * ["any://example:80/", "any://example/endpoint", "/endpoint"] + * ["any://example.com:80/", "any://example.com:80/endpoint", "/endpoint"] + * ["any://example:80/", "any://example:80/endpoint", "/endpoint"] */ public function send_request_without_base_path(string $baseUri, string $expectedRequestUri, string $expectedRequestPath) { From 8536bbdf01cb373ba9df6fe23821d80cf35bd280 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Wed, 27 Mar 2024 10:19:53 +0100 Subject: [PATCH 82/93] Releases version 3.0.11 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9497f1..0e0c6f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.11] - 2024-03-27 ### Added - service url scheme and host validation - service url with port support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..e67e0c2 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.11'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 23469da106cc04ceee08c744c7555c1a6da92b3b Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 1 Jul 2025 12:14:15 +0000 Subject: [PATCH 83/93] Run tests against PHP 8.4 --- .github/workflows/tests.yml | 1 + build/Makefile | 3 +++ build/docker-compose.yml | 7 +++++++ build/php-8.4/Dockerfile | 18 ++++++++++++++++++ build/php-8.4/Makefile | 10 ++++++++++ 5 files changed, 39 insertions(+) create mode 100644 build/php-8.4/Dockerfile create mode 100644 build/php-8.4/Makefile diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ab815b5..e1fed77 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,7 @@ jobs: - 8.1 - 8.2 - 8.3 + - 8.4 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/build/Makefile b/build/Makefile index 21b9005..9c90389 100644 --- a/build/Makefile +++ b/build/Makefile @@ -9,6 +9,7 @@ include $(CURDIR)/php-8.0/Makefile include $(CURDIR)/php-8.1/Makefile include $(CURDIR)/php-8.2/Makefile include $(CURDIR)/php-8.3/Makefile +include $(CURDIR)/php-8.4/Makefile help: @grep -hE '^[a-zA-Z0-9_.-]+:.*?## .*$$' $(MAKEFILE_LIST) \ @@ -28,6 +29,7 @@ test: ## test all against all php images $(MAKE) test-php-8.1 $(MAKE) test-php-8.2 $(MAKE) test-php-8.3 + $(MAKE) test-php-8.4 test-unit: ## test unit suite against all php images $(MAKE) test-suite-php-7.0 SUITE=unit @@ -39,5 +41,6 @@ test-unit: ## test unit suite against all php images $(MAKE) test-suite-php-8.1 SUITE=unit $(MAKE) test-suite-php-8.2 SUITE=unit $(MAKE) test-suite-php-8.3 SUITE=unit + $(MAKE) test-suite-php-8.4 SUITE=unit .DEFAULT_GOAL := help diff --git a/build/docker-compose.yml b/build/docker-compose.yml index af9fe64..d3205f2 100644 --- a/build/docker-compose.yml +++ b/build/docker-compose.yml @@ -63,4 +63,11 @@ services: context: php-8.3 volumes: - ..:/app + network_mode: host + + php-8.4: + build: + context: php-8.4 + volumes: + - ..:/app network_mode: host \ No newline at end of file diff --git a/build/php-8.4/Dockerfile b/build/php-8.4/Dockerfile new file mode 100644 index 0000000..30effb1 --- /dev/null +++ b/build/php-8.4/Dockerfile @@ -0,0 +1,18 @@ +FROM composer:latest AS composer +FROM php:8.4-cli-alpine + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache \ + autoconf \ + g++ \ + make \ + linux-headers + +RUN pecl install xdebug-3.4.4 && \ + pecl clear-cache && \ + docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-8.4/Makefile b/build/php-8.4/Makefile new file mode 100644 index 0000000..326100b --- /dev/null +++ b/build/php-8.4/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-8.4 test-php-8.4 test-suite-php-8.4 + +prepare-php-8.4: ## load dependencies with php 8.4 + docker-compose run -T php-8.4 /usr/bin/composer update --ignore-platform-req=PHP + +test-php-8.4: prepare-php-8.4 ## run tests against php 8.4 + docker-compose run -T php-8.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-8.4: prepare-php-8.4 ## run suite tests against php 8.4, ex: make test-suite-php-8.4 SUITE="unit" + docker-compose run -T php-8.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file From 2f021ba2a0a3bb4329f80f1b4305ad81d4931992 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 1 Jul 2025 12:29:44 +0000 Subject: [PATCH 84/93] Run test workflow on pull request to master branch --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e1fed77..8abd84f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,6 +6,9 @@ on: - main - master pull_request: + branches: + - main + - master jobs: tests: From 22e79d6ff72447ab20167cb81c4596c23594e07d Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 1 Jul 2025 13:21:08 +0000 Subject: [PATCH 85/93] Mark methods that are to be changed in next major release. Implicitly marking parameter as nullable is deprecated since PHP 8.4. --- src/Feature/Contacts/ContactsFeature.php | 1 + src/Feature/Contacts/ContactsHttpFeature.php | 3 +++ src/Feature/Sms/Bag/ScheduleSmsBag.php | 3 +++ src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php | 3 +++ src/Feature/Sms/Bag/ScheduleSmssBag.php | 3 +++ src/Feature/Sms/Bag/SendSmsBag.php | 3 +++ src/Feature/Sms/Bag/SendSmsToGroupBag.php | 3 +++ src/Feature/Sms/Bag/SendSmssBag.php | 3 +++ 8 files changed, 22 insertions(+) diff --git a/src/Feature/Contacts/ContactsFeature.php b/src/Feature/Contacts/ContactsFeature.php index a1f2bfd..ed17b33 100644 --- a/src/Feature/Contacts/ContactsFeature.php +++ b/src/Feature/Contacts/ContactsFeature.php @@ -19,6 +19,7 @@ interface ContactsFeature { /** * @return Contact[] + * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 */ public function findContacts(FindContactsBag $findContactsBag = null): array; diff --git a/src/Feature/Contacts/ContactsHttpFeature.php b/src/Feature/Contacts/ContactsHttpFeature.php index 7d2f38c..86360bb 100644 --- a/src/Feature/Contacts/ContactsHttpFeature.php +++ b/src/Feature/Contacts/ContactsHttpFeature.php @@ -31,6 +31,9 @@ public function __construct(RestRequestExecutor $restRequestExecutor, DataFactor $this->dataFactoryProvider = $dataFactoryProvider; } + /** + * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + */ public function findContacts(FindContactsBag $findContactsBag = null): array { $result = $this->restRequestExecutor->read('contacts', (array)$findContactsBag); diff --git a/src/Feature/Sms/Bag/ScheduleSmsBag.php b/src/Feature/Sms/Bag/ScheduleSmsBag.php index 69257d4..3512917 100644 --- a/src/Feature/Sms/Bag/ScheduleSmsBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmsBag.php @@ -67,6 +67,9 @@ public function setParams(array $params): self return $this; } + /** + * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + */ public function setExternalId(string $idx, bool $checkIdx = null): self { $this->idx = [$idx]; diff --git a/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php b/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php index 3412f21..536ec8a 100644 --- a/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php @@ -55,6 +55,9 @@ public static function withTemplateName(DateTimeInterface $scheduleAt, string $g return $bag; } + /** + * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + */ public function setExternalId(string $idx, bool $checkIdx = null): self { $this->idx = [$idx]; diff --git a/src/Feature/Sms/Bag/ScheduleSmssBag.php b/src/Feature/Sms/Bag/ScheduleSmssBag.php index 3a1220d..d274e49 100644 --- a/src/Feature/Sms/Bag/ScheduleSmssBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmssBag.php @@ -68,6 +68,9 @@ public function setParams(array $params): self return $this; } + /** + * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + */ public function setExternalId(array $idx, bool $checkIdx = null): self { $this->idx = $idx; diff --git a/src/Feature/Sms/Bag/SendSmsBag.php b/src/Feature/Sms/Bag/SendSmsBag.php index 1391c37..eb4cef2 100644 --- a/src/Feature/Sms/Bag/SendSmsBag.php +++ b/src/Feature/Sms/Bag/SendSmsBag.php @@ -62,6 +62,9 @@ public function setParams(array $params): self return $this; } + /** + * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + */ public function setExternalId(string $idx, bool $checkIdx = null): self { $this->idx = [$idx]; diff --git a/src/Feature/Sms/Bag/SendSmsToGroupBag.php b/src/Feature/Sms/Bag/SendSmsToGroupBag.php index 98b944e..b41768d 100644 --- a/src/Feature/Sms/Bag/SendSmsToGroupBag.php +++ b/src/Feature/Sms/Bag/SendSmsToGroupBag.php @@ -48,6 +48,9 @@ public static function withTemplateName(string $group, string $templateName): se return $bag; } + /** + * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + */ public function setExternalId(string $idx, bool $checkIdx = null): self { $this->idx = [$idx]; diff --git a/src/Feature/Sms/Bag/SendSmssBag.php b/src/Feature/Sms/Bag/SendSmssBag.php index 383d6c0..d3cb370 100644 --- a/src/Feature/Sms/Bag/SendSmssBag.php +++ b/src/Feature/Sms/Bag/SendSmssBag.php @@ -63,6 +63,9 @@ public function setParams(array $params): self return $this; } + /** + * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + */ public function setExternalId(array $idx, bool $checkIdx = null): self { $this->idx = $idx; From 7d1510fe2bc004cea12c8756fd6c3da42a843f90 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 1 Jul 2025 13:24:08 +0000 Subject: [PATCH 86/93] Fix typo --- src/Feature/Contacts/ContactsFeature.php | 2 +- src/Feature/Contacts/ContactsHttpFeature.php | 2 +- src/Feature/Sms/Bag/ScheduleSmsBag.php | 2 +- src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php | 2 +- src/Feature/Sms/Bag/ScheduleSmssBag.php | 2 +- src/Feature/Sms/Bag/SendSmsBag.php | 2 +- src/Feature/Sms/Bag/SendSmsToGroupBag.php | 2 +- src/Feature/Sms/Bag/SendSmssBag.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Feature/Contacts/ContactsFeature.php b/src/Feature/Contacts/ContactsFeature.php index ed17b33..df9de39 100644 --- a/src/Feature/Contacts/ContactsFeature.php +++ b/src/Feature/Contacts/ContactsFeature.php @@ -19,7 +19,7 @@ interface ContactsFeature { /** * @return Contact[] - * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + * @todo method signature to be changed in next major release as implicitly marking parameter as nullable is deprecated since PHP 8.4 */ public function findContacts(FindContactsBag $findContactsBag = null): array; diff --git a/src/Feature/Contacts/ContactsHttpFeature.php b/src/Feature/Contacts/ContactsHttpFeature.php index 86360bb..7c73a56 100644 --- a/src/Feature/Contacts/ContactsHttpFeature.php +++ b/src/Feature/Contacts/ContactsHttpFeature.php @@ -32,7 +32,7 @@ public function __construct(RestRequestExecutor $restRequestExecutor, DataFactor } /** - * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + * @todo method signature to be changed in next major release as implicitly marking parameter as nullable is deprecated since PHP 8.4 */ public function findContacts(FindContactsBag $findContactsBag = null): array { diff --git a/src/Feature/Sms/Bag/ScheduleSmsBag.php b/src/Feature/Sms/Bag/ScheduleSmsBag.php index 3512917..2ce4b52 100644 --- a/src/Feature/Sms/Bag/ScheduleSmsBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmsBag.php @@ -68,7 +68,7 @@ public function setParams(array $params): self } /** - * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + * @todo method signature to be changed in next major release as implicitly marking parameter as nullable is deprecated since PHP 8.4 */ public function setExternalId(string $idx, bool $checkIdx = null): self { diff --git a/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php b/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php index 536ec8a..0981fd2 100644 --- a/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmsToGroupBag.php @@ -56,7 +56,7 @@ public static function withTemplateName(DateTimeInterface $scheduleAt, string $g } /** - * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + * @todo method signature to be changed in next major release as implicitly marking parameter as nullable is deprecated since PHP 8.4 */ public function setExternalId(string $idx, bool $checkIdx = null): self { diff --git a/src/Feature/Sms/Bag/ScheduleSmssBag.php b/src/Feature/Sms/Bag/ScheduleSmssBag.php index d274e49..b214567 100644 --- a/src/Feature/Sms/Bag/ScheduleSmssBag.php +++ b/src/Feature/Sms/Bag/ScheduleSmssBag.php @@ -69,7 +69,7 @@ public function setParams(array $params): self } /** - * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + * @todo method signature to be changed in next major release as implicitly marking parameter as nullable is deprecated since PHP 8.4 */ public function setExternalId(array $idx, bool $checkIdx = null): self { diff --git a/src/Feature/Sms/Bag/SendSmsBag.php b/src/Feature/Sms/Bag/SendSmsBag.php index eb4cef2..9ac48b5 100644 --- a/src/Feature/Sms/Bag/SendSmsBag.php +++ b/src/Feature/Sms/Bag/SendSmsBag.php @@ -63,7 +63,7 @@ public function setParams(array $params): self } /** - * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + * @todo method signature to be changed in next major release as implicitly marking parameter as nullable is deprecated since PHP 8.4 */ public function setExternalId(string $idx, bool $checkIdx = null): self { diff --git a/src/Feature/Sms/Bag/SendSmsToGroupBag.php b/src/Feature/Sms/Bag/SendSmsToGroupBag.php index b41768d..a6da846 100644 --- a/src/Feature/Sms/Bag/SendSmsToGroupBag.php +++ b/src/Feature/Sms/Bag/SendSmsToGroupBag.php @@ -49,7 +49,7 @@ public static function withTemplateName(string $group, string $templateName): se } /** - * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + * @todo method signature to be changed in next major release as implicitly marking parameter as nullable is deprecated since PHP 8.4 */ public function setExternalId(string $idx, bool $checkIdx = null): self { diff --git a/src/Feature/Sms/Bag/SendSmssBag.php b/src/Feature/Sms/Bag/SendSmssBag.php index d3cb370..279bc53 100644 --- a/src/Feature/Sms/Bag/SendSmssBag.php +++ b/src/Feature/Sms/Bag/SendSmssBag.php @@ -64,7 +64,7 @@ public function setParams(array $params): self } /** - * @todo method signature to be changed in next major release as implicitly marking parameters as nullable is deprecated since PHP 8.4 + * @todo method signature to be changed in next major release as implicitly marking parameter as nullable is deprecated since PHP 8.4 */ public function setExternalId(array $idx, bool $checkIdx = null): self { From e551d3af414a0f8c4f6deb22d9bba39937b8e8b3 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Tue, 1 Jul 2025 14:06:53 +0000 Subject: [PATCH 87/93] Add PHP 8.4 support. --- CHANGELOG.md | 4 ++++ build/php-8.3/Makefile | 2 +- build/php-8.4/Makefile | 2 +- composer.json | 2 +- src/SmsapiClient.php | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e0c6f8..4231563 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Added +- PHP-8.4 support + ## [3.0.11] - 2024-03-27 ### Added - service url scheme and host validation diff --git a/build/php-8.3/Makefile b/build/php-8.3/Makefile index edb5c99..3b913f1 100644 --- a/build/php-8.3/Makefile +++ b/build/php-8.3/Makefile @@ -1,7 +1,7 @@ .PHONY: prepare-php-8.3 test-php-8.3 test-suite-php-8.3 prepare-php-8.3: ## load dependencies with php 8.3 - docker-compose run -T php-8.3 /usr/bin/composer update --ignore-platform-req=PHP + docker-compose run -T php-8.3 /usr/bin/composer update test-php-8.3: prepare-php-8.3 ## run tests against php 8.3 docker-compose run -T php-8.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml diff --git a/build/php-8.4/Makefile b/build/php-8.4/Makefile index 326100b..05d45e3 100644 --- a/build/php-8.4/Makefile +++ b/build/php-8.4/Makefile @@ -1,7 +1,7 @@ .PHONY: prepare-php-8.4 test-php-8.4 test-suite-php-8.4 prepare-php-8.4: ## load dependencies with php 8.4 - docker-compose run -T php-8.4 /usr/bin/composer update --ignore-platform-req=PHP + docker-compose run -T php-8.4 /usr/bin/composer update test-php-8.4: prepare-php-8.4 ## run tests against php 8.4 docker-compose run -T php-8.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml diff --git a/composer.json b/composer.json index 31269cb..ee46693 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": "^7 || ~8.0 || ~8.1 || ~8.2 || ~8.3", + "php": "^7 || ~8.0 || ~8.1 || ~8.2 || ~8.3 || ~8.4", "ext-json": "*", "psr/log": "^1 || ^2 || ^3", "psr/http-message": "~1.0 || ~1.1 || ~2.0", diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index e67e0c2..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.11'; + const VERSION = 'Unreleased'; public function smsapiPlService(string $apiToken): SmsapiPlService; From b4305a817083a43a58affa2502f47fee78602bfb Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Thu, 3 Jul 2025 11:47:02 +0000 Subject: [PATCH 88/93] Release version 3.0.12 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4231563..f8f636e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.12] - 2025-07-03 ### Added - PHP-8.4 support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..eb8591a 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.12'; public function smsapiPlService(string $apiToken): SmsapiPlService; From fca4a1ba99f8910975053083033345cfe71d6556 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 12 Jan 2026 10:11:01 +0100 Subject: [PATCH 89/93] Adjust to docker compose CLI API changes. --- build/Makefile | 2 +- build/php-7.0/Makefile | 6 +++--- build/php-7.1/Makefile | 6 +++--- build/php-7.2/Makefile | 6 +++--- build/php-7.3/Makefile | 6 +++--- build/php-7.4/Makefile | 6 +++--- build/php-8.0/Makefile | 6 +++--- build/php-8.1/Makefile | 6 +++--- build/php-8.2/Makefile | 6 +++--- build/php-8.3/Makefile | 6 +++--- build/php-8.4/Makefile | 6 +++--- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/build/Makefile b/build/Makefile index 9c90389..5d807b1 100644 --- a/build/Makefile +++ b/build/Makefile @@ -17,7 +17,7 @@ help: | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' build: ## build php images - docker-compose build + docker compose build test: ## test all against all php images $(MAKE) test-php-7.0 diff --git a/build/php-7.0/Makefile b/build/php-7.0/Makefile index 9f16c05..62c467c 100644 --- a/build/php-7.0/Makefile +++ b/build/php-7.0/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-7.0 test-php-7.0 test-suite-php-7.0 prepare-php-7.0: ## load dependencies with php 7.0 - docker-compose run -T php-7.0 /usr/bin/composer update + docker compose run -T php-7.0 /usr/bin/composer update test-php-7.0: prepare-php-7.0 ## run tests against php 7.0 - docker-compose run -T php-7.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-7.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-7.0: prepare-php-7.0 ## run suite tests against php 7.0, ex: make test-suite-php-7.0 SUITE="unit" - docker-compose run -T php-7.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-7.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-7.1/Makefile b/build/php-7.1/Makefile index b3a33d3..26cbfad 100644 --- a/build/php-7.1/Makefile +++ b/build/php-7.1/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-7.1 test-php-7.1 test-suite-php-7.1 prepare-php-7.1: ## load dependencies with php 7.1 - docker-compose run -T php-7.1 /usr/bin/composer update + docker compose run -T php-7.1 /usr/bin/composer update test-php-7.1: prepare-php-7.1 ## run tests against php 7.1 - docker-compose run -T php-7.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-7.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-7.1: prepare-php-7.1 ## run suite tests against php 7.1, ex: make test-suite-php-7.1 SUITE="unit" - docker-compose run -T php-7.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-7.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-7.2/Makefile b/build/php-7.2/Makefile index 46d4374..6cb0833 100644 --- a/build/php-7.2/Makefile +++ b/build/php-7.2/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-7.2 test-php-7.2 test-suite-php-7.2 prepare-php-7.2: ## load dependencies with php 7.2 - docker-compose run -T php-7.2 /usr/bin/composer update + docker compose run -T php-7.2 /usr/bin/composer update test-php-7.2: prepare-php-7.2 ## run tests against php 7.2 - docker-compose run -T php-7.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-7.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-7.2: prepare-php-7.2 ## run suite tests against php 7.2, ex: make test-suite-php-7.2 SUITE="unit" - docker-compose run -T php-7.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-7.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-7.3/Makefile b/build/php-7.3/Makefile index d866e53..99e7817 100644 --- a/build/php-7.3/Makefile +++ b/build/php-7.3/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-7.3 test-php-7.3 test-suite-php-7.3 prepare-php-7.3: ## load dependencies with php 7.3 - docker-compose run -T php-7.3 /usr/bin/composer update + docker compose run -T php-7.3 /usr/bin/composer update test-php-7.3: prepare-php-7.3 ## run tests against php 7.3 - docker-compose run -T php-7.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-7.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-7.3: prepare-php-7.3 ## run suite tests against php 7.3, ex: make test-suite-php-7.3 SUITE="unit" - docker-compose run -T php-7.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-7.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-7.4/Makefile b/build/php-7.4/Makefile index 412c121..d68c343 100644 --- a/build/php-7.4/Makefile +++ b/build/php-7.4/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-7.4 test-php-7.4 test-suite-php-7.4 prepare-php-7.4: ## load dependencies with php 7.4 - docker-compose run -T php-7.4 /usr/bin/composer update + docker compose run -T php-7.4 /usr/bin/composer update test-php-7.4: prepare-php-7.4 ## run tests against php 7.4 - docker-compose run -T php-7.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-7.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-7.4: prepare-php-7.4 ## run suite tests against php 7.4, ex: make test-suite-php-7.4 SUITE="unit" - docker-compose run -T php-7.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-7.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-8.0/Makefile b/build/php-8.0/Makefile index e834ead..b8b7eaf 100644 --- a/build/php-8.0/Makefile +++ b/build/php-8.0/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-8.0 test-php-8.0 test-suite-php-8.0 prepare-php-8.0: ## load dependencies with php 8.0 - docker-compose run -T php-8.0 /usr/bin/composer update + docker compose run -T php-8.0 /usr/bin/composer update test-php-8.0: prepare-php-8.0 ## run tests against php 8.0 - docker-compose run -T php-8.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-8.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-8.0: prepare-php-8.0 ## run suite tests against php 8.0, ex: make test-suite-php-8.0 SUITE="unit" - docker-compose run -T php-8.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-8.0 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-8.1/Makefile b/build/php-8.1/Makefile index 517275d..607d37b 100644 --- a/build/php-8.1/Makefile +++ b/build/php-8.1/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-8.1 test-php-8.1 test-suite-php-8.1 prepare-php-8.1: ## load dependencies with php 8.1 - docker-compose run -T php-8.1 /usr/bin/composer update + docker compose run -T php-8.1 /usr/bin/composer update test-php-8.1: prepare-php-8.1 ## run tests against php 8.1 - docker-compose run -T php-8.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-8.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-8.1: prepare-php-8.1 ## run suite tests against php 8.1, ex: make test-suite-php-8.1 SUITE="unit" - docker-compose run -T php-8.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-8.1 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-8.2/Makefile b/build/php-8.2/Makefile index c7788aa..3867be5 100644 --- a/build/php-8.2/Makefile +++ b/build/php-8.2/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-8.2 test-php-8.2 test-suite-php-8.2 prepare-php-8.2: ## load dependencies with php 8.2 - docker-compose run -T php-8.2 /usr/bin/composer update + docker compose run -T php-8.2 /usr/bin/composer update test-php-8.2: prepare-php-8.2 ## run tests against php 8.2 - docker-compose run -T php-8.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-8.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-8.2: prepare-php-8.2 ## run suite tests against php 8.2, ex: make test-suite-php-8.2 SUITE="unit" - docker-compose run -T php-8.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-8.2 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-8.3/Makefile b/build/php-8.3/Makefile index 3b913f1..886f5d4 100644 --- a/build/php-8.3/Makefile +++ b/build/php-8.3/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-8.3 test-php-8.3 test-suite-php-8.3 prepare-php-8.3: ## load dependencies with php 8.3 - docker-compose run -T php-8.3 /usr/bin/composer update + docker compose run -T php-8.3 /usr/bin/composer update test-php-8.3: prepare-php-8.3 ## run tests against php 8.3 - docker-compose run -T php-8.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-8.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-8.3: prepare-php-8.3 ## run suite tests against php 8.3, ex: make test-suite-php-8.3 SUITE="unit" - docker-compose run -T php-8.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-8.3 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/build/php-8.4/Makefile b/build/php-8.4/Makefile index 05d45e3..bd4cfd0 100644 --- a/build/php-8.4/Makefile +++ b/build/php-8.4/Makefile @@ -1,10 +1,10 @@ .PHONY: prepare-php-8.4 test-php-8.4 test-suite-php-8.4 prepare-php-8.4: ## load dependencies with php 8.4 - docker-compose run -T php-8.4 /usr/bin/composer update + docker compose run -T php-8.4 /usr/bin/composer update test-php-8.4: prepare-php-8.4 ## run tests against php 8.4 - docker-compose run -T php-8.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + docker compose run -T php-8.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml test-suite-php-8.4: prepare-php-8.4 ## run suite tests against php 8.4, ex: make test-suite-php-8.4 SUITE="unit" - docker-compose run -T php-8.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file + docker compose run -T php-8.4 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file From f656ac6ed137d586ca7744857b13a8965ca33edf Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 12 Jan 2026 10:21:53 +0100 Subject: [PATCH 90/93] Add PHP 8.5 support --- .github/workflows/tests.yml | 1 + CHANGELOG.md | 4 ++++ build/docker-compose.yml | 7 +++++++ build/php-8.5/Dockerfile | 6 ++++++ build/php-8.5/Makefile | 10 ++++++++++ composer.json | 2 +- src/SmsapiClient.php | 2 +- 7 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 build/php-8.5/Dockerfile create mode 100644 build/php-8.5/Makefile diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8abd84f..1657a68 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,6 +27,7 @@ jobs: - 8.2 - 8.3 - 8.4 + - 8.5 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index f8f636e..289fc09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Added +- PHP-8.5 support + ## [3.0.12] - 2025-07-03 ### Added - PHP-8.4 support diff --git a/build/docker-compose.yml b/build/docker-compose.yml index d3205f2..dcbfba0 100644 --- a/build/docker-compose.yml +++ b/build/docker-compose.yml @@ -70,4 +70,11 @@ services: context: php-8.4 volumes: - ..:/app + network_mode: host + + php-8.5: + build: + context: php-8.5 + volumes: + - ..:/app network_mode: host \ No newline at end of file diff --git a/build/php-8.5/Dockerfile b/build/php-8.5/Dockerfile new file mode 100644 index 0000000..c93d62d --- /dev/null +++ b/build/php-8.5/Dockerfile @@ -0,0 +1,6 @@ +FROM composer:latest AS composer +FROM php:8.5-cli-alpine + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /app/ \ No newline at end of file diff --git a/build/php-8.5/Makefile b/build/php-8.5/Makefile new file mode 100644 index 0000000..3a38702 --- /dev/null +++ b/build/php-8.5/Makefile @@ -0,0 +1,10 @@ +.PHONY: prepare-php-8.5 test-php-8.5 test-suite-php-8.5 + +prepare-php-8.5: ## load dependencies with php 8.5 + docker compose run -T php-8.5 /usr/bin/composer update + +test-php-8.5: prepare-php-8.5 ## run tests against php 8.5 + docker compose run -T php-8.5 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml + +test-suite-php-8.5: prepare-php-8.5 ## run suite tests against php 8.5, ex: make test-suite-php-8.5 SUITE="unit" + docker compose run -T php-8.5 php vendor/bin/phpunit --configuration tests-resources/phpunit.xml --testsuite $(SUITE) \ No newline at end of file diff --git a/composer.json b/composer.json index ee46693..dd8d42e 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": "^7 || ~8.0 || ~8.1 || ~8.2 || ~8.3 || ~8.4", + "php": "^7 || ~8.0 || ~8.1 || ~8.2 || ~8.3 || ~8.4 || ~8.5", "ext-json": "*", "psr/log": "^1 || ^2 || ^3", "psr/http-message": "~1.0 || ~1.1 || ~2.0", diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index eb8591a..564843f 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = '3.0.12'; + const VERSION = 'Unreleased'; public function smsapiPlService(string $apiToken): SmsapiPlService; From a58a422feb9bd8652dd2893a9a2e5653e8c83764 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Mon, 12 Jan 2026 11:56:43 +0100 Subject: [PATCH 91/93] Release version 3.0.13 --- CHANGELOG.md | 2 +- src/SmsapiClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 289fc09..190eb08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [3.0.13] - 2026-01-12 ### Added - PHP-8.5 support diff --git a/src/SmsapiClient.php b/src/SmsapiClient.php index 564843f..1c2bc2b 100644 --- a/src/SmsapiClient.php +++ b/src/SmsapiClient.php @@ -12,7 +12,7 @@ */ interface SmsapiClient extends LoggerAwareInterface { - const VERSION = 'Unreleased'; + const VERSION = '3.0.13'; public function smsapiPlService(string $apiToken): SmsapiPlService; From 394f7b14c788ab36a46ea91f656df51ba569f3d0 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 27 Mar 2026 15:00:14 +0100 Subject: [PATCH 92/93] Remove xdebug from test images. Mitigate pecl installation issues. --- build/php-7.1/Dockerfile | 9 +-------- build/php-7.2/Dockerfile | 9 +-------- build/php-7.3/Dockerfile | 9 +-------- build/php-7.4/Dockerfile | 9 +-------- build/php-8.0/Dockerfile | 9 +-------- build/php-8.1/Dockerfile | 9 +-------- build/php-8.2/Dockerfile | 10 +--------- build/php-8.3/Dockerfile | 10 +--------- build/php-8.4/Dockerfile | 10 +--------- 9 files changed, 9 insertions(+), 75 deletions(-) diff --git a/build/php-7.1/Dockerfile b/build/php-7.1/Dockerfile index 690c835..2a0487e 100644 --- a/build/php-7.1/Dockerfile +++ b/build/php-7.1/Dockerfile @@ -3,14 +3,7 @@ FROM php:7.1-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make - -RUN pecl install xdebug-2.9.8 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/build/php-7.2/Dockerfile b/build/php-7.2/Dockerfile index 0876175..bd7b230 100644 --- a/build/php-7.2/Dockerfile +++ b/build/php-7.2/Dockerfile @@ -3,14 +3,7 @@ FROM php:7.2-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make - -RUN pecl install xdebug-2.9.8 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/build/php-7.3/Dockerfile b/build/php-7.3/Dockerfile index e2dee2e..28ef4fc 100644 --- a/build/php-7.3/Dockerfile +++ b/build/php-7.3/Dockerfile @@ -3,14 +3,7 @@ FROM php:7.3-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make - -RUN pecl install xdebug-2.9.8 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/build/php-7.4/Dockerfile b/build/php-7.4/Dockerfile index 24a17d3..d810922 100644 --- a/build/php-7.4/Dockerfile +++ b/build/php-7.4/Dockerfile @@ -3,14 +3,7 @@ FROM php:7.4-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make - -RUN pecl install xdebug-2.9.8 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/build/php-8.0/Dockerfile b/build/php-8.0/Dockerfile index b75744e..04a6435 100644 --- a/build/php-8.0/Dockerfile +++ b/build/php-8.0/Dockerfile @@ -3,14 +3,7 @@ FROM php:8.0-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make - -RUN pecl install xdebug-3.1.6 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/build/php-8.1/Dockerfile b/build/php-8.1/Dockerfile index a68b5e2..70aea88 100644 --- a/build/php-8.1/Dockerfile +++ b/build/php-8.1/Dockerfile @@ -3,14 +3,7 @@ FROM php:8.1-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make - -RUN pecl install xdebug-3.1.6 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/build/php-8.2/Dockerfile b/build/php-8.2/Dockerfile index 9092d51..677d0ad 100644 --- a/build/php-8.2/Dockerfile +++ b/build/php-8.2/Dockerfile @@ -3,15 +3,7 @@ FROM php:8.2-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make \ - linux-headers - -RUN pecl install xdebug-3.2.2 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/build/php-8.3/Dockerfile b/build/php-8.3/Dockerfile index 97fdde4..94ac096 100644 --- a/build/php-8.3/Dockerfile +++ b/build/php-8.3/Dockerfile @@ -3,15 +3,7 @@ FROM php:8.3-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make \ - linux-headers - -RUN pecl install xdebug-3.3.1 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer diff --git a/build/php-8.4/Dockerfile b/build/php-8.4/Dockerfile index 30effb1..ba691e0 100644 --- a/build/php-8.4/Dockerfile +++ b/build/php-8.4/Dockerfile @@ -3,15 +3,7 @@ FROM php:8.4-cli-alpine RUN apk update && \ apk upgrade && \ - apk add --no-cache \ - autoconf \ - g++ \ - make \ - linux-headers - -RUN pecl install xdebug-3.4.4 && \ - pecl clear-cache && \ - docker-php-ext-enable xdebug + apk add --no-cache make COPY --from=composer /usr/bin/composer /usr/bin/composer From 740353da4bd89d26adeaca0e7621d688bec073b5 Mon Sep 17 00:00:00 2001 From: Maciej Lew Date: Fri, 27 Mar 2026 15:03:32 +0100 Subject: [PATCH 93/93] Switch to non-blocking dependencies audit. --- .github/workflows/tests.yml | 3 +++ composer.json | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1657a68..9385edd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,5 +49,8 @@ jobs: - name: Install dependencies run: composer update --prefer-dist --no-interaction + - name: Audit dependencies + run: composer audit || true + - name: Running unit tests run: php vendor/bin/phpunit --configuration tests-resources/phpunit.dist.xml --testsuite unit diff --git a/composer.json b/composer.json index dd8d42e..8c5dad5 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,7 @@ "phpdocumentor/reflection-docblock": "^4.3 || ^5.2.0", "phpdocumentor/type-resolver": "^0.5 || ^1.3.0", "guzzlehttp/psr7": "^1 || ^2", - "ext-curl": "*", - "roave/security-advisories": "dev-latest" + "ext-curl": "*" }, "suggest": { "ext-curl": "To use Curl HttpClient",