test(tiktok): fake against the config base URL across all TikTok test files
Convert TikTokCreatorInfoTest and TikTokPublishExceptionTest to fake against
config('trypost.platforms.tiktok.api') instead of the hardcoded host, matching
the TikTokPublisherTest cleanup. TikTokControllerTest is left as-is: its only
TikTok URL is a Socialite authorize stub, which has no config counterpart.
This commit is contained in:
parent
5df854092b
commit
ffa4377615
2 changed files with 10 additions and 8 deletions
|
|
@ -17,11 +17,13 @@
|
|||
]);
|
||||
|
||||
$this->service = new TikTokCreatorInfo;
|
||||
|
||||
$this->api = config('trypost.platforms.tiktok.api');
|
||||
});
|
||||
|
||||
test('it returns full creator payload from api response', function () {
|
||||
Http::fake([
|
||||
'https://open.tiktokapis.com/v2/post/publish/creator_info/query/' => Http::response([
|
||||
$this->api.'/post/publish/creator_info/query/' => Http::response([
|
||||
'data' => [
|
||||
'creator_nickname' => 'Paulo',
|
||||
'creator_username' => 'paulocastellano',
|
||||
|
|
@ -49,7 +51,7 @@
|
|||
|
||||
test('it returns an empty payload when the api fails', function () {
|
||||
Http::fake([
|
||||
'https://open.tiktokapis.com/v2/post/publish/creator_info/query/' => Http::response(['error' => 'unauthorized'], 401),
|
||||
$this->api.'/post/publish/creator_info/query/' => Http::response(['error' => 'unauthorized'], 401),
|
||||
]);
|
||||
|
||||
$info = $this->service->fetch($this->account);
|
||||
|
|
@ -66,12 +68,12 @@
|
|||
$this->account->update(['token_expires_at' => now()->subMinute()]);
|
||||
|
||||
Http::fake([
|
||||
'https://open.tiktokapis.com/v2/oauth/token/' => Http::response([
|
||||
$this->api.'/oauth/token/' => Http::response([
|
||||
'access_token' => 'new-token',
|
||||
'refresh_token' => 'new-refresh',
|
||||
'expires_in' => 3600,
|
||||
], 200),
|
||||
'https://open.tiktokapis.com/v2/post/publish/creator_info/query/' => Http::response([
|
||||
$this->api.'/post/publish/creator_info/query/' => Http::response([
|
||||
'data' => [
|
||||
'privacy_level_options' => ['PUBLIC_TO_EVERYONE'],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
],
|
||||
], 429);
|
||||
|
||||
$fakeResponse = Http::fake(['*' => $response])->post('https://open.tiktokapis.com/test');
|
||||
$fakeResponse = Http::fake(['*' => $response])->post(config('trypost.platforms.tiktok.api').'/test');
|
||||
|
||||
$exception = TikTokPublishException::fromApiResponse($fakeResponse);
|
||||
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
],
|
||||
], 401);
|
||||
|
||||
$fakeResponse = Http::fake(['*' => $response])->post('https://open.tiktokapis.com/test');
|
||||
$fakeResponse = Http::fake(['*' => $response])->post(config('trypost.platforms.tiktok.api').'/test');
|
||||
|
||||
TikTokPublishException::fromApiResponse($fakeResponse);
|
||||
})->throws(TokenExpiredException::class);
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
],
|
||||
], 400);
|
||||
|
||||
$fakeResponse = Http::fake(['*' => $response])->post('https://open.tiktokapis.com/test');
|
||||
$fakeResponse = Http::fake(['*' => $response])->post(config('trypost.platforms.tiktok.api').'/test');
|
||||
|
||||
$exception = TikTokPublishException::fromApiResponse($fakeResponse);
|
||||
|
||||
|
|
@ -91,7 +91,7 @@
|
|||
],
|
||||
], 400);
|
||||
|
||||
$fakeResponse = Http::fake(['*' => $response])->post('https://open.tiktokapis.com/test');
|
||||
$fakeResponse = Http::fake(['*' => $response])->post(config('trypost.platforms.tiktok.api').'/test');
|
||||
|
||||
$exception = TikTokPublishException::fromApiResponse($fakeResponse);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue