'__return_true', ) ); StaticMockerHack::add_method_mocks( array( 'WC_Tax' => array( 'get_rates' => function( $tax_class, $customer ) use ( &$customer_passed_to_get_rates ) { $customer_passed_to_get_rates = $customer; }, 'get_base_tax_rates' => function( $tax_class ) { return 0; }, 'calc_tax' => function( $price, $rates, $price_includes_tax = false, $deprecated = false ) { return array( 0 ); }, ), ) ); // phpcs:disable Squiz.Commenting.FunctionComment.Missing $product = new class() extends WC_Product { public function get_price( $context = 'view' ) { return 0; } public function is_taxable() { return true; } public function get_tax_class( $context = 'view' ) { return ''; } }; $customer = new stdClass(); $this->register_legacy_proxy_class_mocks( array( 'WC_Customer' => function( $customer_id ) use ( &$customer_id_passed_to_wc_customer_constructor, $customer ) { $customer_id_passed_to_wc_customer_constructor = $customer_id; return $customer; }, ) ); if ( $pass_order ) { $order = new class() { public function get_customer_id() { return 1; } }; wc_get_price_excluding_tax( $product, array( 'order' => $order ) ); $this->assertEquals( $order->get_customer_id(), $customer_id_passed_to_wc_customer_constructor ); $this->assertSame( $customer, $customer_passed_to_get_rates ); } else { wc_get_price_excluding_tax( $product ); $this->assertFalse( $customer_id_passed_to_wc_customer_constructor ); $this->assertNull( $customer_passed_to_get_rates ); } // phpcs:enable Squiz.Commenting.FunctionComment.Missing } }