-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement getListChunkIterator() as a generator function that uses …
…the fetch (/contactIds) endpoint instead of the legacy (/contacts) endpoint AUT-3246 Co-authored-by: Bence Kadar <[email protected]>
- Loading branch information
1 parent
1ffec2b
commit 5653bba
Showing
6 changed files
with
101 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Suite\Api\Acceptance; | ||
|
||
use Suite\Api\RequestFailed; | ||
use Suite\Api\Test\Helper\AcceptanceBaseTestCase; | ||
use Suite\Api\Test\Helper\ApiStub; | ||
|
||
class ContactListChunkIteratorTest extends AcceptanceBaseTestCase | ||
{ | ||
protected int $customerId = 123456; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getListChunkIterator_EmptyContactList_ReturnsSingleEmptyChunk(): void | ||
{ | ||
$this->assertEquals([[]], $this->getChunksOfContactList(ApiStub::LIST_ID_FOR_EMPTY_LIST)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getListChunkIterator_ContactListContainsSingleChunk_ReturnsContactIds(): void | ||
{ | ||
$this->assertEquals([[1, 2, 3]], $this->getChunksOfContactList(ApiStub::LIST_ID_FOR_LIST_WITH_SINGLE_CHUNK)); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function getListChunkIterator_SeveralChunks_ReturnsContactIdsInChunks(): void | ||
{ | ||
$this->assertEquals([ | ||
[1, 2, 3], | ||
[4, 5, 6], | ||
[7, 8, 9], | ||
[10, 11], | ||
], $this->getChunksOfContactList(ApiStub::LIST_ID_FOR_LIST_WITH_MULTIPLE_CHUNKS)); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function getListChunkIterator_ApiRequestFailed_ThrowsException(): void | ||
{ | ||
$this->expectException(RequestFailed::class); | ||
$this->getChunksOfContactList(ApiStub::LIST_ID_FOR_WRONG_RESPONSE); | ||
} | ||
|
||
private function getChunksOfContactList(int $contactListId): array | ||
{ | ||
return iterator_to_array($this->factory->createContactList()->getListChunkIterator($this->customerId, $contactListId)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters