From ffa437761588a8f464b40018911d2cc05b55abfb Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Fri, 26 Jun 2026 13:13:15 -0300 Subject: [PATCH] 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. --- .../Feature/Services/Social/TikTokCreatorInfoTest.php | 10 ++++++---- .../Exceptions/Social/TikTokPublishExceptionTest.php | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/Feature/Services/Social/TikTokCreatorInfoTest.php b/tests/Feature/Services/Social/TikTokCreatorInfoTest.php index 15ad23a9..f12bed08 100644 --- a/tests/Feature/Services/Social/TikTokCreatorInfoTest.php +++ b/tests/Feature/Services/Social/TikTokCreatorInfoTest.php @@ -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'], ], diff --git a/tests/Unit/Exceptions/Social/TikTokPublishExceptionTest.php b/tests/Unit/Exceptions/Social/TikTokPublishExceptionTest.php index b852e218..c05d8135 100644 --- a/tests/Unit/Exceptions/Social/TikTokPublishExceptionTest.php +++ b/tests/Unit/Exceptions/Social/TikTokPublishExceptionTest.php @@ -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);