TenantAtlas/tests/Unit/MicrosoftGraphClientRetryPolicyTest.php
2026-01-19 19:01:36 +01:00

29 lines
807 B
PHP

<?php
use App\Services\Graph\MicrosoftGraphClient;
use Illuminate\Support\Facades\Http;
it('retries 429 responses using the shared retry policy', function () {
config([
'graph.base_url' => 'https://graph.microsoft.com',
'graph.version' => 'beta',
'graph.retry.times' => 2,
'graph.retry.sleep' => 0,
]);
Http::fakeSequence()
->push(['error' => ['code' => 'TooManyRequests', 'message' => 'throttled']], 429)
->push(['value' => []], 200);
/** @var MicrosoftGraphClient $client */
$client = app(MicrosoftGraphClient::class);
$response = $client->request('GET', '/deviceManagement/managedDevices', [
'access_token' => 'test-access-token',
]);
expect($response->success)->toBeTrue();
Http::assertSentCount(2);
});