diff --git a/tests/unit/payment-methods/test-class-upe-payment-gateway.php b/tests/unit/payment-methods/test-class-upe-payment-gateway.php index eca7d435c14..137a283a944 100644 --- a/tests/unit/payment-methods/test-class-upe-payment-gateway.php +++ b/tests/unit/payment-methods/test-class-upe-payment-gateway.php @@ -171,6 +171,13 @@ class UPE_Payment_Gateway_Test extends WCPAY_UnitTestCase { */ private $mock_fraud_service; + /** + * Mock Duplicates Detection Service. + * + * @var Duplicates_Detection_Service + */ + private $mock_duplicates_detection_service; + /** * Pre-test setup */ @@ -231,8 +238,9 @@ public function set_up() { $this->mock_dpps = $this->createMock( Duplicate_Payment_Prevention_Service::class ); - $this->mock_localization_service = $this->createMock( WC_Payments_Localization_Service::class ); - $this->mock_fraud_service = $this->createMock( WC_Payments_Fraud_Service::class ); + $this->mock_localization_service = $this->createMock( WC_Payments_Localization_Service::class ); + $this->mock_fraud_service = $this->createMock( WC_Payments_Fraud_Service::class ); + $this->mock_duplicates_detection_service = $this->createMock( Duplicates_Detection_Service::class ); $this->mock_payment_methods = []; $payment_method_classes = [ @@ -295,7 +303,7 @@ public function set_up() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ] ) ->setMethods( @@ -950,7 +958,6 @@ public function test_get_upe_available_payment_methods( $payment_methods, $expec ->expects( $this->any() ) ->method( 'get_fees' ) ->willReturn( $payment_methods ); - $mock_duplicates_detection_service = $this->createMock( Duplicates_Detection_Service::class ); $gateway = new WC_Payment_Gateway_WCPay( $this->mock_api_client, @@ -965,7 +972,7 @@ public function test_get_upe_available_payment_methods( $payment_methods, $expec $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $mock_duplicates_detection_service + $this->mock_duplicates_detection_service ); $this->assertEquals( $expected_result, $gateway->get_upe_available_payment_methods() ); diff --git a/tests/unit/payment-methods/test-class-upe-split-payment-gateway.php b/tests/unit/payment-methods/test-class-upe-split-payment-gateway.php index 5c305d09662..8ac1db139a5 100644 --- a/tests/unit/payment-methods/test-class-upe-split-payment-gateway.php +++ b/tests/unit/payment-methods/test-class-upe-split-payment-gateway.php @@ -159,6 +159,13 @@ class UPE_Split_Payment_Gateway_Test extends WCPAY_UnitTestCase { */ private $mock_fraud_service; + /** + * Mock Duplicates Detection Service. + * + * @var Duplicates_Detection_Service + */ + private $mock_duplicates_detection_service; + /** * Mapping for payment ID to payment method. * @@ -248,8 +255,9 @@ public function set_up() { $this->mock_dpps = $this->createMock( Duplicate_Payment_Prevention_Service::class ); - $this->mock_localization_service = $this->createMock( WC_Payments_Localization_Service::class ); - $this->mock_fraud_service = $this->createMock( WC_Payments_Fraud_Service::class ); + $this->mock_localization_service = $this->createMock( WC_Payments_Localization_Service::class ); + $this->mock_fraud_service = $this->createMock( WC_Payments_Fraud_Service::class ); + $this->mock_duplicates_detection_service = $this->createMock( Duplicates_Detection_Service::class ); // Arrange: Define a $_POST array which includes the payment method, // so that get_payment_method_from_request() does not throw error. @@ -282,7 +290,7 @@ public function set_up() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ] ) ->setMethods( @@ -1062,7 +1070,7 @@ public function test_get_payment_methods_with_request_context() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ] ) ->setMethods( [ 'get_payment_methods_from_gateway_id' ] ) @@ -1108,7 +1116,7 @@ public function test_get_payment_methods_without_request_context() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ] ) ->setMethods( [ 'get_payment_methods_from_gateway_id' ] ) @@ -1153,7 +1161,7 @@ public function test_get_payment_methods_without_request_context_or_token() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ] ) ->setMethods( @@ -1207,7 +1215,7 @@ public function test_get_payment_methods_from_gateway_id_upe() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ] ) ->onlyMethods( diff --git a/tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions.php b/tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions.php index 4e50568e8b6..151b3b919fe 100644 --- a/tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions.php +++ b/tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions.php @@ -103,6 +103,13 @@ class WC_Payment_Gateway_WCPay_Subscriptions_Test extends WCPAY_UnitTestCase { */ private $mock_fraud_service; + /** + * Mock Duplicates Detection Service. + * + * @var Duplicates_Detection_Service + */ + private $mock_duplicates_detection_service; + public function set_up() { parent::set_up(); @@ -137,8 +144,9 @@ public function set_up() { $this->mock_dpps = $this->createMock( Duplicate_Payment_Prevention_Service::class ); - $this->mock_localization_service = $this->createMock( WC_Payments_Localization_Service::class ); - $this->mock_fraud_service = $this->createMock( WC_Payments_Fraud_Service::class ); + $this->mock_localization_service = $this->createMock( WC_Payments_Localization_Service::class ); + $this->mock_fraud_service = $this->createMock( WC_Payments_Fraud_Service::class ); + $this->mock_duplicates_detection_service = $this->createMock( Duplicates_Detection_Service::class ); $mock_payment_method = $this->getMockBuilder( CC_Payment_Method::class ) ->setConstructorArgs( [ $this->mock_token_service ] ) @@ -158,7 +166,7 @@ public function set_up() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ); $this->wcpay_gateway->init_hooks(); WC_Payments::set_gateway( $this->wcpay_gateway ); @@ -832,7 +840,8 @@ public function test_adds_custom_payment_meta_input_fallback_until_subs_3_0_7() $this->order_service, $this->mock_dpps, $this->mock_localization_service, - $this->mock_fraud_service + $this->mock_fraud_service, + $this->mock_duplicates_detection_service, ); // Ensure the has_attached_integration_hooks property is set to false so callbacks can be attached in maybe_init_subscriptions(). @@ -866,7 +875,8 @@ public function test_does_not_add_custom_payment_meta_input_fallback_for_subs_3_ $this->order_service, $this->mock_dpps, $this->mock_localization_service, - $this->mock_fraud_service + $this->mock_fraud_service, + $this->mock_duplicates_detection_service, ); $this->assertFalse( has_action( 'woocommerce_admin_order_data_after_billing_address' ) ); diff --git a/tests/unit/test-class-wc-payment-gateway-wcpay.php b/tests/unit/test-class-wc-payment-gateway-wcpay.php index e28fc51612d..c485a19ecb3 100644 --- a/tests/unit/test-class-wc-payment-gateway-wcpay.php +++ b/tests/unit/test-class-wc-payment-gateway-wcpay.php @@ -178,6 +178,13 @@ class WC_Payment_Gateway_WCPay_Test extends WCPAY_UnitTestCase { */ private $mock_fraud_service; + /** + * Mock Duplicates Detection Service. + * + * @var Duplicates_Detection_Service + */ + private $mock_duplicates_detection_service; + /** * Pre-test setup */ @@ -230,7 +237,8 @@ public function set_up() { 'currency_code' => 'usd', ] ); - $this->mock_fraud_service = $this->createMock( WC_Payments_Fraud_Service::class ); + $this->mock_fraud_service = $this->createMock( WC_Payments_Fraud_Service::class ); + $this->mock_duplicates_detection_service = $this->createMock( Duplicates_Detection_Service::class ); $this->mock_payment_method = $this->getMockBuilder( CC_Payment_Method::class ) ->setConstructorArgs( [ $this->mock_token_service ] ) @@ -898,7 +906,7 @@ public function test_process_redirect_setup_intent_succeded() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ] ) ->onlyMethods( @@ -1006,7 +1014,7 @@ public function test_process_redirect_payment_save_payment_token() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ] ) ->onlyMethods( @@ -3206,7 +3214,7 @@ private function get_partial_mock_for_gateway( array $methods = [], array $const $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ), + $this->mock_duplicates_detection_service, ]; foreach ( $constructor_replacement as $key => $value ) { @@ -3693,7 +3701,7 @@ private function init_gateways() { $this->mock_dpps, $this->mock_localization_service, $this->mock_fraud_service, - $this->createMock( Duplicates_Detection_Service::class ) + $this->mock_duplicates_detection_service ); }