Skip to content

Commit

Permalink
Add a test for the retry mechanism of the `API\Google\Ads::get_mercha…
Browse files Browse the repository at this point in the history
…nt_link` method.
  • Loading branch information
eason9487 committed May 27, 2024
1 parent cdd6807 commit 6e54e69
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Unit/API/Google/AdsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,30 @@ public function test_accept_merchant_link_already_accepted() {
$this->ads->accept_merchant_link( self::TEST_MERCHANT_ID );
}

public function test_accept_merchant_link_with_retry_get_merchant_link() {
$this->options->method( 'get_ads_id' )->willReturn( self::TEST_ADS_ID );
$link = new ProductLinkInvitation();
$mc = $this->createMock( MerchantCenterLinkInvitationIdentifier::class );

$mc
->expects( $this->exactly( 4 ) )
->method( 'getMerchantCenterId' )
->willReturnOnConsecutiveCalls(
self::TEST_MERCHANT_ID + 3,
self::TEST_MERCHANT_ID + 2,
self::TEST_MERCHANT_ID + 1,
self::TEST_MERCHANT_ID
);

$link->setStatus( ProductLinkInvitationStatus::PENDING_APPROVAL );
$link->setMerchantCenter( $mc );

$service = $this->generate_mc_link_mock( [ $link ] );
$service->expects( $this->once() )->method( 'updateProductLinkInvitation' );

$this->ads->accept_merchant_link( self::TEST_MERCHANT_ID );
}

public function test_accept_merchant_link() {
$this->options->method( 'get_ads_id' )->willReturn( self::TEST_ADS_ID );
$link = new ProductLinkInvitation();
Expand Down

0 comments on commit 6e54e69

Please sign in to comment.