Skip to content

Commit

Permalink
Fix fetch auth token tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yash30201 committed Oct 27, 2023
1 parent c2cb07d commit 5b5cdf9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/FetchAuthTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Google\Auth\CredentialsLoader;
use Google\Auth\FetchAuthTokenInterface;
use Google\Auth\OAuth2;
use Google\Auth\UpdateMetadataInterface;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;

Expand Down Expand Up @@ -53,9 +54,19 @@ class_implements($fetcherClass)
)) {
$mockFetcher->getQuotaProject()->shouldBeCalledTimes(1);
}
$mockFetcher->fetchAuthToken(Argument::any())

if (is_a($fetcherClass, UpdateMetadataInterface::class, true)) {
$mockFetcher->updateMetadata(Argument::cetera())
->shouldBeCalledTimes(1)
->willReturn(['authorization' => 'Bearer xyz']);
$mockFetcher->getLastReceivedToken()
->shouldBeCalledTimes(1)
->will($httpHandler);
} else {
$mockFetcher->fetchAuthToken(Argument::any())
->shouldBeCalledTimes(1)
->will($httpHandler);
}
$mockFetcher->getCacheKey()->willReturn('');

$tokenCallbackCalled = false;
Expand Down

0 comments on commit 5b5cdf9

Please sign in to comment.