@@ -6,21 +6,21 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class WC_Stripe_level3_Data_Test extends WP_UnitTestCase { |
| 8 | 8 | public function test_data_for_mutli_item_order() { |
| 9 | - update_option( 'woocommerce_default_country', 'US:CA' ); |
|
| 9 | + update_option('woocommerce_default_country', 'US:CA'); |
|
| 10 | 10 | $store_postcode = '90210'; |
| 11 | - update_option( 'woocommerce_store_postcode', $store_postcode ); |
|
| 11 | + update_option('woocommerce_store_postcode', $store_postcode); |
|
| 12 | 12 | |
| 13 | 13 | // Arrange: Create a couple of products to use. |
| 14 | 14 | $variation_product = WC_Helper_Product::create_variation_product(); |
| 15 | 15 | $variation_ids = $variation_product->get_children(); |
| 16 | 16 | |
| 17 | - $product_1 = wc_get_product ( $variation_ids[0] ); |
|
| 18 | - $product_1->set_regular_price( 19.19 ); |
|
| 19 | - $product_1->set_sale_price( 11.83 ); |
|
| 17 | + $product_1 = wc_get_product($variation_ids[0]); |
|
| 18 | + $product_1->set_regular_price(19.19); |
|
| 19 | + $product_1->set_sale_price(11.83); |
|
| 20 | 20 | $product_1->save(); |
| 21 | 21 | |
| 22 | - $product_2 = wc_get_product( $variation_ids[1] ); |
|
| 23 | - $product_2->set_regular_price( 20.05 ); |
|
| 22 | + $product_2 = wc_get_product($variation_ids[1]); |
|
| 23 | + $product_2->set_regular_price(20.05); |
|
| 24 | 24 | $product_2->save(); |
| 25 | 25 | |
| 26 | 26 | // Arrange: Set up an order with: |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | // 2) The same product added several times. |
| 29 | 29 | // 3) A valid US ZIP code |
| 30 | 30 | $order = new WC_Order(); |
| 31 | - $order->set_shipping_postcode( '90210' ); |
|
| 32 | - $order->add_product( $product_1, 1 ); // Add one item of the first product variation |
|
| 33 | - $order->add_product( $product_2, 2 ); // Add two items of the second product variation |
|
| 31 | + $order->set_shipping_postcode('90210'); |
|
| 32 | + $order->add_product($product_1, 1); // Add one item of the first product variation |
|
| 33 | + $order->add_product($product_2, 2); // Add two items of the second product variation |
|
| 34 | 34 | |
| 35 | 35 | $order->save(); |
| 36 | 36 | $order->calculate_totals(); |
| 37 | 37 | |
| 38 | 38 | // Act: Call get_level3_data_from_order(). |
| 39 | 39 | $gateway = new WC_Gateway_Stripe(); |
| 40 | - $result = $gateway->get_level3_data_from_order( $order ); |
|
| 40 | + $result = $gateway->get_level3_data_from_order($order); |
|
| 41 | 41 | |
| 42 | 42 | // Assert. |
| 43 | 43 | $this->assertEquals( |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | 'line_items' => array( |
| 50 | 50 | (object) array( |
| 51 | 51 | 'product_code' => (string) $product_1->get_id(), |
| 52 | - 'product_description' => substr( $product_1->get_name(), 0, 26 ), |
|
| 52 | + 'product_description' => substr($product_1->get_name(), 0, 26), |
|
| 53 | 53 | 'unit_cost' => 1183, |
| 54 | 54 | 'quantity' => 1, |
| 55 | 55 | 'tax_amount' => 0, |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | ), |
| 58 | 58 | (object) array( |
| 59 | 59 | 'product_code' => (string) $product_2->get_id(), |
| 60 | - 'product_description' => substr( $product_2->get_name(), 0, 26 ), |
|
| 60 | + 'product_description' => substr($product_2->get_name(), 0, 26), |
|
| 61 | 61 | 'unit_cost' => 2005, |
| 62 | 62 | 'quantity' => 2, |
| 63 | 63 | 'tax_amount' => 0, |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | // Assert: Check that Stripe's total charge check passes. |
| 72 | - $total_charged = WC_Stripe_Helper::get_stripe_amount( $order->get_total() ); |
|
| 73 | - $sum_of_unit_costs = array_reduce( $result['line_items'], function( $sum, $item ) { |
|
| 72 | + $total_charged = WC_Stripe_Helper::get_stripe_amount($order->get_total()); |
|
| 73 | + $sum_of_unit_costs = array_reduce($result['line_items'], function($sum, $item) { |
|
| 74 | 74 | return $sum + $item->quantity * $item->unit_cost; |
| 75 | 75 | } ); |
| 76 | - $sum_of_taxes = array_reduce( $result['line_items'], function( $sum, $item ) { |
|
| 76 | + $sum_of_taxes = array_reduce($result['line_items'], function($sum, $item) { |
|
| 77 | 77 | return $sum + $item->tax_amount; |
| 78 | 78 | } ); |
| 79 | - $sum_of_discounts = array_reduce( $result['line_items'], function( $sum, $item ) { |
|
| 79 | + $sum_of_discounts = array_reduce($result['line_items'], function($sum, $item) { |
|
| 80 | 80 | return $sum + $item->discount_amount; |
| 81 | 81 | } ); |
| 82 | 82 | $shipping_amount = $result['shipping_amount']; |
@@ -88,24 +88,24 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | public function test_non_us_shipping_zip_codes() { |
| 90 | 90 | // Update the store with the right post code. |
| 91 | - update_option( 'woocommerce_store_postcode', 1040 ); |
|
| 91 | + update_option('woocommerce_store_postcode', 1040); |
|
| 92 | 92 | |
| 93 | 93 | // Arrange: Create a couple of products to use. |
| 94 | 94 | $product = WC_Helper_Product::create_simple_product(); |
| 95 | - $product->set_regular_price( 19.19 ); |
|
| 95 | + $product->set_regular_price(19.19); |
|
| 96 | 96 | $product->save(); |
| 97 | 97 | |
| 98 | 98 | // Arrange: Set up an order with a non-US postcode. |
| 99 | 99 | $order = new WC_Order(); |
| 100 | - $order->set_shipping_postcode( '1050' ); |
|
| 101 | - $order->add_product( $product, 1 ); |
|
| 100 | + $order->set_shipping_postcode('1050'); |
|
| 101 | + $order->add_product($product, 1); |
|
| 102 | 102 | $order->save(); |
| 103 | 103 | $order->calculate_totals(); |
| 104 | 104 | |
| 105 | 105 | // Act: Call get_level3_data_from_order(). |
| 106 | 106 | $store_postcode = '1100'; |
| 107 | 107 | $gateway = new WC_Gateway_Stripe(); |
| 108 | - $result = $gateway->get_level3_data_from_order( $order ); |
|
| 108 | + $result = $gateway->get_level3_data_from_order($order); |
|
| 109 | 109 | |
| 110 | 110 | // Assert. |
| 111 | 111 | $this->assertEquals( |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | 'line_items' => array( |
| 116 | 116 | (object) array( |
| 117 | 117 | 'product_code' => (string) $product->get_id(), |
| 118 | - 'product_description' => substr( $product->get_name(), 0, 26 ), |
|
| 118 | + 'product_description' => substr($product->get_name(), 0, 26), |
|
| 119 | 119 | 'unit_cost' => 1919, |
| 120 | 120 | 'quantity' => 1, |
| 121 | 121 | 'tax_amount' => 0, |