From 4158951d709612b8a7b2d1da758f77a5df5cff91 Mon Sep 17 00:00:00 2001 From: James Seconde Date: Mon, 14 Oct 2024 20:13:00 +0100 Subject: [PATCH] Linting Scrub (#516) * Code sniffer auto fixes * Friends of PHP code lint fixer * Whoops, fix composer.json --- src/Account/Price.php | 1 + src/Client.php | 4 +- src/Client/APIClient.php | 1 + src/Client/APIExceptionHandler.php | 1 + src/Client/APIResource.php | 9 +- .../Credentials/Handler/BasicHandler.php | 2 +- .../Credentials/Handler/BasicQueryHandler.php | 2 +- .../Credentials/Handler/GnpKeypairHandler.php | 2 +- .../Credentials/Handler/HandlerInterface.php | 2 +- .../Credentials/Handler/KeypairHandler.php | 2 +- .../Handler/TokenBodyFormHandler.php | 2 +- .../Credentials/Handler/TokenQueryHandler.php | 2 +- src/Client/Exception/Validation.php | 8 +- src/Client/Factory/MapFactory.php | 3 +- src/Client/InvalidResponseException.php | 1 + src/Client/Request/RequestInterface.php | 1 - src/Client/Signature.php | 10 +- src/Conversation/Client.php | 2 +- src/Entity/Filter/EmptyFilter.php | 1 - src/Insights/Basic.php | 1 + src/Meetings/ExceptionErrorHandler.php | 1 - src/Meetings/Room.php | 2 +- src/Messages/Channel/MMS/MMSImage.php | 2 +- .../Messenger/InvalidCategoryException.php | 2 +- .../Channel/Messenger/MessengerVideo.php | 2 +- .../Channel/RCS/RcsInvalidTtlException.php | 2 +- src/Messages/Channel/Viber/ViberImage.php | 8 +- src/Messages/Channel/Viber/ViberText.php | 8 +- .../WhatsApp/MessageObjects/StickerObject.php | 2 +- src/Messages/ClientFactory.php | 2 +- src/NumberVerification/ClientFactory.php | 2 +- src/Numbers/Client.php | 2 +- src/ProactiveConnect/ClientFactory.php | 2 +- src/ProactiveConnect/Objects/ManualList.php | 2 +- .../Objects/SalesforceList.php | 2 +- src/SimSwap/ClientFactory.php | 2 +- src/Subaccount/Client.php | 16 +- src/Subaccount/ClientFactory.php | 2 +- src/Subaccount/Filter/SubaccountFilter.php | 2 +- src/Verify2/ClientFactory.php | 2 +- src/Verify2/Request/BaseVerifyRequest.php | 2 +- src/Verify2/Request/RequestInterface.php | 2 +- src/Verify2/Traits/CustomTemplateTrait.php | 2 +- .../VerifyObjects/VerificationLocale.php | 2 +- src/Voice/Endpoint/EndpointFactory.php | 1 - src/Voice/Endpoint/EndpointInterface.php | 1 - test/Application/ClientTest.php | 1 + .../Handler/BasicQueryHandlerTest.php | 2 +- .../Credentials/Handler/GnpHandlerTest.php | 45 +++- test/Client/Exception/Validation.php | 1 + test/Conversation/ClientTest.php | 225 +++++++++++++++--- test/Insights/AdvancedTest.php | 2 +- test/Insights/ClientTest.php | 12 +- test/Logger/LoggerTraitTest.php | 2 +- test/Meetings/ClientTest.php | 24 +- test/Numbers/ClientTest.php | 57 +++-- test/Numbers/Filter/AvailableNumbersTest.php | 2 +- test/ProactiveConnect/ClientTest.php | 12 +- test/Redact/ClientTest.php | 2 +- test/SMS/ClientTest.php | 5 +- test/SimSwap/ClientTest.php | 13 +- test/Subaccount/ClientFactoryTest.php | 12 +- test/Subaccount/ClientTest.php | 4 +- test/Verify/ClientTest.php | 1 + test/Verify/ExceptionErrorHandlerTest.php | 2 +- test/Verify/VerificationTest.php | 1 + test/Verify2/ClientTest.php | 120 +++++++--- test/Voice/ClientTest.php | 11 +- test/VonageTestCase.php | 2 +- 69 files changed, 501 insertions(+), 189 deletions(-) diff --git a/src/Account/Price.php b/src/Account/Price.php index 8cdb2079..190f85e1 100644 --- a/src/Account/Price.php +++ b/src/Account/Price.php @@ -10,6 +10,7 @@ use Vonage\Entity\JsonResponseTrait; use Vonage\Entity\JsonSerializableTrait; use Vonage\Entity\NoRequestResponseTrait; + use function array_key_exists; use function ltrim; use function preg_replace; diff --git a/src/Client.php b/src/Client.php index d254b6d2..aa866fb4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -210,7 +210,7 @@ public function __construct( // Additional utility classes APIResource::class => APIResource::class, - Client::class => fn() => $this + Client::class => fn () => $this ]; if (class_exists('Vonage\Video\ClientFactory')) { @@ -231,7 +231,7 @@ public function __construct( // Disable throwing E_USER_DEPRECATED notices by default, the user can turn it on during development if (array_key_exists('show_deprecations', $this->options) && ($this->options['show_deprecations'] == true)) { set_error_handler( - static fn(int $errno, string $errstr, string $errfile = null, int $errline = null, array $errorcontext = null) => true, + static fn (int $errno, string $errstr, string $errfile = null, int $errline = null, array $errorcontext = null) => true, E_USER_DEPRECATED ); } diff --git a/src/Client/APIClient.php b/src/Client/APIClient.php index 241ca65b..f7e58911 100644 --- a/src/Client/APIClient.php +++ b/src/Client/APIClient.php @@ -1,4 +1,5 @@ getBaseUrl() . $this->baseUri . '/' . $id; // This is a necessary hack if you want to fetch a totally different URL but use Vonage Auth diff --git a/src/Client/Credentials/Handler/BasicHandler.php b/src/Client/Credentials/Handler/BasicHandler.php index 72cbd6d9..b911724f 100644 --- a/src/Client/Credentials/Handler/BasicHandler.php +++ b/src/Client/Credentials/Handler/BasicHandler.php @@ -17,4 +17,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden return $request->withHeader('Authorization', 'Basic ' . $cx); } -} \ No newline at end of file +} diff --git a/src/Client/Credentials/Handler/BasicQueryHandler.php b/src/Client/Credentials/Handler/BasicQueryHandler.php index b75ba5b2..f8861827 100644 --- a/src/Client/Credentials/Handler/BasicQueryHandler.php +++ b/src/Client/Credentials/Handler/BasicQueryHandler.php @@ -16,4 +16,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden return $request->withUri($request->getUri()->withQuery(http_build_query($query))); } -} \ No newline at end of file +} diff --git a/src/Client/Credentials/Handler/GnpKeypairHandler.php b/src/Client/Credentials/Handler/GnpKeypairHandler.php index 2b810cd7..ab4f2dc5 100644 --- a/src/Client/Credentials/Handler/GnpKeypairHandler.php +++ b/src/Client/Credentials/Handler/GnpKeypairHandler.php @@ -17,4 +17,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden return $request->withHeader('Authorization', 'Bearer ' . $token->toString()); } -} \ No newline at end of file +} diff --git a/src/Client/Credentials/Handler/HandlerInterface.php b/src/Client/Credentials/Handler/HandlerInterface.php index f7a81bb9..9f86d5b1 100644 --- a/src/Client/Credentials/Handler/HandlerInterface.php +++ b/src/Client/Credentials/Handler/HandlerInterface.php @@ -10,5 +10,5 @@ interface HandlerInterface /** * Add authentication to a request */ - function __invoke(RequestInterface $request, CredentialsInterface $credentials): RequestInterface; + public function __invoke(RequestInterface $request, CredentialsInterface $credentials): RequestInterface; } diff --git a/src/Client/Credentials/Handler/KeypairHandler.php b/src/Client/Credentials/Handler/KeypairHandler.php index 0147a0f1..920ff45c 100644 --- a/src/Client/Credentials/Handler/KeypairHandler.php +++ b/src/Client/Credentials/Handler/KeypairHandler.php @@ -16,4 +16,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden return $request->withHeader('Authorization', 'Bearer ' . $token->toString()); } -} \ No newline at end of file +} diff --git a/src/Client/Credentials/Handler/TokenBodyFormHandler.php b/src/Client/Credentials/Handler/TokenBodyFormHandler.php index 57f25cb2..202688a0 100644 --- a/src/Client/Credentials/Handler/TokenBodyFormHandler.php +++ b/src/Client/Credentials/Handler/TokenBodyFormHandler.php @@ -22,4 +22,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden return $request; } -} \ No newline at end of file +} diff --git a/src/Client/Credentials/Handler/TokenQueryHandler.php b/src/Client/Credentials/Handler/TokenQueryHandler.php index 8f49aeaa..5758aa33 100644 --- a/src/Client/Credentials/Handler/TokenQueryHandler.php +++ b/src/Client/Credentials/Handler/TokenQueryHandler.php @@ -19,4 +19,4 @@ public function __invoke(RequestInterface $request, CredentialsInterface $creden return $request; } -} \ No newline at end of file +} diff --git a/src/Client/Exception/Validation.php b/src/Client/Exception/Validation.php index d882686a..27d4bb25 100644 --- a/src/Client/Exception/Validation.php +++ b/src/Client/Exception/Validation.php @@ -8,8 +8,12 @@ class Validation extends Request { - public function __construct(string $message = '', int $code = 0, Throwable $previous = null, private readonly array $errors = []) - { + public function __construct( + string $message = '', + int $code = 0, + Throwable $previous = null, + private readonly array $errors = [] + ) { parent::__construct($message, $code, $previous); } diff --git a/src/Client/Factory/MapFactory.php b/src/Client/Factory/MapFactory.php index f28c7d72..8008ad6b 100644 --- a/src/Client/Factory/MapFactory.php +++ b/src/Client/Factory/MapFactory.php @@ -34,8 +34,7 @@ public function __construct( * Vonage Client */ protected Client $client - ) - { + ) { } /** diff --git a/src/Client/InvalidResponseException.php b/src/Client/InvalidResponseException.php index d07f66e2..66f3a023 100644 --- a/src/Client/InvalidResponseException.php +++ b/src/Client/InvalidResponseException.php @@ -1,4 +1,5 @@ signed = $params; if (!isset($this->signed['timestamp'])) { diff --git a/src/Conversation/Client.php b/src/Conversation/Client.php index 4a312483..f7bac303 100644 --- a/src/Conversation/Client.php +++ b/src/Conversation/Client.php @@ -103,7 +103,7 @@ public function listMembersByConversationId( ?ListMembersFilter $filter = null ): IterableAPICollection { $api = clone $this->getAPIResource(); - $api->setBaseUrl('https://api.nexmo.com/v1/users'); + $api->setBaseUrl('https://api.nexmo.com/v1/users/'); $api->setCollectionName('members'); $response = $api->search($filter, $conversationId . '/members'); $response->setHasPagination(true); diff --git a/src/Entity/Filter/EmptyFilter.php b/src/Entity/Filter/EmptyFilter.php index 0085e5f0..8cbec4d2 100644 --- a/src/Entity/Filter/EmptyFilter.php +++ b/src/Entity/Filter/EmptyFilter.php @@ -6,7 +6,6 @@ class EmptyFilter implements FilterInterface { - public function getQuery(): array { return []; diff --git a/src/Insights/Basic.php b/src/Insights/Basic.php index cad79221..1e25a2c7 100644 --- a/src/Insights/Basic.php +++ b/src/Insights/Basic.php @@ -5,6 +5,7 @@ namespace Vonage\Insights; use Vonage\Entity\Hydrator\ArrayHydrateInterface; + class Basic implements ArrayHydrateInterface { protected array $data = []; diff --git a/src/Meetings/ExceptionErrorHandler.php b/src/Meetings/ExceptionErrorHandler.php index 6fd1073b..b4711160 100644 --- a/src/Meetings/ExceptionErrorHandler.php +++ b/src/Meetings/ExceptionErrorHandler.php @@ -6,7 +6,6 @@ use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; - use Vonage\Client\Exception\Conflict; use Vonage\Client\Exception\Credentials; use Vonage\Client\Exception\NotFound; diff --git a/src/Meetings/Room.php b/src/Meetings/Room.php index 448fdcdc..93a0529a 100644 --- a/src/Meetings/Room.php +++ b/src/Meetings/Room.php @@ -21,7 +21,7 @@ public function fromArray(array $data): static public function toArray(): array { - return array_filter($this->data, static fn($value) => $value !== ''); + return array_filter($this->data, static fn ($value) => $value !== ''); } public function __get($value) diff --git a/src/Messages/Channel/MMS/MMSImage.php b/src/Messages/Channel/MMS/MMSImage.php index d99a469e..a92c76a3 100644 --- a/src/Messages/Channel/MMS/MMSImage.php +++ b/src/Messages/Channel/MMS/MMSImage.php @@ -33,4 +33,4 @@ public function toArray(): array return $returnArray; } -} \ No newline at end of file +} diff --git a/src/Messages/Channel/Messenger/InvalidCategoryException.php b/src/Messages/Channel/Messenger/InvalidCategoryException.php index a6acdb39..636568d0 100644 --- a/src/Messages/Channel/Messenger/InvalidCategoryException.php +++ b/src/Messages/Channel/Messenger/InvalidCategoryException.php @@ -4,4 +4,4 @@ class InvalidCategoryException extends \Exception { -} \ No newline at end of file +} diff --git a/src/Messages/Channel/Messenger/MessengerVideo.php b/src/Messages/Channel/Messenger/MessengerVideo.php index fd0394e4..a88f4e6b 100644 --- a/src/Messages/Channel/Messenger/MessengerVideo.php +++ b/src/Messages/Channel/Messenger/MessengerVideo.php @@ -36,4 +36,4 @@ public function toArray(): array return $returnArray; } -} \ No newline at end of file +} diff --git a/src/Messages/Channel/RCS/RcsInvalidTtlException.php b/src/Messages/Channel/RCS/RcsInvalidTtlException.php index b7866a99..160f9778 100644 --- a/src/Messages/Channel/RCS/RcsInvalidTtlException.php +++ b/src/Messages/Channel/RCS/RcsInvalidTtlException.php @@ -4,4 +4,4 @@ class RcsInvalidTtlException extends \Exception { -} \ No newline at end of file +} diff --git a/src/Messages/Channel/Viber/ViberImage.php b/src/Messages/Channel/Viber/ViberImage.php index aea4bcb4..f231a7b9 100644 --- a/src/Messages/Channel/Viber/ViberImage.php +++ b/src/Messages/Channel/Viber/ViberImage.php @@ -36,10 +36,10 @@ public function toArray(): array $returnArray['image'] = $this->image->toArray(); if ($this->requiresViberServiceObject()) { - $this->getCategory() ? $returnArray['viber_service']['category'] = $this->getCategory(): null; - $this->getTtl() ? $returnArray['viber_service']['ttl'] = $this->getTtl(): null; - $this->getType() ? $returnArray['viber_service']['type'] = $this->getType(): null; - $this->getAction() ? $returnArray['viber_service']['action'] = $this->getAction()->toArray(): null; + $this->getCategory() ? $returnArray['viber_service']['category'] = $this->getCategory() : null; + $this->getTtl() ? $returnArray['viber_service']['ttl'] = $this->getTtl() : null; + $this->getType() ? $returnArray['viber_service']['type'] = $this->getType() : null; + $this->getAction() ? $returnArray['viber_service']['action'] = $this->getAction()->toArray() : null; } return array_filter($returnArray); diff --git a/src/Messages/Channel/Viber/ViberText.php b/src/Messages/Channel/Viber/ViberText.php index 8d9d860c..0313eb3b 100644 --- a/src/Messages/Channel/Viber/ViberText.php +++ b/src/Messages/Channel/Viber/ViberText.php @@ -38,10 +38,10 @@ public function toArray(): array $returnArray['text'] = $this->getText(); if ($this->requiresViberServiceObject()) { - $this->getCategory() ? $returnArray['viber_service']['category'] = $this->getCategory(): null; - $this->getTtl() ? $returnArray['viber_service']['ttl'] = $this->getTtl(): null; - $this->getType() ? $returnArray['viber_service']['type'] = $this->getType(): null; - $this->getAction() ? $returnArray['viber_service']['action'] = $this->getAction()->toArray(): null; + $this->getCategory() ? $returnArray['viber_service']['category'] = $this->getCategory() : null; + $this->getTtl() ? $returnArray['viber_service']['ttl'] = $this->getTtl() : null; + $this->getType() ? $returnArray['viber_service']['type'] = $this->getType() : null; + $this->getAction() ? $returnArray['viber_service']['action'] = $this->getAction()->toArray() : null; } return array_filter($returnArray); diff --git a/src/Messages/Channel/WhatsApp/MessageObjects/StickerObject.php b/src/Messages/Channel/WhatsApp/MessageObjects/StickerObject.php index 4cb1e118..a57a8af9 100644 --- a/src/Messages/Channel/WhatsApp/MessageObjects/StickerObject.php +++ b/src/Messages/Channel/WhatsApp/MessageObjects/StickerObject.php @@ -7,7 +7,7 @@ class StickerObject implements ArrayHydrateInterface { public const STICKER_URL = 'url'; - public const STICKER_ID = 'id'; + public const STICKER_ID = 'id'; private array $allowedTypes = [ self::STICKER_URL, diff --git a/src/Messages/ClientFactory.php b/src/Messages/ClientFactory.php index e72ca2ee..76b715ea 100644 --- a/src/Messages/ClientFactory.php +++ b/src/Messages/ClientFactory.php @@ -22,4 +22,4 @@ public function __invoke(ContainerInterface $container): Client return new Client($api); } -} \ No newline at end of file +} diff --git a/src/NumberVerification/ClientFactory.php b/src/NumberVerification/ClientFactory.php index bbad042e..c62a652f 100644 --- a/src/NumberVerification/ClientFactory.php +++ b/src/NumberVerification/ClientFactory.php @@ -29,4 +29,4 @@ public function __invoke(ContainerInterface $container): Client return new Client($api); } -} \ No newline at end of file +} diff --git a/src/Numbers/Client.php b/src/Numbers/Client.php index 58513c7c..874648d0 100644 --- a/src/Numbers/Client.php +++ b/src/Numbers/Client.php @@ -204,7 +204,7 @@ public function purchase($number, ?string $country = null): void 'msisdn' => $number->getMsisdn(), 'country' => $number->getCountry() ]; - // Evil else that will be removed in the next major version. + // Evil else that will be removed in the next major version. } else { $body = [ 'msisdn' => $number, diff --git a/src/ProactiveConnect/ClientFactory.php b/src/ProactiveConnect/ClientFactory.php index 3296ee08..597c1f53 100644 --- a/src/ProactiveConnect/ClientFactory.php +++ b/src/ProactiveConnect/ClientFactory.php @@ -18,4 +18,4 @@ public function __invoke(ContainerInterface $container): Client return new Client($api); } -} \ No newline at end of file +} diff --git a/src/ProactiveConnect/Objects/ManualList.php b/src/ProactiveConnect/Objects/ManualList.php index 08402a77..64308cd3 100644 --- a/src/ProactiveConnect/Objects/ManualList.php +++ b/src/ProactiveConnect/Objects/ManualList.php @@ -86,6 +86,6 @@ public function toArray(): array 'attributes' => $this->getAttributes() ?: null ]; - return array_filter($returnArray, fn($value) => $value !== null); + return array_filter($returnArray, fn ($value) => $value !== null); } } diff --git a/src/ProactiveConnect/Objects/SalesforceList.php b/src/ProactiveConnect/Objects/SalesforceList.php index 005d35f6..ed6047ae 100644 --- a/src/ProactiveConnect/Objects/SalesforceList.php +++ b/src/ProactiveConnect/Objects/SalesforceList.php @@ -112,6 +112,6 @@ public function toArray(): array 'attributes' => $this->getAttributes() ?: null ]; - return array_filter($returnArray, fn($value) => $value !== null); + return array_filter($returnArray, fn ($value) => $value !== null); } } diff --git a/src/SimSwap/ClientFactory.php b/src/SimSwap/ClientFactory.php index 3a740095..47ffb66f 100644 --- a/src/SimSwap/ClientFactory.php +++ b/src/SimSwap/ClientFactory.php @@ -28,4 +28,4 @@ public function __invoke(ContainerInterface $container): Client return new Client($api); } -} \ No newline at end of file +} diff --git a/src/Subaccount/Client.php b/src/Subaccount/Client.php index 77b420df..03950a6c 100644 --- a/src/Subaccount/Client.php +++ b/src/Subaccount/Client.php @@ -54,7 +54,7 @@ public function getSubaccounts(string $apiKey): array $hydrator->setPrototype(new Account()); $subaccounts = $collection->getPageData()['_embedded'][$api->getCollectionName()]; - return array_map(fn($item) => $hydrator->hydrate($item), $subaccounts); + return array_map(fn ($item) => $hydrator->hydrate($item), $subaccounts); } public function createSubaccount(string $apiKey, Account $account): ?array @@ -64,14 +64,20 @@ public function createSubaccount(string $apiKey, Account $account): ?array public function makeBalanceTransfer(TransferBalanceRequest $transferRequest): BalanceTransfer { - $response = $this->api->create($transferRequest->toArray(), '/' . $transferRequest->getApiKey() . '/balance-transfers'); + $response = $this->api->create( + $transferRequest->toArray(), + '/' . $transferRequest->getApiKey() . '/balance-transfers' + ); return (new BalanceTransfer())->fromArray($response); } public function makeCreditTransfer(TransferCreditRequest $transferRequest): CreditTransfer { - $response = $this->api->create($transferRequest->toArray(), '/' . $transferRequest->getApiKey() . '/credit-transfers'); + $response = $this->api->create( + $transferRequest->toArray(), + '/' . $transferRequest->getApiKey() . '/credit-transfers' + ); return (new CreditTransfer())->fromArray($response); } @@ -92,7 +98,7 @@ public function getCreditTransfers(string $apiKey, FilterInterface $filter = nul $hydrator->setPrototype(new CreditTransfer()); $transfers = $response['_embedded']['credit_transfers']; - return array_map(fn($item) => $hydrator->hydrate($item), $transfers); + return array_map(fn ($item) => $hydrator->hydrate($item), $transfers); } public function getBalanceTransfers(string $apiKey, FilterInterface $filter = null): mixed @@ -107,7 +113,7 @@ public function getBalanceTransfers(string $apiKey, FilterInterface $filter = nu $hydrator->setPrototype(new BalanceTransfer()); $transfers = $response['_embedded']['balance_transfers']; - return array_map(fn($item) => $hydrator->hydrate($item), $transfers); + return array_map(fn ($item) => $hydrator->hydrate($item), $transfers); } public function makeNumberTransfer(NumberTransferRequest $request): ?array diff --git a/src/Subaccount/ClientFactory.php b/src/Subaccount/ClientFactory.php index c1a3d4d6..8ec08a08 100644 --- a/src/Subaccount/ClientFactory.php +++ b/src/Subaccount/ClientFactory.php @@ -16,4 +16,4 @@ public function __invoke(ContainerInterface $container): Client return new Client($api); } -} \ No newline at end of file +} diff --git a/src/Subaccount/Filter/SubaccountFilter.php b/src/Subaccount/Filter/SubaccountFilter.php index d7bd70c7..bd840a37 100644 --- a/src/Subaccount/Filter/SubaccountFilter.php +++ b/src/Subaccount/Filter/SubaccountFilter.php @@ -94,4 +94,4 @@ public function setSubaccount(?string $subaccount): void { $this->subaccount = $subaccount; } -} \ No newline at end of file +} diff --git a/src/Verify2/ClientFactory.php b/src/Verify2/ClientFactory.php index b6446259..8bca137a 100644 --- a/src/Verify2/ClientFactory.php +++ b/src/Verify2/ClientFactory.php @@ -19,4 +19,4 @@ public function __invoke(ContainerInterface $container): Client return new Client($api); } -} \ No newline at end of file +} diff --git a/src/Verify2/Request/BaseVerifyRequest.php b/src/Verify2/Request/BaseVerifyRequest.php index 529a4252..57cddba4 100644 --- a/src/Verify2/Request/BaseVerifyRequest.php +++ b/src/Verify2/Request/BaseVerifyRequest.php @@ -124,7 +124,7 @@ public function setBrand(string $brand): static public function getWorkflows(): array { - return array_map(static fn($workflow) => $workflow->toArray(), $this->workflows); + return array_map(static fn ($workflow) => $workflow->toArray(), $this->workflows); } public function addWorkflow(VerificationWorkflow $verificationWorkflow): static diff --git a/src/Verify2/Request/RequestInterface.php b/src/Verify2/Request/RequestInterface.php index e4d0538e..8141e4dc 100644 --- a/src/Verify2/Request/RequestInterface.php +++ b/src/Verify2/Request/RequestInterface.php @@ -22,4 +22,4 @@ public function getWorkflows(): array; public function getBaseVerifyUniversalOutputArray(): array; public function setCode(string $code): static; public function getCode(): ?string; -} \ No newline at end of file +} diff --git a/src/Verify2/Traits/CustomTemplateTrait.php b/src/Verify2/Traits/CustomTemplateTrait.php index 26ee84cf..18c3d824 100644 --- a/src/Verify2/Traits/CustomTemplateTrait.php +++ b/src/Verify2/Traits/CustomTemplateTrait.php @@ -15,4 +15,4 @@ public function setTemplateId(string $templateId): string { return $this->templateId = $templateId; } -} \ No newline at end of file +} diff --git a/src/Verify2/VerifyObjects/VerificationLocale.php b/src/Verify2/VerifyObjects/VerificationLocale.php index 6f0d8434..1ef0105a 100644 --- a/src/Verify2/VerifyObjects/VerificationLocale.php +++ b/src/Verify2/VerifyObjects/VerificationLocale.php @@ -19,4 +19,4 @@ public function setCode(string $code): static return $this; } -} \ No newline at end of file +} diff --git a/src/Voice/Endpoint/EndpointFactory.php b/src/Voice/Endpoint/EndpointFactory.php index edac3e31..94a7a138 100644 --- a/src/Voice/Endpoint/EndpointFactory.php +++ b/src/Voice/Endpoint/EndpointFactory.php @@ -9,7 +9,6 @@ class EndpointFactory implements FactoryInterface { - public function create(array $data): ?EndpointInterface { return match ($data['type']) { diff --git a/src/Voice/Endpoint/EndpointInterface.php b/src/Voice/Endpoint/EndpointInterface.php index e59156a5..ad3c725c 100644 --- a/src/Voice/Endpoint/EndpointInterface.php +++ b/src/Voice/Endpoint/EndpointInterface.php @@ -8,7 +8,6 @@ interface EndpointInterface extends JsonSerializable { - public function getId(): string; /** diff --git a/test/Application/ClientTest.php b/test/Application/ClientTest.php index ec3d6a0f..29be21b3 100644 --- a/test/Application/ClientTest.php +++ b/test/Application/ClientTest.php @@ -25,6 +25,7 @@ use VonageTest\Traits\HTTPTestTrait; use VonageTest\Traits\Psr7AssertionTrait; use VonageTest\VonageTestCase; + use function json_decode; use function substr; diff --git a/test/Client/Credentials/Handler/BasicQueryHandlerTest.php b/test/Client/Credentials/Handler/BasicQueryHandlerTest.php index 82759f51..324f90e4 100644 --- a/test/Client/Credentials/Handler/BasicQueryHandlerTest.php +++ b/test/Client/Credentials/Handler/BasicQueryHandlerTest.php @@ -20,4 +20,4 @@ public function testWillAddCredentialsToRequest(): void $uriString = $uri->__toString(); $this->assertEquals('https://example.com?api_key=abc&api_secret=xyz', $uriString); } -} \ No newline at end of file +} diff --git a/test/Client/Credentials/Handler/GnpHandlerTest.php b/test/Client/Credentials/Handler/GnpHandlerTest.php index f3541450..863a1ea6 100644 --- a/test/Client/Credentials/Handler/GnpHandlerTest.php +++ b/test/Client/Credentials/Handler/GnpHandlerTest.php @@ -59,7 +59,11 @@ public function testWillReturnSimSwapCheckWithValidCredentials(): void ); $this->assertRequestFormBodyContains('login_hint', 'tel:+447700900000', $request); - $this->assertRequestFormBodyContains('scope', 'dpv:FraudPreventionAndDetection#check-sim-swap', $request); + $this->assertRequestFormBodyContains( + 'scope', + 'dpv:FraudPreventionAndDetection#check-sim-swap', + $request + ); $this->assertEquals( 'Bearer ', @@ -79,8 +83,17 @@ public function testWillReturnSimSwapCheckWithValidCredentials(): void $uriString ); - $this->assertRequestFormBodyContains('grant_type', 'urn:openid:params:grant-type:ciba', $request); - $this->assertRequestFormBodyContains('auth_req_id', '0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537', $request); + $this->assertRequestFormBodyContains( + 'grant_type', + 'urn:openid:params:grant-type:ciba', + $request + ); + + $this->assertRequestFormBodyContains( + 'auth_req_id', + '0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537', + $request + ); return true; } @@ -118,8 +131,17 @@ public function testWillReturnSimSwapDateWithValidCredentials(): void $uriString ); - $this->assertRequestFormBodyContains('login_hint', 'tel:+447700900000', $request); - $this->assertRequestFormBodyContains('scope', 'dpv:FraudPreventionAndDetection#check-sim-swap', $request); + $this->assertRequestFormBodyContains( + 'login_hint', + 'tel:+447700900000', + $request + ); + + $this->assertRequestFormBodyContains( + 'scope', + 'dpv:FraudPreventionAndDetection#check-sim-swap', + $request + ); $this->assertEquals( 'Bearer ', @@ -139,8 +161,17 @@ public function testWillReturnSimSwapDateWithValidCredentials(): void $uriString ); - $this->assertRequestFormBodyContains('grant_type', 'urn:openid:params:grant-type:ciba', $request); - $this->assertRequestFormBodyContains('auth_req_id', '0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537', $request); + $this->assertRequestFormBodyContains( + 'grant_type', + 'urn:openid:params:grant-type:ciba', + $request + ); + + $this->assertRequestFormBodyContains( + 'auth_req_id', + '0dadaeb4-7c79-4d39-b4b0-5a6cc08bf537', + $request + ); return true; } diff --git a/test/Client/Exception/Validation.php b/test/Client/Exception/Validation.php index 4fafd8dc..2325bf18 100644 --- a/test/Client/Exception/Validation.php +++ b/test/Client/Exception/Validation.php @@ -1,4 +1,5 @@ assertEquals('https://api.nexmo.com/v1/conversations?order=desc&page_size=10&cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg='); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations?' . + 'order=desc&page_size=10&' . + 'cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg=' + ); } return true; @@ -147,7 +151,14 @@ public function testWillListConversationsByQueryParameters(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations?date_start=2018-01-01+10%3A00%3A00&date_end=2018-01-01+12%3A00%3A00&page_size=5&order=asc', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations?' . + 'date_start=2018-01-01+10%3A00%3A00&' . + 'date_end=2018-01-01+12%3A00%3A00&' . + 'page_size=5&' . + 'order=asc', + $uriString + ); return true; }))->willReturn($this->getResponse('list-conversations')); @@ -183,7 +194,11 @@ public function testWillCreateConversation(): void $this->assertRequestJsonBodyContains('display_name', 'Customer Chat', $request); $this->assertRequestJsonBodyContains('image_url', 'https://example.com/image.png', $request); $this->assertRequestJsonBodyContains('ttl', 60, $request, true); - $this->assertRequestJsonBodyContains('numbers', ['type' => 'phone', 'number' => '447700900000'], $request); + $this->assertRequestJsonBodyContains( + 'numbers', + ['type' => 'phone', 'number' => '447700900000'], + $request + ); $callbackStructure = [ 'url' => 'https://example.com/eventcallback', @@ -200,7 +215,11 @@ public function testWillCreateConversation(): void return true; }))->willReturn($this->getResponse('create-conversation')); - $conversation = new CreateConversationRequest('customer_chat', 'Customer Chat', 'https://example.com/image.png'); + $conversation = new CreateConversationRequest( + 'customer_chat', + 'Customer Chat', + 'https://example.com/image.png' + ); $conversation->setTtl(60); $conversationNumber = new ConversationNumber('447700900000'); @@ -252,7 +271,10 @@ public function testWillRetrieveConversation(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', + $uriString + ); return true; }))->willReturn($this->getResponse('get-conversation')); @@ -297,7 +319,10 @@ public function testWillUpdateConversation(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', + $uriString + ); return true; }))->willReturn($this->getResponse('update-conversation')); @@ -312,7 +337,11 @@ public function testWillUpdateConversation(): void $updatePayload ); - $response = $this->conversationsClient->updateConversationById('CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', $updateConversationRequest); + $response = $this->conversationsClient->updateConversationById( + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', + $updateConversationRequest + ); + $this->assertInstanceOf(Conversation::class, $response); $conversationShape = [ @@ -352,7 +381,10 @@ public function testWillDeleteConversation(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', + $uriString + ); return true; }))->willReturn($this->getResponse('delete-conversation', 204)); @@ -372,17 +404,33 @@ public function testWillListMembersByConversationId(): void $uriString = $uri->__toString(); if ($requestIndex == 1) { - $this->assertEquals('https://api.nexmo.com/v1/users/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/conversations?page_size=1', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/users/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/conversations?' . + 'page_size=1', + $uriString + ); } if ($requestIndex == 2) { - $this->assertEquals('https://api.nexmo.com/v1/conversations?order=desc&page_size=10&cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg='); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations?' . + 'order=desc&' . + 'page_size=10&' . + 'cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg=' + ); } return true; - }))->willReturn($this->getResponse('list-user-conversations'), $this->getResponse('list-user-conversations-2')); + }))->willReturn( + $this->getResponse( + 'list-user-conversations' + ), + $this->getResponse('list-user-conversations-2') + ); - $response = $this->conversationsClient->listUserConversationsByUserId('CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a'); + $response = $this->conversationsClient->listUserConversationsByUserId( + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a' + ); $this->assertInstanceOf(IterableAPICollection::class, $response); $conversations = []; @@ -440,15 +488,36 @@ public function testWillListMembersByConversationByUserIdUsingQueryParameters(): $uriString = $uri->__toString(); if ($this->requestIndex == 1) { - $this->assertEquals('https://api.nexmo.com/v1/users/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/conversations?state=INVITED&order_by=created&include_custom_data=1&date_start=2018-01-01+10%3A00%3A00&date_end=2018-01-01+12%3A00%3A00&page_size=5&order=asc&page_index=1', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/users/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/conversations?' . + 'state=INVITED&' . + 'order_by=created&' . + 'include_custom_data=1&' . + 'date_start=2018-01-01+10%3A00%3A00&' . + 'date_end=2018-01-01+12%3A00%3A00&' . + 'page_size=5&' . + 'order=asc&' . + 'page_index=1', + $uriString + ); } if ($this->requestIndex == 2) { - $this->assertEquals('https://api.nexmo.com/v1/users/USR-82e028d9-5201-4f1e-8188-604b2d3471ec/conversations?order=desc&page_size=10&cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg=', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/users/USR-82e028d9-5201-4f1e-8188-604b2d3471ec/conversations?' . + 'order=desc&' . + 'page_size=10&' . + 'cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg=', + $uriString + ); } + return true; - }))->willReturn($this->getResponse('list-user-conversations'), $this->getResponse('list-user-conversations-2')); + }))->willReturn( + $this->getResponse('list-user-conversations'), + $this->getResponse('list-user-conversations-2') + ); $filter = new ListUserConversationsFilter(); $filter->setState('INVITED'); @@ -459,7 +528,10 @@ public function testWillListMembersByConversationByUserIdUsingQueryParameters(): $filter->setPageSize(5); $filter->setOrder('asc'); - $response = $this->conversationsClient->listUserConversationsByUserId('CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', $filter); + $response = $this->conversationsClient->listUserConversationsByUserId( + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', + $filter + ); $conversations = []; @@ -482,11 +554,22 @@ public function testWillListMembersInConversation(): void $uriString = $uri->__toString(); if ($this->requestIndex == 1) { - $this->assertEquals('https://api.nexmo.com/v1/usersCON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members?page_index=1', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/users/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members?' . + 'page_index=1', + $uriString + ); } if ($this->requestIndex == 2) { - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members?order=desc&page_size=10&cursor=88b395c167da4d94e929705cbd63b829a650e69a39197bfd4c949f4243f60dc4babb696afa404d2f44e7775e32b967f2a1a0bb8fb259c0999ba5a4e501eaab55', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/' . + 'members?order=desc&' . + 'page_size=10&' . + 'cursor=88b395c167da4d94e929705cbd63b829a650e69a39197bfd4c949f4243f60dc4babb696afa404d2f4' . + '4e7775e32b967f2a1a0bb8fb259c0999ba5a4e501eaab55', + $uriString + ); } return true; @@ -515,7 +598,13 @@ public function testWillListMembersWithQuery(): void $uriString = $uri->__toString(); if ($this->requestIndex == 1) { - $this->assertEquals('https://api.nexmo.com/v1/usersCON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members?page_size=50&order=DESC&page_index=1', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/users/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members?' . + 'page_size=50&' . + 'order=DESC&' . + 'page_index=1', + $uriString + ); } return true; @@ -525,7 +614,10 @@ public function testWillListMembersWithQuery(): void $filter->setOrder('DESC'); $filter->setPageSize(50); - $response = $this->conversationsClient->listMembersByConversationId('CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', $filter); + $response = $this->conversationsClient->listMembersByConversationId( + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', + $filter + ); $conversations = []; @@ -546,10 +638,17 @@ public function testWillCreateMemberInConversation(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-63f61863-4a51-4f6b-86e1-46edebio0391/members', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-63f61863-4a51-4f6b-86e1-46edebio0391/members', + $uriString + ); $this->assertRequestJsonBodyContains('state', 'invited', $request); $this->assertRequestJsonBodyContains('knocking_id', '4f1e-8188', $request); - $this->assertRequestJsonBodyContains('member_id_inviting', 'MEM-63f61863-4a51-4f6b-86e1-46edebio0391', $request); + $this->assertRequestJsonBodyContains( + 'member_id_inviting', + 'MEM-63f61863-4a51-4f6b-86e1-46edebio0391', + $request + ); $this->assertRequestJsonBodyContains('from', 'value', $request); $this->assertRequestJsonBodyContains( 'channel', @@ -630,12 +729,17 @@ public function testWillGetMeAsMemberInConversation(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members/me', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members/me', + $uriString + ); return true; }))->willReturn($this->getResponse('get-member')); - $response = $this->conversationsClient->getMyMemberByConversationId('CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a'); + $response = $this->conversationsClient->getMyMemberByConversationId( + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a' + ); $this->assertInstanceOf(Member::class, $response); } @@ -647,7 +751,11 @@ public function testWillGetMemberInConversation(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members/MEM-63f61863-4a51-4f6b-86e1-46edebio0391', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members/' . + 'MEM-63f61863-4a51-4f6b-86e1-46edebio0391', + $uriString + ); return true; }))->willReturn($this->getResponse('get-member')); @@ -668,10 +776,19 @@ public function testWillUpdateMemberInConversation(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members/MEM-63f61863-4a51-4f6b-86e1-46edebio0391', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/members/' . + 'MEM-63f61863-4a51-4f6b-86e1-46edebio0391', + $uriString + ); + $this->assertRequestJsonBodyContains('state', 'left', $request); $this->assertRequestJsonBodyContains('from', 'value', $request); - $this->assertRequestJsonBodyContains('reason', ['code' => '400', 'text' => 'user got bored'], $request); + $this->assertRequestJsonBodyContains( + 'reason', + ['code' => '400', 'text' => 'user got bored'], + $request + ); return true; }))->willReturn($this->getResponse('update-member')); @@ -707,10 +824,17 @@ public function testWillCreateEvent(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/events', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/events', + $uriString + ); $this->assertRequestJsonBodyContains('type', 'message', $request); $this->assertRequestJsonBodyContains('from', 'from-value', $request); - $this->assertRequestJsonBodyContains('body', ['message_type' => 'text', 'text' => 'my event'], $request); + $this->assertRequestJsonBodyContains( + 'body', + ['message_type' => 'text', 'text' => 'my event'], + $request + ); return true; }))->willReturn($this->getResponse('create-event')); @@ -729,7 +853,15 @@ public function testWillListEvents(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/events?start_id=3453&end_id=5634&event_type=member%3Amessage%3Astatus&page_size=2&order=desc', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/events?' . + 'start_id=3453&' . + 'end_id=5634&' . + 'event_type=member%3Amessage%3Astatus&' . + 'page_size=2&' . + 'order=desc', + $uriString + ); return true; } @@ -740,7 +872,11 @@ public function testWillListEvents(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a?cursor=94f0', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a?' . + 'cursor=94f0', + $uriString + ); return true; } @@ -754,7 +890,10 @@ public function testWillListEvents(): void $filter->setOrder('desc'); $filter->setExcludeDeletedEvents(false); - $response = $this->conversationsClient->listEvents('CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', $filter); + $response = $this->conversationsClient->listEvents( + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a', + $filter + ); $responseData = []; foreach ($response as $event) { @@ -773,12 +912,19 @@ public function testWillGetEventById(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/events/999', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/events/' . + '999', + $uriString + ); return true; }))->willReturn($this->getResponse('get-event')); - $response = $this->conversationsClient->getEventById('999', 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a'); + $response = $this->conversationsClient->getEventById( + '999', + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a' + ); } public function testWillDeleteEvent(): void @@ -789,12 +935,19 @@ public function testWillDeleteEvent(): void $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/events/999', $uriString); + $this->assertEquals( + 'https://api.nexmo.com/v1/conversations/CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a/events/' . + '999', + $uriString + ); return true; }))->willReturn($this->getResponse('delete-conversation', 204)); - $response = $this->conversationsClient->deleteEventById('999', 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a'); + $response = $this->conversationsClient->deleteEventById( + '999', + 'CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a' + ); $this->assertTrue($response); } diff --git a/test/Insights/AdvancedTest.php b/test/Insights/AdvancedTest.php index a1a9212c..b46cd1c9 100644 --- a/test/Insights/AdvancedTest.php +++ b/test/Insights/AdvancedTest.php @@ -26,7 +26,7 @@ class AdvancedTest extends VonageTestCase public function setUp(): void { $this->responsesDirectory = __DIR__ . '/responses'; - + $this->vonageClient = $this->prophesize(Client::class); $this->vonageClient->getRestUrl()->willReturn('https://api.nexmo.com'); $this->vonageClient->getCredentials()->willReturn( diff --git a/test/Insights/ClientTest.php b/test/Insights/ClientTest.php index 6d3871d3..bbe2d75e 100644 --- a/test/Insights/ClientTest.php +++ b/test/Insights/ClientTest.php @@ -77,7 +77,7 @@ public function testAdvancedAsync(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) { $this->assertEquals('/ni/advanced/async/json', $request->getUri()->getPath()); $this->assertEquals('api.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $this->assertRequestQueryContains("number", "14155550100", $request); $this->assertRequestQueryContains("callback", "example.com/hook", $request); @@ -112,7 +112,7 @@ public function testError(): void { $this->expectException(RequestException::class); - $this->vonageClient->send(Argument::that(fn(RequestInterface $request) => true))->willReturn($this->getResponse('error')); + $this->vonageClient->send(Argument::that(fn (RequestInterface $request) => true))->willReturn($this->getResponse('error')); $this->insightsClient->basic('14155550100'); } @@ -127,7 +127,7 @@ public function testClientException(): void { $this->expectException(RequestException::class); - $this->vonageClient->send(Argument::that(fn(RequestInterface $request) => true))->willReturn($this->getResponse('error', 401)); + $this->vonageClient->send(Argument::that(fn (RequestInterface $request) => true))->willReturn($this->getResponse('error', 401)); $this->insightsClient->basic('14155550100'); } @@ -142,7 +142,7 @@ public function testServerException(): void { $this->expectException(ServerException::class); - $this->vonageClient->send(Argument::that(fn(RequestInterface $request) => true))->willReturn($this->getResponse('error', 502)); + $this->vonageClient->send(Argument::that(fn (RequestInterface $request) => true))->willReturn($this->getResponse('error', 502)); $this->insightsClient->basic('14155550100'); } @@ -152,7 +152,7 @@ protected function checkInsightsRequest($methodToCall, $expectedPath, $expectedC $this->vonageClient->send(Argument::that(function (RequestInterface $request) use ($expectedPath) { $this->assertEquals($expectedPath, $request->getUri()->getPath()); $this->assertEquals('api.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $this->assertRequestQueryContains("number", "14155550100", $request); return true; @@ -168,7 +168,7 @@ protected function checkInsightsRequestCnam($methodToCall, $expectedPath, $expec $this->vonageClient->send(Argument::that(function (RequestInterface $request) use ($expectedPath) { $this->assertEquals($expectedPath, $request->getUri()->getPath()); $this->assertEquals('api.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $this->assertRequestQueryContains("number", "14155550100", $request); $this->assertRequestQueryContains("cnam", "true", $request); diff --git a/test/Logger/LoggerTraitTest.php b/test/Logger/LoggerTraitTest.php index 2cc973c1..4787cbab 100644 --- a/test/Logger/LoggerTraitTest.php +++ b/test/Logger/LoggerTraitTest.php @@ -43,4 +43,4 @@ public function testLoggingAcceptsMessageWithLogger() $this->assertNull($trait->log('debug', 'This is a message')); } -} \ No newline at end of file +} diff --git a/test/Meetings/ClientTest.php b/test/Meetings/ClientTest.php index 5a8ed39c..3d73ac9a 100644 --- a/test/Meetings/ClientTest.php +++ b/test/Meetings/ClientTest.php @@ -70,7 +70,7 @@ public function testBaseUrlIsSet(): void public function testWillGetAvailableRooms(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -90,7 +90,7 @@ public function testWillGetAvailableRooms(): void public function testWillGetAvailableRoomsWithFilter(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -182,7 +182,7 @@ public function testClientWillHandleUnauthorizedRequests(): void public function testClientWillHandleNotFoundResponse(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); $this->assertEquals( @@ -220,7 +220,7 @@ public function testClientWillHandleValidationError(): void public function testWillGetRoomDetails(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); $this->assertEquals( @@ -272,7 +272,7 @@ public function testWillUpdateExistingRoom(): void public function testWillGetRecording(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -311,7 +311,7 @@ public function testWillDeleteRecording(): void public function testWillGetRecordingsFromSession(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -333,7 +333,7 @@ public function testWillGetRecordingsFromSession(): void public function testWillGetMeetingDialNumbers(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -355,7 +355,7 @@ public function testWillGetMeetingDialNumbers(): void public function testWillGetApplicationThemes(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -416,7 +416,7 @@ public function testWillHandleConflictErrorOnThemeCreation(): void public function testWillGetThemeById(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -565,7 +565,7 @@ public function testWillUploadImageToAws(): void public function testCanGetUploadUrlsForThemeLogo(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -581,7 +581,7 @@ public function testCanGetUploadUrlsForThemeLogo(): void public function testWillGetRoomsAssociatedWithTheme(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -600,7 +600,7 @@ public function testWillGetRoomsAssociatedWithTheme(): void public function testWillGetRoomsAssociatedWithThemeUsingFilter(): void { $this->vonageClient->send(Argument::that(function (RequestInterface $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); diff --git a/test/Numbers/ClientTest.php b/test/Numbers/ClientTest.php index 90a76a54..83fc36fd 100644 --- a/test/Numbers/ClientTest.php +++ b/test/Numbers/ClientTest.php @@ -50,7 +50,7 @@ public function setUp(): void $this->api = new APIResource(); $this->api->setBaseUrl('https://rest.nexmo.com') - ->setIsHAL(false); + ->setIsHAL(false); $this->api->setClient($this->vonageClient->reveal()); @@ -92,10 +92,22 @@ public function testUpdateNumber($payload, $id, $expectedId, $lookup): void $this->assertRequestFormBodyContains('country', 'US', $request); $this->assertRequestFormBodyContains('msisdn', $expectedId, $request); - $this->assertRequestFormBodyContains('moHttpUrl', 'https://example.com/new_message', $request); + $this->assertRequestFormBodyContains( + 'moHttpUrl', + 'https://example.com/new_message', + $request + ); $this->assertRequestFormBodyContains('voiceCallbackType', 'vxml', $request); - $this->assertRequestFormBodyContains('voiceCallbackValue', 'https://example.com/new_voice', $request); - $this->assertRequestFormBodyContains('voiceStatusCallback', 'https://example.com/new_status', $request); + $this->assertRequestFormBodyContains( + 'voiceCallbackValue', + 'https://example.com/new_voice', + $request + ); + $this->assertRequestFormBodyContains( + 'voiceStatusCallback', + 'https://example.com/new_status', + $request + ); return true; }))->willReturn($first, $second, $third); @@ -142,7 +154,7 @@ public function testGetNumber($payload, $id): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) use ($id) { $this->assertEquals('/account/numbers', $request->getUri()->getPath()); $this->assertEquals('rest.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $this->assertRequestQueryContains('pattern', $id, $request); return true; }))->willReturn($this->getResponse('single')); @@ -168,7 +180,7 @@ public function testListNumbers(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) { $this->assertEquals('/account/numbers', $request->getUri()->getPath()); $this->assertEquals('rest.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); return true; }))->willReturn($this->getResponse('list')); @@ -194,7 +206,7 @@ public function testSearchAvailablePassesThroughWhitelistedOptions(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) use ($options) { $this->assertEquals('/number/search', $request->getUri()->getPath()); $this->assertEquals('rest.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); // Things that are whitelisted should be shown foreach ($options as $name => $value) { @@ -221,7 +233,11 @@ public function testSearchAvailableAcceptsFilterInterfaceOptions(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) { $uri = $request->getUri(); $uriString = $uri->__toString(); - $this->assertEquals('https://rest.nexmo.com/number/search?size=100&index=19&country=US&search_pattern=2&pattern=1&type=landline&features=SMS%2CVOICE&page_index=1', $uriString); + $this->assertEquals( + 'https://rest.nexmo.com/number/search?size=100&index=19&country=US&' . + 'search_pattern=2&pattern=1&type=landline&features=SMS%2CVOICE&page_index=1', + $uriString + ); $this->assertRequestMethod('GET', $request); return true; @@ -243,7 +259,7 @@ public function testSearchAvailableReturnsNumberList(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) { $this->assertEquals('/number/search', $request->getUri()->getPath()); $this->assertEquals('rest.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); return true; }))->willReturn($this->getResponse('available-numbers')); @@ -265,7 +281,7 @@ public function testSearchAvailableReturnsEmptyNumberList(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) { $this->assertEquals('/number/search', $request->getUri()->getPath()); $this->assertEquals('rest.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); return true; }))->willReturn($this->getResponse('empty')); @@ -289,7 +305,7 @@ public function testSearchOwnedPassesInAllowedAdditionalParameters(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) { $this->assertEquals('/account/numbers', $request->getUri()->getPath()); $this->assertEquals('rest.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $this->assertRequestQueryContains('index', '1', $request); $this->assertRequestQueryContains('size', '100', $request); $this->assertRequestQueryContains('search_pattern', '0', $request); @@ -316,7 +332,7 @@ public function testSearchOwnedReturnsSingleNumber(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) { $this->assertEquals('/account/numbers', $request->getUri()->getPath()); $this->assertEquals('rest.nexmo.com', $request->getUri()->getHost()); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); return true; }))->willReturn($this->getResponse('single')); @@ -348,7 +364,10 @@ public function testPurchaseNumberWithNumberObject(): void public function testPurchaseNumberWithNumberAndCountry(): void { // When providing a number string, the first thing that happens is a GET request to fetch number details - $this->vonageClient->send(Argument::that(fn(RequestInterface $request) => $request->getUri()->getPath() === '/account/numbers'))->willReturn($this->getResponse('single')); + $this->vonageClient->send( + Argument::that(fn (RequestInterface $request) => $request->getUri()->getPath() === '/account/numbers') + ) + ->willReturn($this->getResponse('single')); // Then we purchase the number $this->vonageClient->send(Argument::that(function (RequestInterface $request) { @@ -428,9 +447,12 @@ public function purchaseNumberErrorProvider(): array public function testCancelNumberWithNumberString(): void { // When providing a number string, the first thing that happens is a GET request to fetch number details - $this->vonageClient->send(Argument::that(fn(RequestInterface $request) => $request->getUri()->getPath() === '/account/numbers'))->willReturn($this->getResponse('single')); + $this->vonageClient->send( + Argument::that(fn (RequestInterface $request) => $request->getUri()->getPath() === '/account/numbers') + ) + ->willReturn($this->getResponse('single')); - // Then we get a POST request to cancel + // Then we get a POST request to cancel $this->vonageClient->send(Argument::that(function (RequestInterface $request) { if ($request->getUri()->getPath() === '/number/cancel') { $this->assertEquals('rest.nexmo.com', $request->getUri()->getHost()); @@ -447,7 +469,10 @@ public function testCancelNumberWithNumberString(): void public function testCancelNumberWithNumberAndCountryString(): void { // When providing a number string, the first thing that happens is a GET request to fetch number details - $this->vonageClient->send(Argument::that(fn(RequestInterface $request) => $request->getUri()->getPath() === '/account/numbers'))->willReturn($this->getResponse('single')); + $this->vonageClient->send( + Argument::that(fn (RequestInterface $request) => $request->getUri()->getPath() === '/account/numbers') + ) + ->willReturn($this->getResponse('single')); // Then we get a POST request to cancel $this->vonageClient->send(Argument::that(function (RequestInterface $request) { diff --git a/test/Numbers/Filter/AvailableNumbersTest.php b/test/Numbers/Filter/AvailableNumbersTest.php index 53eb0ee5..a5a5d146 100644 --- a/test/Numbers/Filter/AvailableNumbersTest.php +++ b/test/Numbers/Filter/AvailableNumbersTest.php @@ -22,7 +22,7 @@ public function testCanSetValidNumberType(string $type): void /** * List of valid number types that can be searched on - * + * * @return array> */ public function numberTypes(): array diff --git a/test/ProactiveConnect/ClientTest.php b/test/ProactiveConnect/ClientTest.php index ebaa9340..8811b4ba 100644 --- a/test/ProactiveConnect/ClientTest.php +++ b/test/ProactiveConnect/ClientTest.php @@ -269,7 +269,7 @@ public function testCannotCreateSalesforceListWithoutIntegrationId(): void $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('integration_id needs to be set on datasource on a Salesforce list'); - $this->vonageClient->send(Argument::that(fn(Request $request) => true))->willReturn($this->getResponse('list-create-success')); + $this->vonageClient->send(Argument::that(fn (Request $request) => true))->willReturn($this->getResponse('list-create-success')); $createSalesforceListRequest = new SalesforceList('my-list'); $createSalesforceListRequest->setDescription('my-description') @@ -292,7 +292,7 @@ public function testCannotCreateSalesforceListWithoutSoql(): void $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('soql needs to be set on datasource on a Salesforce list'); - $this->vonageClient->send(Argument::that(fn(Request $request) => true))->willReturn($this->getResponse('list-create-success')); + $this->vonageClient->send(Argument::that(fn (Request $request) => true))->willReturn($this->getResponse('list-create-success')); $createSalesforceListRequest = new SalesforceList('my-list'); $createSalesforceListRequest->setDescription('my-description') @@ -322,7 +322,7 @@ public function testCanGetListById(): void $uriString ); - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); return true; }))->willReturn($this->getResponse('list-get-success')); @@ -479,7 +479,7 @@ public function testWillReplaceFetchItemsFromDataSource() public function testWillGetListItems(): void { $this->vonageClient->send(Argument::that(function (Request $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -545,7 +545,7 @@ public function testWillCreateListItem(): void public function testWillDownloadItemCsv(): void { $this->vonageClient->send(Argument::that(function (Request $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); @@ -593,7 +593,7 @@ public function testWillGetItemById(): void $itemId = '4cb98f71-a879-49f7-b5cf-2314353eb52c'; $this->vonageClient->send(Argument::that(function (Request $request) { - $this->assertRequestMethod('GET', $request); + $this->assertRequestMethod('GET', $request); $uri = $request->getUri(); $uriString = $uri->__toString(); $this->assertEquals( diff --git a/test/Redact/ClientTest.php b/test/Redact/ClientTest.php index 00a035bc..98f6edbe 100644 --- a/test/Redact/ClientTest.php +++ b/test/Redact/ClientTest.php @@ -130,7 +130,7 @@ public function testExceptions($response, $code, $expectedException, $expectedMe $this->expectException($expectedException); $this->expectExceptionMessage($expectedMessage); - $this->vonageClient->send(Argument::that(fn(RequestInterface $request) => true))->shouldBeCalledTimes(1)->willReturn($this->getResponse($response, $code)); + $this->vonageClient->send(Argument::that(fn (RequestInterface $request) => true))->shouldBeCalledTimes(1)->willReturn($this->getResponse($response, $code)); $this->redact->transaction('ABC123', 'sms'); } diff --git a/test/SMS/ClientTest.php b/test/SMS/ClientTest.php index ddb0fcd5..b3a58c17 100644 --- a/test/SMS/ClientTest.php +++ b/test/SMS/ClientTest.php @@ -18,6 +18,7 @@ use VonageTest\Traits\HTTPTestTrait; use VonageTest\Traits\Psr7AssertionTrait; use VonageTest\VonageTestCase; + use function json_decode; use function str_repeat; @@ -412,7 +413,9 @@ public function testCanHandleMissingShortcodeOn2FA(): void public function testLogsWarningWhenSendingUnicodeAsText(): void { - $this->vonageClient->send(Argument::that(fn(Request $request) => true))->willReturn($this->getResponse('send-success')); + $this->vonageClient->send( + Argument::that(fn (Request $request) => true) + )->willReturn($this->getResponse('send-success')); $args = [ 'to' => '447700900000', diff --git a/test/SimSwap/ClientTest.php b/test/SimSwap/ClientTest.php index 6cb32d16..78651749 100644 --- a/test/SimSwap/ClientTest.php +++ b/test/SimSwap/ClientTest.php @@ -76,7 +76,12 @@ public function testWillCheckSimSwap(): void $this->assertArrayHasKey('Authorization', $headers); $this->assertRequestFormBodyContains('login_hint', '+346661113334', $request); - $this->assertRequestFormBodyContains('scope', 'dpv:FraudPreventionAndDetection#check-sim-swap', $request); + $this->assertRequestFormBodyContains( + 'scope', + 'dpv:FraudPreventionAndDetection#check-sim-swap', + $request + ); + return true; } @@ -137,7 +142,11 @@ public function testWillRetrieveSimSwapDate(): void $this->assertArrayHasKey('Authorization', $headers); $this->assertRequestFormBodyContains('login_hint', '+346661113334', $request); - $this->assertRequestFormBodyContains('scope', 'dpv:FraudPreventionAndDetection#retrieve-sim-swap-date', $request); + $this->assertRequestFormBodyContains( + 'scope', + 'dpv:FraudPreventionAndDetection#retrieve-sim-swap-date', + $request + ); return true; } diff --git a/test/Subaccount/ClientFactoryTest.php b/test/Subaccount/ClientFactoryTest.php index be38a489..72294b6a 100644 --- a/test/Subaccount/ClientFactoryTest.php +++ b/test/Subaccount/ClientFactoryTest.php @@ -35,13 +35,13 @@ public function setUp(): void /** * Makes sure that the client factory returns the correct object instance - * + * * @see https://github.com/Vonage/vonage-php-sdk-core/pull/472 - * - * @return void - * @throws InvalidArgumentException - * @throws Exception - * @throws ExpectationFailedException + * + * @return void + * @throws InvalidArgumentException + * @throws Exception + * @throws ExpectationFailedException */ public function testFactoryMakeCorrectClient(): void { diff --git a/test/Subaccount/ClientTest.php b/test/Subaccount/ClientTest.php index 547e1a30..be6bddbc 100644 --- a/test/Subaccount/ClientTest.php +++ b/test/Subaccount/ClientTest.php @@ -249,7 +249,7 @@ public function testWillListCreditTransfers(): void $filter = new SubaccountFilter([ 'start_date' => '2022-01-01', - 'end_date'=> '2022-01-05', + 'end_date' => '2022-01-05', 'subaccount' => 's5r3fds' ]); @@ -283,7 +283,7 @@ public function testWillListBalanceTransfers(): void $filter = new SubaccountFilter([ 'start_date' => '2022-01-01', - 'end_date'=> '2022-01-05', + 'end_date' => '2022-01-05', 'subaccount' => 's5r3fds' ]); diff --git a/test/Verify/ClientTest.php b/test/Verify/ClientTest.php index 3b601f65..e469c146 100644 --- a/test/Verify/ClientTest.php +++ b/test/Verify/ClientTest.php @@ -18,6 +18,7 @@ use VonageTest\Traits\HTTPTestTrait; use VonageTest\Traits\Psr7AssertionTrait; use VonageTest\VonageTestCase; + use function serialize; class ClientTest extends VonageTestCase diff --git a/test/Verify/ExceptionErrorHandlerTest.php b/test/Verify/ExceptionErrorHandlerTest.php index e25f9922..d76978e6 100644 --- a/test/Verify/ExceptionErrorHandlerTest.php +++ b/test/Verify/ExceptionErrorHandlerTest.php @@ -37,4 +37,4 @@ public function getResponse(string $type = 'success'): Response { return new Response(fopen(__DIR__ . '/responses/' . $type . '.json', 'rb')); } -} \ No newline at end of file +} diff --git a/test/Verify/VerificationTest.php b/test/Verify/VerificationTest.php index 3d3cfb8a..37b74f5d 100644 --- a/test/Verify/VerificationTest.php +++ b/test/Verify/VerificationTest.php @@ -17,6 +17,7 @@ use Vonage\Verify\Verification; use VonageTest\Traits\HTTPTestTrait; use VonageTest\VonageTestCase; + use function is_null; use function serialize; use function unserialize; diff --git a/test/Verify2/ClientTest.php b/test/Verify2/ClientTest.php index 44b67df8..82f95283 100644 --- a/test/Verify2/ClientTest.php +++ b/test/Verify2/ClientTest.php @@ -54,7 +54,8 @@ public function setUp(): void ->setIsHAL(true) ->setErrorsOn200(false) ->setClient($this->vonageClient->reveal()) - ->setAuthHandlers([new Client\Credentials\Handler\BasicHandler(), new Client\Credentials\Handler\KeypairHandler()]) + ->setAuthHandlers([new Client\Credentials\Handler\BasicHandler(), + new Client\Credentials\Handler\KeypairHandler()]) ->setBaseUrl('https://api.nexmo.com/v2/verify'); $this->verify2Client = new Verify2Client($this->api); @@ -147,7 +148,12 @@ public function testCanRequestSmsWithCustomTemplate(): void $uriString ); - $this->assertRequestJsonBodyContains('template_id', '33945c03-71c6-4aaf-954d-750a9b480def', $request); + $this->assertRequestJsonBodyContains( + 'template_id', + '33945c03-71c6-4aaf-954d-750a9b480def', + $request + ); + $this->assertEquals('POST', $request->getMethod()); return true; @@ -189,8 +195,19 @@ public function testWillPopulateEntityIdAndContentId(): void $uriString ); - $this->assertRequestJsonBodyContains('entity_id', '1101407360000017170', $request, true); - $this->assertRequestJsonBodyContains('content_id', '1107158078772563946', $request, true); + $this->assertRequestJsonBodyContains( + 'entity_id', + '1101407360000017170', + $request, + true + ); + + $this->assertRequestJsonBodyContains( + 'content_id', + '1107158078772563946', + $request, + true + ); $this->assertEquals('POST', $request->getMethod()); return true; @@ -480,7 +497,10 @@ public function testCanRequestSilentAuth(): void $this->assertIsArray($result); $this->assertArrayHasKey('request_id', $result); $this->assertArrayHasKey('check_url', $result); - $this->assertEquals('https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/silent-auth/redirect', $result['check_url']); + $this->assertEquals( + 'https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/silent-auth/redirect', + $result['check_url'] + ); } public function testCanRequestSilentAuthWithRedirectUrl(): void @@ -497,7 +517,12 @@ public function testCanRequestSilentAuthWithRedirectUrl(): void $this->assertRequestJsonBodyContains('brand', $payload['brand'], $request); $this->assertRequestJsonBodyContains('to', $payload['to'], $request, true); $this->assertRequestJsonBodyContains('channel', 'silent_auth', $request, true); - $this->assertRequestJsonBodyContains('redirect_url', 'https://my-app-endpoint/webhook', $request, true); + $this->assertRequestJsonBodyContains( + 'redirect_url', + 'https://my-app-endpoint/webhook', + $request, + true + ); $this->assertEquals('POST', $request->getMethod()); return true; @@ -507,13 +532,17 @@ public function testCanRequestSilentAuthWithRedirectUrl(): void $this->assertIsArray($result); $this->assertArrayHasKey('request_id', $result); $this->assertArrayHasKey('check_url', $result); - $this->assertEquals('https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/silent-auth/redirect', $result['check_url']); + $this->assertEquals( + 'https://api.nexmo.com/v2/verify/c11236f4-00bf-4b89-84ba-88b25df97315/silent-auth/redirect', + $result['check_url'] + ); } public function testCannotSendConcurrentVerifications(): void { $this->expectException(Client\Exception\Request::class); - $this->expectExceptionMessage('Conflict: Concurrent verifications to the same number are not allowed.. See https://www.developer.vonage.com/api-errors/verify#conflict for more information'); + $this->expectExceptionMessage('Conflict: Concurrent verifications to the same number are not allowed.. ' . + 'See https://www.developer.vonage.com/api-errors/verify#conflict for more information'); $payload = [ 'to' => '07785254785', @@ -564,7 +593,8 @@ public function testCannotSendWithoutBrand(): void public function testCanHandleThrottle(): void { $this->expectException(Client\Exception\Request::class); - $this->expectExceptionMessage('Rate Limit Hit: Please wait, then retry your request. See https://www.developer.vonage.com/api-errors#throttled for more information'); + $this->expectExceptionMessage('Rate Limit Hit: Please wait, then retry your request. See https://www.' . + 'developer.vonage.com/api-errors#throttled for more information'); $payload = [ 'to' => '07785254785', @@ -604,7 +634,8 @@ public function testCheckValidIdAndPIN(): void public function testCheckHandlesInvalidPIN(): void { $this->expectException(Client\Exception\Request::class); - $this->expectExceptionMessage('Invalid Code: The code you provided does not match the expected value.. See https://www.developer.vonage.com/api-errors/verify#invalid-code for more information'); + $this->expectExceptionMessage('Invalid Code: The code you provided does not match the expected value.. See' . + ' https://www.developer.vonage.com/api-errors/verify#invalid-code for more information'); $this->vonageClient->send(Argument::that(function (Request $request) { $this->assertRequestJsonBodyContains('code', '24525', $request); @@ -624,7 +655,8 @@ public function testCheckHandlesInvalidPIN(): void public function testCheckHandlesInvalidRequestId(): void { $this->expectException(Client\Exception\Request::class); - $this->expectExceptionMessage('Not Found: Request c11236f4-00bf-4b89-84ba-88b25df97315 was not found or it has been verified already.. See https://developer.vonage.com/api-errors#not-found for more information'); + $this->expectExceptionMessage('Not Found: Request c11236f4-00bf-4b89-84ba-88b25df97315 was not found or it ' . + 'has been verified already.. See https://developer.vonage.com/api-errors#not-found for more information'); $this->vonageClient->send(Argument::that(function (Request $request) { $this->assertRequestJsonBodyContains('code', '24525', $request); @@ -672,9 +704,10 @@ public function testCheckHandlesConflict(): void public function testCheckHandlesLockedCodeSubmission(): void { $this->expectException(Client\Exception\Request::class); - $this->expectExceptionMessage('Invalid Code: An incorrect code has been provided too many times. Workflow terminated.. See https://www.developer.vonage.com/api-errors/verify#expired for more information'); + $this->expectExceptionMessage('Invalid Code: An incorrect code has been provided too many times. ' . + 'Workflow terminated.. See https://www.developer.vonage.com/api-errors/verify#expired for more information'); - $this->vonageClient->send(Argument::that(fn(Request $request) => true))->willReturn($this->getResponse('verify-check-locked', 410)); + $this->vonageClient->send(Argument::that(fn (Request $request) => true))->willReturn($this->getResponse('verify-check-locked', 410)); $result = $this->verify2Client->check('c11236f4-00bf-4b89-84ba-88b25df97315', '24525'); } @@ -682,9 +715,13 @@ public function testCheckHandlesLockedCodeSubmission(): void public function testCheckHandlesThrottle(): void { $this->expectException(Client\Exception\Request::class); - $this->expectExceptionMessage('Rate Limit Hit: Please wait, then retry your request. See https://www.developer.vonage.com/api-errors#throttled for more information'); + $this->expectExceptionMessage('Rate Limit Hit: Please wait, then retry your request. See https://www.de' . + 'veloper.vonage.com/api-errors#throttled for more information'); - $this->vonageClient->send(Argument::that(fn(Request $request) => true))->willReturn($this->getResponse('verify-check-throttle', 429)); + $this->vonageClient->send( + Argument::that(fn (Request $request) => true) + ) + ->willReturn($this->getResponse('verify-check-throttle', 429)); $result = $this->verify2Client->check('c11236f4-00bf-4b89-84ba-88b25df97315', '24525'); } @@ -861,7 +898,10 @@ public function testWillUpdateTemplate(): void true ); - $this->verify2Client->updateCustomTemplate('8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9', $updateTemplateRequest); + $this->verify2Client->updateCustomTemplate( + '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9', + $updateTemplateRequest + ); } public function testWillListTemplateFragments(): void @@ -874,14 +914,16 @@ public function testWillListTemplateFragments(): void if ($this->requestCount == 1) { $this->assertEquals( - 'https://api.nexmo.com/v2/verify/templates/8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9/template_fragments', + 'https://api.nexmo.com/v2/verify/templates/8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9/' . + 'template_fragments', $uriString ); } if ($this->requestCount == 2) { $this->assertEquals( - 'https://api.nexmo.com/v2/verify/templates/c70f446e-997a-4313-a081-60a02a31dc19/template_fragments?page=3', + 'https://api.nexmo.com/v2/verify/templates/c70f446e-997a-4313-a081-60a02a31dc19/' . + 'template_fragments?page=3', $uriString ); } @@ -889,7 +931,10 @@ public function testWillListTemplateFragments(): void $this->assertEquals('GET', $request->getMethod()); return true; - }))->willReturn($this->getResponse('list-template-fragment-success'), $this->getResponse('list-template-fragment-success-2')); + }))->willReturn( + $this->getResponse('list-template-fragment-success'), + $this->getResponse('list-template-fragment-success-2') + ); $fragments = $this->verify2Client->listTemplateFragments('8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9'); @@ -906,7 +951,8 @@ public function testWillListTemplateFragmentsWithQuery(): void $uri = $request->getUri(); $uriString = $uri->__toString(); $this->assertEquals( - 'https://api.nexmo.com/v2/verify/templates/8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9/template_fragments?page=2&page_size=10', + 'https://api.nexmo.com/v2/verify/templates/8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9/' . + 'template_fragments?page=2&page_size=10', $uriString ); @@ -918,7 +964,10 @@ public function testWillListTemplateFragmentsWithQuery(): void $templateFilter->setPage(2); $templateFilter->setPageSize(10); - $fragments = $this->verify2Client->listTemplateFragments('8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9', $templateFilter); + $fragments = $this->verify2Client->listTemplateFragments( + '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9', + $templateFilter + ); foreach ($fragments as $fragment) { $this->assertInstanceOf(TemplateFragment::class, $fragment); @@ -931,12 +980,17 @@ public function testWillCreateTemplateFragment(): void $uri = $request->getUri(); $uriString = $uri->__toString(); $this->assertEquals( - 'https://api.nexmo.com/v2/verify/templates/c70f446e-997a-4313-a081-60a02a31dc19/template_fragments', + 'https://api.nexmo.com/v2/verify/templates/c70f446e-997a-4313-a081-60a02a31dc19/' . + 'template_fragments', $uriString ); $this->assertRequestJsonBodyContains('channel', 'sms', $request); $this->assertRequestJsonBodyContains('locale', 'en-us', $request); - $this->assertRequestJsonBodyContains('text', 'The authentication code for your ${brand} is: ${code}', $request); + $this->assertRequestJsonBodyContains( + 'text', + 'The authentication code for your ${brand} is: ${code}', + $request + ); $this->assertEquals('POST', $request->getMethod()); @@ -948,8 +1002,11 @@ public function testWillCreateTemplateFragment(): void "en-us", 'The authentication code for your ${brand} is: ${code}' ); - - $template = $this->verify2Client->createCustomTemplateFragment('c70f446e-997a-4313-a081-60a02a31dc19', $createTemplateFragmentRequest); + + $template = $this->verify2Client->createCustomTemplateFragment( + 'c70f446e-997a-4313-a081-60a02a31dc19', + $createTemplateFragmentRequest + ); $this->assertInstanceOf(TemplateFragment::class, $template); } @@ -960,7 +1017,8 @@ public function testWillGetTemplateFragment(): void $uri = $request->getUri(); $uriString = $uri->__toString(); $this->assertEquals( - 'https://api.nexmo.com/v2/verify/templates/8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9/template_fragments/c70f446e-997a-4313-a081-60a02a31dc19', + 'https://api.nexmo.com/v2/verify/templates/8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9/' . + 'template_fragments/c70f446e-997a-4313-a081-60a02a31dc19', $uriString ); @@ -969,7 +1027,10 @@ public function testWillGetTemplateFragment(): void return true; }))->willReturn($this->getResponse('get-template-fragment-success')); - $fragment = $this->verify2Client->getCustomTemplateFragment('8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9', 'c70f446e-997a-4313-a081-60a02a31dc19'); + $fragment = $this->verify2Client->getCustomTemplateFragment( + '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9', + 'c70f446e-997a-4313-a081-60a02a31dc19' + ); } public function testWillUpdateTemplateFragment(): void @@ -1006,7 +1067,10 @@ public function testWillDeleteTemplateFragment(): void return true; }))->willReturn($this->getResponse('delete-template-fragment-success')); - $response = $this->verify2Client->deleteCustomTemplateFragment('8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9', 'c70f446e-997a-4313-a081-60a02a31dc19'); + $response = $this->verify2Client->deleteCustomTemplateFragment( + '8f35a1a7-eb2f-4552-8fdf-fffdaee41bc9', + 'c70f446e-997a-4313-a081-60a02a31dc19' + ); $this->assertTrue($response); } diff --git a/test/Voice/ClientTest.php b/test/Voice/ClientTest.php index 8591d3f9..8d24212c 100644 --- a/test/Voice/ClientTest.php +++ b/test/Voice/ClientTest.php @@ -23,6 +23,7 @@ use VonageTest\Traits\HTTPTestTrait; use VonageTest\Traits\Psr7AssertionTrait; use VonageTest\VonageTestCase; + use function fopen; use function json_decode; use function json_encode; @@ -145,7 +146,11 @@ public function testAdvancedMachineDetectionRenders(): void $this->vonageClient->send(Argument::that(function (RequestInterface $request) use ($payload) { $this->assertRequestUrl('api.nexmo.com', '/v1/calls', 'POST', $request); - $this->assertRequestJsonBodyContains('advanced_machine_detection', $payload['advanced_machine_detection']->toArray(), $request); + $this->assertRequestJsonBodyContains( + 'advanced_machine_detection', + $payload['advanced_machine_detection']->toArray(), + $request + ); return true; }))->willReturn($this->getResponse('create-outbound-call-success', 201)); @@ -279,7 +284,9 @@ public function testCreateOutboundCallErrorUnknownFormat(): void $this->expectException(RequestException::class); $this->expectExceptionMessage("Unexpected error"); - $this->vonageClient->send(Argument::that(fn() => true))->willReturn($this->getResponse('error_unknown_format', 400)); + $this->vonageClient->send(Argument::that( + fn () => true + ))->willReturn($this->getResponse('error_unknown_format', 400)); $outboundCall = new OutboundCall(new Phone('15555555555'), new Phone('16666666666')); $this->voiceClient->createOutboundCall($outboundCall); diff --git a/test/VonageTestCase.php b/test/VonageTestCase.php index 863311cd..5fe3f65c 100644 --- a/test/VonageTestCase.php +++ b/test/VonageTestCase.php @@ -8,4 +8,4 @@ class VonageTestCase extends TestCase { use ProphecyTrait; -} \ No newline at end of file +}