Skip to content

Commit

Permalink
CR: assert on proper URLs in contact list API tests
Browse files Browse the repository at this point in the history
AUT-2568
  • Loading branch information
kozma committed Feb 12, 2024
1 parent 0e732ba commit b8d6f21
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions test/unit/Suite/Api/ContactListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ public function createContactList_Perfect_Perfect(): void
$contactIds = [1, 2, 3];
$this->apiClient
->method('post')
->with($this->endPoints->createContactList($this->customerId), [
'name' => $this->listName,
'key_id' => 'id',
'external_ids' => $contactIds,
])
->with(
"api_base_url/$this->customerId/contactlist",
[
'name' => $this->listName,
'key_id' => 'id',
'external_ids' => $contactIds,
]
)
->willReturn($this->apiSuccess(['id' => $this->contactListId]));

$contactListId = $this->listService->createContactList($this->customerId, $this->listName, $contactIds);
Expand Down Expand Up @@ -88,7 +91,7 @@ public function getContactLists_Perfect_Perfect(): void

$this->apiClient
->method('get')
->with($this->endPoints->contactLists($this->customerId))
->with("api_base_url/$this->customerId/contactlist")
->willReturn($this->apiSuccess($contactLists));

$returnedContactLists = $this->listService->getContactLists($this->customerId);
Expand All @@ -109,7 +112,7 @@ public function findContactListByName_Perfect_Perfect(): void

$this->apiClient
->method('get')
->with($this->endPoints->contactLists($this->customerId))
->with("api_base_url/$this->customerId/contactlist")
->willReturn($this->apiSuccess($contactLists));

$contactListId = $this->listService->findContactListByName($this->customerId, $this->listName);
Expand Down Expand Up @@ -178,7 +181,7 @@ public function addToContactList_Perfect_Perfect(): void
->expects($this->once())
->method('post')
->with(
$this->endPoints->addToContactList($this->customerId, $this->contactListId),
"api_base_url/$this->customerId/contactlist/654321/add",
[
'key_id' => 'id',
'external_ids' => $contactIds,
Expand Down Expand Up @@ -211,7 +214,7 @@ public function replaceContactList_Perfect_Perfect(): void
$this->apiClient
->method('post')
->with(
$this->endPoints->replaceContactList($this->customerId, $this->contactListId),
"api_base_url/$this->customerId/contactlist/654321/replace",
[
'key_id' => 'id',
'external_ids' => $contactIds,
Expand Down Expand Up @@ -239,12 +242,12 @@ public function replaceContactList_ApiFailure_ThrowsException(): void
/**
* @test
*/
public function getContactIdsInList_Perfect_Perfect(): void
public function getContactIdsInList_CalledWithProperUrl_ApiResponseConverted(): void
{
$response = ['value' => [1, 2, 3], 'next' => null];
$this->apiClient
->method('get')
->with($this->endPoints->contactIdsInList($this->customerId, $this->contactListId))
->with("api_base_url/$this->customerId/contactlist/$this->contactListId/contactIds")
->willReturn($this->apiSuccess($response));

$result = $this->listService->getContactIdsInList($this->customerId, $this->contactListId);
Expand Down Expand Up @@ -273,7 +276,7 @@ public function getContactsOfList_Perfect_Perfect(): void
$chunk = [1, 2, 3];
$this->apiClient
->method('get')
->with($this->endPoints->contactsOfList($this->customerId, $this->contactListId, $limit, $offset))
->with("api_base_url/$this->customerId/contactlist/654321/contacts/?limit=100&offset=200")
->willReturn($this->apiSuccess($chunk));

$result = $this->listService->getContactsOfList($this->customerId, $this->contactListId, $limit, $offset);
Expand Down Expand Up @@ -328,7 +331,7 @@ public function deleteContactsFromList_Perfect_Perfect(): void
->expects($this->once())
->method('post')
->with(
$this->endPoints->deleteContactsFromList($this->customerId, $this->contactListId),
"api_base_url/$this->customerId/contactlist/654321/delete",
[
'key_id' => 'id',
'external_ids' => $contactIds,
Expand Down

0 comments on commit b8d6f21

Please sign in to comment.