Skip to content

Commit 74cc799

Browse files
committed
Update settings controller tests
1 parent 4a120e0 commit 74cc799

2 files changed

+17
-9
lines changed

tests/phpunit/admin/test-class-wc-rest-stripe-settings-controller-gb.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function set_up() {
9898
$upe_helper->reload_payment_gateways();
9999

100100
$this->stripe_api = $this->createMock( WC_Stripe_API::class );
101-
$this->controller = new WC_REST_Stripe_Settings_Controller( new WC_Stripe_UPE_Payment_Gateway(), $this->stripe_api );
101+
$this->controller = new WC_REST_Stripe_Settings_Controller( new WC_Stripe_UPE_Payment_Gateway() );
102102

103103
$this->stripe_api->method( 'get_payment_method_configurations' )->willReturn(
104104
(object) [

tests/phpunit/admin/test-class-wc-rest-stripe-settings-controller.php

+16-8
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public function set_up() {
8181
}
8282

8383
$this->stripe_api = $this->createMock( WC_Stripe_API::class );
84-
$this->controller = new WC_REST_Stripe_Settings_Controller( $this->get_gateway(), $this->stripe_api );
84+
WC_Stripe_API::set_instance( $this->stripe_api );
85+
$this->controller = new WC_REST_Stripe_Settings_Controller( $this->get_gateway() );
8586

8687
add_action( 'rest_api_init', [ $this, 'deregister_wc_blocks_rest_api' ], 5 );
8788

@@ -165,28 +166,35 @@ public function test_update_stripe_payment_method_configurations_settings() {
165166
],
166167
);
167168

168-
$this->stripe_api->method( 'update_payment_method_configurations' )->with(
169+
$this->stripe_api->expects( $this->once() )->method( 'update_payment_method_configurations' )->with(
169170
$this->equalTo( 'pmc_abcdef' ),
170171
$this->equalTo(
171172
[
172173
'amazon_pay' => [
173-
'display_preference' => (object) [ 'value' => 'on' ],
174+
'display_preference' => [ 'preference' => 'on' ],
174175
],
175176
'card' => [
176-
'display_preference' => (object) [ 'value' => 'on' ],
177+
'display_preference' => [ 'preference' => 'on' ],
177178
],
178-
'boleto' => [
179-
'display_preference' => (object) [ 'preference' => 'on' ],
179+
'us_bank_account' => [
180+
'display_preference' => [ 'preference' => 'off' ],
180181
],
181-
'link' => [
182-
'display_preference' => (object) [ 'preference' => 'off' ],
182+
'affirm' => [
183+
'display_preference' => [ 'preference' => 'off' ],
184+
],
185+
'afterpay_clearpay' => [
186+
'display_preference' => [ 'preference' => 'off' ],
187+
],
188+
'cashapp' => [
189+
'display_preference' => [ 'preference' => 'off' ],
183190
],
184191
]
185192
),
186193
);
187194

188195
$request = new WP_REST_Request( 'POST', self::SETTINGS_ROUTE );
189196
$request->set_param( 'enabled_payment_method_ids', [ 'amazon_pay', 'card' ] );
197+
$request->set_param( 'is_upe_enabled', true );
190198

191199
$response = $this->controller->update_settings( $request );
192200
$this->assertEquals( 200, $response->get_status() );

0 commit comments

Comments
 (0)