diff --git a/src/Suite/Api/ContactListEndPoints.php b/src/Suite/Api/ContactListEndPoints.php index 2bda636..bade84a 100644 --- a/src/Suite/Api/ContactListEndPoints.php +++ b/src/Suite/Api/ContactListEndPoints.php @@ -57,11 +57,17 @@ public function contactIdsInList(int $customerId, int $contactListId, int $top = public function contactIdsInListNextChunk(int $customerId, string $next = null): ?string { - return $next ? "{$this->apiBaseUrl}/{$customerId}{$next}" : null; + + return $next ? $this->getBaseUrlWithoutInternalPostfix() . "{$next}" : null; } public function deleteContactsFromList(int $customerId, int $contactListId): string { return $this->baseUrl($customerId) . "/{$contactListId}/delete"; } + + public function getBaseUrlWithoutInternalPostfix(): string + { + return preg_replace('/\/internal$/', '', $this->apiBaseUrl); + } } diff --git a/test/helper/AcceptanceBaseTestCase.php b/test/helper/AcceptanceBaseTestCase.php index 1c3856f..163cca0 100644 --- a/test/helper/AcceptanceBaseTestCase.php +++ b/test/helper/AcceptanceBaseTestCase.php @@ -26,7 +26,7 @@ class AcceptanceBaseTestCase extends \PHPUnit\Framework\TestCase /** * @var string */ - protected $apiBaseUrl = 'http://localhost:7984'; + protected $apiBaseUrl = 'http://localhost:7984/internal'; protected function setUp(): void { diff --git a/test/helper/ApiStub.php b/test/helper/ApiStub.php index eadedbd..65845d4 100644 --- a/test/helper/ApiStub.php +++ b/test/helper/ApiStub.php @@ -24,42 +24,42 @@ public static function setUp() $app->before(self::authenticateWithEscher()); $app->error(self::handleError()); - $app->get('/', self::clientTestEndPoint()); + $app->get('/internal/', self::clientTestEndPoint()); foreach (include __DIR__.'/stubs.php' as $route => $data) { $app->get($route, function () use ($data) { return self::success($data); }); } - $app->post('/{customerId}/email/{campaignId}/preview/', function (Request $request) { + $app->post('/internal/{customerId}/email/{campaignId}/preview/', function (Request $request) { $params = json_decode($request->getContent(), true); return new Response(self::success('"'.$params['version'].' version"')); }); - $app->post('/{customerId}/email/{campaignId}/launch/', function (Request $request) { + $app->post('/internal/{customerId}/email/{campaignId}/launch/', function (Request $request) { return new Response(self::success("null")); }); - $app->post('/{customerId}/email/delete/', function (Request $request) { + $app->post('/internal/{customerId}/email/delete/', function (Request $request) { return new Response(self::success("null")); }); - $app->get('/serverError', function (Request $request) { + $app->get('/internal/serverError', function (Request $request) { self::logRetry(); return new Response(self::error("null"), 500); }); - $app->get('/retryCount', function (Request $request) { + $app->get('/internal/retryCount', function (Request $request) { return new Response(self::success(self::getRetryCount())); }); - $app->get('/{customerId}/contactlist/{contactListId}/contactIds', function (Request $request, $contactListId) { + $app->get('/internal/{customerId}/contactlist/{contactListId}/contactIds', function (Request $request, $contactListId, $customerId) { return match ($contactListId) { (string) self::LIST_ID_FOR_EMPTY_LIST => new Response(self::success('{"value":[],"next":null}')), (string) self::LIST_ID_FOR_LIST_WITH_SINGLE_CHUNK => new Response(self::success('{"value":[1,2,3],"next":null}')), (string) self::LIST_ID_FOR_LIST_WITH_MULTIPLE_CHUNKS => match ($request->query->get('$skiptoken') ?? '0') { - '0' => new Response(self::success('{"value":[1,2,3],"next":"/contactlist/'.$contactListId.'/contactIds?$skiptoken=1"}')), - '1' => new Response(self::success('{"value":[4,5,6],"next":"/contactlist/'.$contactListId.'/contactIds?$skiptoken=2"}')), - '2' => new Response(self::success('{"value":[7,8,9],"next":"/contactlist/'.$contactListId.'/contactIds?$skiptoken=3"}')), + '0' => new Response(self::success('{"value":[1,2,3],"next":"/internal/'.$customerId.'/contactlist/'.$contactListId.'/contactIds?$skiptoken=1"}')), + '1' => new Response(self::success('{"value":[4,5,6],"next":"/internal/'.$customerId.'/contactlist/'.$contactListId.'/contactIds?$skiptoken=2"}')), + '2' => new Response(self::success('{"value":[7,8,9],"next":"/internal/'.$customerId.'/contactlist/'.$contactListId.'/contactIds?$skiptoken=3"}')), '3' => new Response(self::success('{"value":[10,11],"next":null}')), }, (string) self::LIST_ID_FOR_WRONG_RESPONSE => new Response(self::error('invalid response format')), diff --git a/test/helper/stubs.php b/test/helper/stubs.php index 4c4b278..f5d9169 100644 --- a/test/helper/stubs.php +++ b/test/helper/stubs.php @@ -1,5 +1,5 @@ '{ + '/internal/{customerId}/email/{campaignId}/' => '{ "id": "1", "language": "en", "name": "20160407_1502_Copy of Test mail 1", @@ -35,7 +35,7 @@ "source": "userlist" }', - '/{customerId}/email/' => '[ + '/internal/{customerId}/email/' => '[ { "id": "2", "administrator": "3", @@ -87,7 +87,7 @@ "source": "profile" } ]', - '/{customerId}/administrator/' => '[ + '/internal/{customerId}/administrator/' => '[ { "id": "1", "username": "admin", @@ -130,7 +130,7 @@ } ]', - '/{customerId}/event' => '[ + '/internal/{customerId}/event' => '[ { "id": "1", "name": "event egy", @@ -149,7 +149,7 @@ } ]', - '/{customerId}/filter' => '[ + '/internal/{customerId}/filter' => '[ { "id": "1", "name": "segment 1",