Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
annemirasol committed Oct 30, 2024
1 parent 5fade4c commit c9c7efe
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/phpunit/test-wc-stripe-express-checkout-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,27 @@ public function test_hides_ece_if_cannot_compute_taxes() {
WC()->cart->add_to_cart( $shippable_product->get_id(), 1 );
$this->assertTrue( $wc_stripe_ece_helper_mock->should_show_express_checkout_button() );
}

/**
* Test for get_checkout_data().
*/
public function test_get_checkout_data() {
// Local setup
update_option( 'woocommerce_checkout_phone_field', 'optional' );
update_option( 'woocommerce_default_country', 'US' );
update_option( 'woocommerce_currency', 'USD' );
WC()->cart->empty_cart();

$wc_stripe_ece_helper = new WC_Stripe_Express_Checkout_Helper();
$checkout_data = $wc_stripe_ece_helper->get_checkout_data();

$this->assertNotEmpty( $checkout_data['url'] );
$this->assertEquals( 'usd', $checkout_data['currency_code'] );
$this->assertEquals( 'US', $checkout_data['country_code'] );
$this->assertEquals( 'no', $checkout_data['needs_shipping'] );
$this->assertFalse( $checkout_data['needs_payer_phone'] );
$this->assertArrayHasKey( 'id', $checkout_data['default_shipping_option'] );
$this->assertArrayHasKey( 'displayName', $checkout_data['default_shipping_option'] );
$this->assertArrayHasKey( 'amount', $checkout_data['default_shipping_option'] );
}
}

0 comments on commit c9c7efe

Please sign in to comment.