diff --git a/tests/unit-tests/CheckoutProcess.php b/tests/unit-tests/CheckoutProcess.php index 63c0f957..55ad729a 100644 --- a/tests/unit-tests/CheckoutProcess.php +++ b/tests/unit-tests/CheckoutProcess.php @@ -25,7 +25,13 @@ public function test_begin_checkout_event() { $cart = WC()->cart; $add_to = $cart->add_to_cart( $product->get_id() ); - ( new WC_Google_Gtag_JS() )->checkout_process( $cart->get_cart() ); + + $mock = $this->getMockBuilder( WC_Google_Gtag_JS::class ) + ->setMethods( array( '__construct' ) ) + ->setConstructorArgs( array( array( 'ga_enhanced_checkout_process_enabled' => 'yes' ) ) ) + ->getMock(); + + $mock->checkout_process( $cart->get_cart() ); // Confirm woocommerce_gtag_event_data is called by checkout_process(). $this->assertEquals( 1, $this->get_event_data_filter_call_count(), 'woocommerce_gtag_event_data filter was not called for begin_checkout (checkout_process()) event' ); diff --git a/tests/unit-tests/ProductDetail.php b/tests/unit-tests/ProductDetail.php index f73723aa..e6b34e2d 100644 --- a/tests/unit-tests/ProductDetail.php +++ b/tests/unit-tests/ProductDetail.php @@ -19,9 +19,15 @@ class ProductDetail extends EventsDataTest { * @return void */ public function test_view_item_event() { + global $product; $product = $this->get_product(); - ( new WC_Google_Gtag_JS() )->product_detail( $product ); + $mock = $this->getMockBuilder( WC_Google_Gtag_JS::class ) + ->setMethods( array( '__construct' ) ) + ->setConstructorArgs( array( array( 'ga_enhanced_product_detail_view_enabled' => 'yes' ) ) ) + ->getMock(); + + $mock->product_detail(); // Confirm woocommerce_gtag_event_data is called by product_detail(). $this->assertEquals( 1, $this->get_event_data_filter_call_count(), 'woocommerce_gtag_event_data filter was not called for view_item (product_detail()) event' );