|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * These teste make assertions against class WC_Stripe_Payment_Request. |
| 3 | + * These tests make assertions against class WC_Stripe_Payment_Request. |
4 | 4 | *
|
5 | 5 | * @package WooCommerce_Stripe/Tests/Payment_Request
|
6 | 6 | */
|
@@ -208,7 +208,8 @@ public function test_migrate_button_size() {
|
208 | 208 | /**
|
209 | 209 | * Migration tests.
|
210 | 210 | *
|
211 |
| - * Migrating the button size only happens when the plugin is updated from a version pre 7.8.0. |
| 211 | + * Migrating the button size only happens when the plugin is updated from a version pre 7.8.0, |
| 212 | + * or when the button size is set to 'medium'. |
212 | 213 | */
|
213 | 214 | update_option( 'wc_stripe_version', '7.6.0' );
|
214 | 215 |
|
@@ -242,10 +243,46 @@ public function test_migrate_button_size() {
|
242 | 243 | $this->pr->migrate_button_size();
|
243 | 244 | $this->assertEquals( 'large', $this->pr->stripe_settings['payment_request_button_size'] );
|
244 | 245 |
|
245 |
| - // Medium => Medium. |
| 246 | + // Medium => default. |
| 247 | + $this->pr->stripe_settings = [ 'payment_request_button_size' => 'medium' ]; |
| 248 | + $this->pr->migrate_button_size(); |
| 249 | + $this->assertEquals( 'default', $this->pr->stripe_settings['payment_request_button_size'] ); |
| 250 | + |
| 251 | + // Small => small. |
| 252 | + $this->pr->stripe_settings = [ 'payment_request_button_size' => 'small' ]; |
| 253 | + $this->pr->migrate_button_size(); |
| 254 | + $this->assertEquals( 'small', $this->pr->stripe_settings['payment_request_button_size'] ); |
| 255 | + |
| 256 | + // Button size not set. |
| 257 | + $this->pr->stripe_settings = []; |
| 258 | + $this->pr->migrate_button_size(); |
| 259 | + $this->assertArrayNotHasKey( 'payment_request_button_size', $this->pr->stripe_settings ); |
| 260 | + $this->assertEmpty( $this->pr->stripe_settings ); |
| 261 | + |
| 262 | + /** |
| 263 | + * Post-migration tests. |
| 264 | + */ |
| 265 | + update_option( 'wc_stripe_version', '9.0.0' ); |
| 266 | + |
| 267 | + // Default => default. |
| 268 | + $this->pr->stripe_settings = [ 'payment_request_button_size' => 'default' ]; |
| 269 | + $this->pr->migrate_button_size(); |
| 270 | + $this->assertEquals( 'default', $this->pr->stripe_settings['payment_request_button_size'] ); |
| 271 | + |
| 272 | + // Large => large. |
| 273 | + $this->pr->stripe_settings = [ 'payment_request_button_size' => 'large' ]; |
| 274 | + $this->pr->migrate_button_size(); |
| 275 | + $this->assertEquals( 'large', $this->pr->stripe_settings['payment_request_button_size'] ); |
| 276 | + |
| 277 | + // Medium => default. |
246 | 278 | $this->pr->stripe_settings = [ 'payment_request_button_size' => 'medium' ];
|
247 | 279 | $this->pr->migrate_button_size();
|
248 |
| - $this->assertEquals( 'medium', $this->pr->stripe_settings['payment_request_button_size'] ); |
| 280 | + $this->assertEquals( 'default', $this->pr->stripe_settings['payment_request_button_size'] ); |
| 281 | + |
| 282 | + // Small => small. |
| 283 | + $this->pr->stripe_settings = [ 'payment_request_button_size' => 'small' ]; |
| 284 | + $this->pr->migrate_button_size(); |
| 285 | + $this->assertEquals( 'small', $this->pr->stripe_settings['payment_request_button_size'] ); |
249 | 286 |
|
250 | 287 | // Button size not set.
|
251 | 288 | $this->pr->stripe_settings = [];
|
|
0 commit comments