Skip to content

Commit

Permalink
Move get_merchant_id to setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemd24 committed Feb 20, 2024
1 parent 71e2c3d commit 6a9a0f9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/Unit/API/Google/MerchantReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class MerchantReportTest extends UnitTest {
/** @var MerchantReport $merchant_report */
protected $merchant_report;

/** Merchant ID */
protected const MERCHANT_ID = 432;


/**
* Runs before each test is executed.
Expand All @@ -57,6 +60,8 @@ public function setUp(): void {
$this->options = $this->createMock( OptionsInterface::class );
$this->merchant_report = new MerchantReport( $this->shopping_client, $this->product_helper );
$this->merchant_report->set_options_object( $this->options );

$this->options->method( 'get_merchant_id' )->willReturn( self::MERCHANT_ID );
}

/**
Expand All @@ -82,10 +87,9 @@ protected function create_product_view_product_status( string $mc_id, string $st
}

public function test_get_product_view_report() {
$test_merchant_id = 432;
$wc_product_id_1 = 882;
$wc_product_id_2 = 883;
$page_size = 800;
$wc_product_id_1 = 882;
$wc_product_id_2 = 883;
$page_size = 800;

add_filter(
'woocommerce_gla_product_view_report_page_size',
Expand All @@ -94,8 +98,6 @@ function () use ( $page_size ) {
}
);

$this->options->method( 'get_merchant_id' )->willReturn( $test_merchant_id );

$this->product_helper->method( 'get_wc_product_id' )->will(
$this->returnCallback(
function ( $mc_id ) use ( $wc_product_id_1, $wc_product_id_2 ) {
Expand Down Expand Up @@ -143,7 +145,7 @@ function ( $mc_id ) use ( $wc_product_id_1, $wc_product_id_2 ) {

$this->shopping_client->reports->expects( $this->once() )
->method( 'search' )
->with( $test_merchant_id, $search_request )
->with( self::MERCHANT_ID, $search_request )
->willReturn( $response );

$this->assertEquals(
Expand All @@ -167,8 +169,6 @@ function ( $mc_id ) use ( $wc_product_id_1, $wc_product_id_2 ) {
}

public function test_get_product_view_report_with_exception() {
$this->options->method( 'get_merchant_id' )->willReturn( 432 );

$this->shopping_client->reports->expects( $this->once() )
->method( 'search' )
->will(
Expand Down

0 comments on commit 6a9a0f9

Please sign in to comment.