From 0f67d02f078de9fc3d42d265da6bbd2e847201f1 Mon Sep 17 00:00:00 2001 From: Jim Seconde Date: Mon, 14 Oct 2024 16:02:22 +0100 Subject: [PATCH] Friends of PHP code lint fixer --- composer.json | 2 +- src/Client.php | 4 +- src/Client/APIResource.php | 9 +- .../Credentials/Handler/HandlerInterface.php | 2 +- src/Client/Exception/Validation.php | 8 +- src/Conversation/Client.php | 2 +- src/Meetings/Room.php | 2 +- src/Numbers/Client.php | 2 +- src/ProactiveConnect/Objects/ManualList.php | 2 +- .../Objects/SalesforceList.php | 2 +- src/Subaccount/Client.php | 16 +- src/Verify2/Request/BaseVerifyRequest.php | 2 +- .../Credentials/Handler/GnpHandlerTest.php | 45 +++- test/Conversation/ClientTest.php | 225 +++++++++++++++--- test/Insights/ClientTest.php | 6 +- test/Numbers/ClientTest.php | 43 +++- test/ProactiveConnect/ClientTest.php | 4 +- test/Redact/ClientTest.php | 2 +- test/SMS/ClientTest.php | 4 +- test/SimSwap/ClientTest.php | 13 +- test/Verify2/ClientTest.php | 118 ++++++--- test/Voice/ClientTest.php | 10 +- 22 files changed, 414 insertions(+), 109 deletions(-) diff --git a/composer.json b/composer.json index 9156b404..63fd0113 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "softcreatr/jsonpath": "^0.7 || ^0.8", "phpspec/prophecy-phpunit": "^2.0", "rector/rector": "^1.1", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.10", }, "config": { "optimize-autoloader": true, 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/APIResource.php b/src/Client/APIResource.php index bcb5773c..dda10b43 100644 --- a/src/Client/APIResource.php +++ b/src/Client/APIResource.php @@ -182,8 +182,13 @@ public function delete(string $id, array $headers = []): ?array * @throws ClientExceptionInterface * @throws Exception\Exception */ - public function get($id, array $query = [], array $headers = [], bool $jsonResponse = true, bool $uriOverride = false) - { + public function get( + $id, + array $query = [], + array $headers = [], + bool $jsonResponse = true, + bool $uriOverride = false + ) { $uri = $this->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/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/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/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/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/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/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/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/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/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/Conversation/ClientTest.php b/test/Conversation/ClientTest.php index 24e77032..efba9c78 100644 --- a/test/Conversation/ClientTest.php +++ b/test/Conversation/ClientTest.php @@ -98,7 +98,11 @@ public function testWillListConversations(): void } 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; @@ -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/ClientTest.php b/test/Insights/ClientTest.php index 24a226ff..bbe2d75e 100644 --- a/test/Insights/ClientTest.php +++ b/test/Insights/ClientTest.php @@ -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'); } diff --git a/test/Numbers/ClientTest.php b/test/Numbers/ClientTest.php index a321c7b0..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); @@ -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; @@ -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/ProactiveConnect/ClientTest.php b/test/ProactiveConnect/ClientTest.php index 8f86bae8..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') 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 77f853f9..b3a58c17 100644 --- a/test/SMS/ClientTest.php +++ b/test/SMS/ClientTest.php @@ -413,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/Verify2/ClientTest.php b/test/Verify2/ClientTest.php index e4d1a11e..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()); @@ -949,7 +1003,10 @@ public function testWillCreateTemplateFragment(): void '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 c4707ccc..8d24212c 100644 --- a/test/Voice/ClientTest.php +++ b/test/Voice/ClientTest.php @@ -146,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)); @@ -280,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);