diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 512cb692a24..e4d3b8fdcd2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,7 +6,7 @@ */ class WC_Unit_Tests_Bootstrap { - /** @var \WC_Unit_Tests_Bootstrap instance */ + /** @var WC_Unit_Tests_Bootstrap instance */ protected static $instance = null; /** @var string directory where wordpress-tests-lib is installed */ diff --git a/tests/framework/class-wc-payment-token-stub.php b/tests/framework/class-wc-payment-token-stub.php index 0d21c80eba3..4fd312e4be3 100644 --- a/tests/framework/class-wc-payment-token-stub.php +++ b/tests/framework/class-wc-payment-token-stub.php @@ -4,7 +4,7 @@ * * @since 2.6.0 */ -class WC_Payment_Token_Stub extends \WC_Payment_Token { +class WC_Payment_Token_Stub extends WC_Payment_Token { /** @protected string Token Type String */ protected $type = 'stub'; diff --git a/tests/framework/class-wc-unit-test-case.php b/tests/framework/class-wc-unit-test-case.php index beb0031c876..839038d0365 100644 --- a/tests/framework/class-wc-unit-test-case.php +++ b/tests/framework/class-wc-unit-test-case.php @@ -9,7 +9,7 @@ */ class WC_Unit_Test_Case extends WP_UnitTestCase { - /** @var \WC_Unit_Test_Factory instance */ + /** @var WC_Unit_Test_Factory instance */ protected $factory; /** diff --git a/tests/framework/class-wc-unit-test-factory.php b/tests/framework/class-wc-unit-test-factory.php index d4b72dc45ab..60d42a945ee 100644 --- a/tests/framework/class-wc-unit-test-factory.php +++ b/tests/framework/class-wc-unit-test-factory.php @@ -8,10 +8,10 @@ */ class WC_Unit_Test_Factory extends WP_UnitTest_Factory { - /** @var \WC_Unit_Test_Factory_For_Webhook */ + /** @var WC_Unit_Test_Factory_For_Webhook */ public $webhook; - /** @var \WC_Unit_Test_Factory_For_Webhook_Delivery */ + /** @var WC_Unit_Test_Factory_For_Webhook_Delivery */ public $webhook_delivery; /** diff --git a/tests/framework/factories/class-wc-unit-test-factory-for-webhook.php b/tests/framework/factories/class-wc-unit-test-factory-for-webhook.php index 56908f6496d..2dd09d562a9 100644 --- a/tests/framework/factories/class-wc-unit-test-factory-for-webhook.php +++ b/tests/framework/factories/class-wc-unit-test-factory-for-webhook.php @@ -61,7 +61,7 @@ class WC_Unit_Test_Factory_For_Webhook extends WP_UnitTest_Factory_For_Post { * @since 2.2 * @see WP_UnitTest_Factory_For_Post::get_object_by_id() * @param int $id webhook ID - * @return \WC_Webhook webhook instance + * @return WC_Webhook webhook instance */ public function get_object_by_id( $id ) { diff --git a/tests/unit-tests/account/functions.php b/tests/unit-tests/account/functions.php index ab095e15c99..be81a75824c 100644 --- a/tests/unit-tests/account/functions.php +++ b/tests/unit-tests/account/functions.php @@ -1,12 +1,10 @@ api->WC_API_Orders; $variation_id = $orders_api->get_variation_id( $product, array( 'size' => 'small' ) ); diff --git a/tests/unit-tests/api/webhooks.php b/tests/unit-tests/api/webhooks.php index d1e2ce1620d..6072da4e58b 100644 --- a/tests/unit-tests/api/webhooks.php +++ b/tests/unit-tests/api/webhooks.php @@ -1,18 +1,16 @@ assertNotWPError( $response ); $this->assertArrayHasKey( 'webhook', $response ); - $this->check_get_webhook_response( $response['webhook'], new \WC_Webhook( $response['webhook']['id'] ) ); + $this->check_get_webhook_response( $response['webhook'], new WC_Webhook( $response['webhook']['id'] ) ); } /** @@ -460,7 +458,7 @@ class Webhooks extends \WC_API_Unit_Test_Case { $this->assertNotWPError( $response ); $this->assertArrayHasKey( 'webhook', $response ); - $this->check_get_webhook_response( $response['webhook'], new \WC_Webhook( $response['webhook']['id'] ) ); + $this->check_get_webhook_response( $response['webhook'], new WC_Webhook( $response['webhook']['id'] ) ); } /** diff --git a/tests/unit-tests/cart/cart.php b/tests/unit-tests/cart/cart.php index 58894a75668..5f984886662 100644 --- a/tests/unit-tests/cart/cart.php +++ b/tests/unit-tests/cart/cart.php @@ -1,12 +1,10 @@ assertNotFalse( WC()->cart->add_to_cart( $product->id, 1 ) ); @@ -44,7 +42,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -52,7 +50,7 @@ class Cart extends \WC_Unit_Test_Case { */ public function test_add_to_cart_trashed() { // Create dummy product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); // Trash product wp_trash_post( $product->id ); @@ -67,7 +65,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -76,7 +74,7 @@ class Cart extends \WC_Unit_Test_Case { * @since 2.3 */ public function test_add_to_cart_variable() { - $product = \WC_Helper_Product::create_variation_product(); + $product = WC_Helper_Product::create_variation_product(); $variations = $product->get_available_variations(); $variation = array_shift( $variations ); @@ -99,7 +97,7 @@ class Cart extends \WC_Unit_Test_Case { */ public function test_add_to_cart_sold_individually() { // Create dummy product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); // Set sold_individually to yes $product->sold_individually = 'yes'; @@ -115,7 +113,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -126,7 +124,7 @@ class Cart extends \WC_Unit_Test_Case { public function test_find_product_in_cart() { // Create dummy product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); // Add product to cart WC()->cart->add_to_cart( $product->id, 1 ); @@ -141,7 +139,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } @@ -208,7 +206,7 @@ class Cart extends \WC_Unit_Test_Case { */ public function test_set_quantity() { // Create dummy product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); // Add 1 product to cart WC()->cart->add_to_cart( $product->id, 1 ); @@ -232,7 +230,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -243,7 +241,7 @@ class Cart extends \WC_Unit_Test_Case { public function test_check_cart_item_validity() { // Create dummy product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); // Add product to cart WC()->cart->add_to_cart( $product->id, 1 ); @@ -255,7 +253,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } @@ -267,7 +265,7 @@ class Cart extends \WC_Unit_Test_Case { public function test_get_total() { // Create dummy product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); // We need this to have the calculate_totals() method calculate totals if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { @@ -284,7 +282,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -298,7 +296,7 @@ class Cart extends \WC_Unit_Test_Case { update_option( 'woocommerce_calc_taxes', 'yes' ); // Create dummy product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); // We need this to have the calculate_totals() method calculate totals if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { @@ -321,7 +319,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); // Restore option update_option( 'woocommerce_calc_taxes', 'no' ); @@ -347,12 +345,12 @@ class Cart extends \WC_Unit_Test_Case { */ public function test_shipping_total() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_price', '10' ); update_post_meta( $product->id, '_regular_price', '10' ); // Create a flat rate method - \WC_Helper_Shipping::create_simple_flat_rate(); + WC_Helper_Shipping::create_simple_flat_rate(); // We need this to have the calculate_totals() method calculate totals if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { @@ -377,10 +375,10 @@ class Cart extends \WC_Unit_Test_Case { // Delete the flat rate method WC()->session->set( 'chosen_shipping_methods', array() ); - \WC_Helper_Shipping::delete_simple_flat_rate(); + WC_Helper_Shipping::delete_simple_flat_rate(); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -390,7 +388,7 @@ class Cart extends \WC_Unit_Test_Case { */ public function test_cart_fee() { // Create product - $product =\WC_Helper_Product::create_simple_product(); + $product =WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_price', '10' ); update_post_meta( $product->id, '_regular_price', '10' ); @@ -400,7 +398,7 @@ class Cart extends \WC_Unit_Test_Case { } // Add fee - \WC_Helper_Fee::add_cart_fee(); + WC_Helper_Fee::add_cart_fee(); // Add product to cart WC()->cart->add_to_cart( $product->id, 1 ); @@ -415,10 +413,10 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->empty_cart(); // Remove fee - \WC_Helper_Fee::remove_cart_fee(); + WC_Helper_Fee::remove_cart_fee(); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -427,7 +425,7 @@ class Cart extends \WC_Unit_Test_Case { public function test_get_coupons() { // Create coupon - $coupon = \WC_Helper_Coupon::create_coupon(); + $coupon = WC_Helper_Coupon::create_coupon(); // Add coupon WC()->cart->add_discount( $coupon->code ); @@ -441,7 +439,7 @@ class Cart extends \WC_Unit_Test_Case { WC()->cart->remove_coupons(); // Delete coupon - \WC_Helper_Coupon::delete_coupon( $coupon->id ); + WC_Helper_Coupon::delete_coupon( $coupon->id ); } diff --git a/tests/unit-tests/cart/functions.php b/tests/unit-tests/cart/functions.php index f4b8639b7c5..d140835d984 100644 --- a/tests/unit-tests/cart/functions.php +++ b/tests/unit-tests/cart/functions.php @@ -1,12 +1,10 @@ cart->add_to_cart( $product->id, 1 ); @@ -99,7 +97,7 @@ class Functions extends \WC_Unit_Test_Case { $this->assertEquals( 0, WC()->cart->get_cart_contents_count() ); // Delete the previously created product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -120,13 +118,13 @@ class Functions extends \WC_Unit_Test_Case { * @since 2.4 */ public function test_wc_cart_totals_subtotal_html() { - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); WC()->cart->add_to_cart( $product->id, 1 ); $this->expectOutputString( wc_price( $product->price ), wc_cart_totals_subtotal_html() ); - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -135,11 +133,11 @@ class Functions extends \WC_Unit_Test_Case { * @since 2.4 */ public function test_wc_cart_totals_coupon_label() { - $coupon = \WC_Helper_Coupon::create_coupon(); + $coupon = WC_Helper_Coupon::create_coupon(); $this->expectOutputString( apply_filters( 'woocommerce_cart_totals_coupon_label', 'Coupon: ' . $coupon->code ), wc_cart_totals_coupon_label( $coupon ) ); - \WC_Helper_Coupon::delete_coupon( $coupon->id ); + WC_Helper_Coupon::delete_coupon( $coupon->id ); } /** diff --git a/tests/unit-tests/coupon/coupon.php b/tests/unit-tests/coupon/coupon.php index 0f121085773..e2dd3205933 100644 --- a/tests/unit-tests/coupon/coupon.php +++ b/tests/unit-tests/coupon/coupon.php @@ -1,12 +1,10 @@ assertTrue( WC()->cart->add_discount( $coupon->code ) ); @@ -31,7 +29,7 @@ class Coupon extends \WC_Unit_Test_Case { WC()->cart->remove_coupons(); // Delete coupon - \WC_Helper_Coupon::delete_coupon( $coupon->id ); + WC_Helper_Coupon::delete_coupon( $coupon->id ); } /** @@ -42,7 +40,7 @@ class Coupon extends \WC_Unit_Test_Case { public function test_add_discount_duplicate() { // Create coupon - $coupon = \WC_Helper_Coupon::create_coupon(); + $coupon = WC_Helper_Coupon::create_coupon(); // Add coupon $this->assertTrue( WC()->cart->add_discount( $coupon->code ) ); @@ -63,7 +61,7 @@ class Coupon extends \WC_Unit_Test_Case { WC()->cart->remove_coupons(); // Delete coupon - \WC_Helper_Coupon::delete_coupon( $coupon->id ); + WC_Helper_Coupon::delete_coupon( $coupon->id ); } /** @@ -74,17 +72,17 @@ class Coupon extends \WC_Unit_Test_Case { public function test_fixed_cart_discount() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_price', '10' ); update_post_meta( $product->id, '_regular_price', '10' ); // Create coupon - $coupon = \WC_Helper_Coupon::create_coupon(); + $coupon = WC_Helper_Coupon::create_coupon(); update_post_meta( $coupon->id, 'discount_type', 'fixed_cart' ); update_post_meta( $coupon->id, 'coupon_amount', '5' ); // Create a flat rate method - \WC_Helper_Shipping::create_simple_flat_rate(); + WC_Helper_Shipping::create_simple_flat_rate(); // We need this to have the calculate_totals() method calculate totals if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { @@ -115,13 +113,13 @@ class Coupon extends \WC_Unit_Test_Case { // Delete the flat rate method WC()->session->set( 'chosen_shipping_methods', array() ); - \WC_Helper_Shipping::delete_simple_flat_rate(); + WC_Helper_Shipping::delete_simple_flat_rate(); // Delete coupon - \WC_Helper_Coupon::delete_coupon( $coupon->id ); + WC_Helper_Coupon::delete_coupon( $coupon->id ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -132,17 +130,17 @@ class Coupon extends \WC_Unit_Test_Case { public function test_percent_cart_discount() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_price', '10' ); update_post_meta( $product->id, '_regular_price', '10' ); // Create coupon - $coupon = \WC_Helper_Coupon::create_coupon(); + $coupon = WC_Helper_Coupon::create_coupon(); update_post_meta( $coupon->id, 'discount_type', 'percent' ); update_post_meta( $coupon->id, 'coupon_amount', '5' ); // Create a flat rate method - \WC_Helper_Shipping::create_simple_flat_rate(); + WC_Helper_Shipping::create_simple_flat_rate(); // We need this to have the calculate_totals() method calculate totals if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { @@ -173,13 +171,13 @@ class Coupon extends \WC_Unit_Test_Case { // Delete the flat rate method WC()->session->set( 'chosen_shipping_methods', array() ); - \WC_Helper_Shipping::delete_simple_flat_rate(); + WC_Helper_Shipping::delete_simple_flat_rate(); // Delete coupon - \WC_Helper_Coupon::delete_coupon( $coupon->id ); + WC_Helper_Coupon::delete_coupon( $coupon->id ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -190,17 +188,17 @@ class Coupon extends \WC_Unit_Test_Case { public function test_fixed_product_discount() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_price', '10' ); update_post_meta( $product->id, '_regular_price', '10' ); // Create coupon - $coupon = \WC_Helper_Coupon::create_coupon(); + $coupon = WC_Helper_Coupon::create_coupon(); update_post_meta( $coupon->id, 'discount_type', 'fixed_product' ); update_post_meta( $coupon->id, 'coupon_amount', '5' ); // Create a flat rate method - $10 - \WC_Helper_Shipping::create_simple_flat_rate(); + WC_Helper_Shipping::create_simple_flat_rate(); // We need this to have the calculate_totals() method calculate totals if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { @@ -208,7 +206,7 @@ class Coupon extends \WC_Unit_Test_Case { } // Add fee - $10 - \WC_Helper_Fee::add_cart_fee(); + WC_Helper_Fee::add_cart_fee(); // Add product to cart WC()->cart->add_to_cart( $product->id, 1 ); @@ -233,17 +231,17 @@ class Coupon extends \WC_Unit_Test_Case { WC()->cart->remove_coupons(); // Remove fee - \WC_Helper_Fee::remove_cart_fee(); + WC_Helper_Fee::remove_cart_fee(); // Delete the flat rate method WC()->session->set( 'chosen_shipping_methods', array() ); - \WC_Helper_Shipping::delete_simple_flat_rate(); + WC_Helper_Shipping::delete_simple_flat_rate(); // Delete coupon - \WC_Helper_Coupon::delete_coupon( $coupon->id ); + WC_Helper_Coupon::delete_coupon( $coupon->id ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -254,17 +252,17 @@ class Coupon extends \WC_Unit_Test_Case { public function test_percent_product_discount() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_price', '10' ); update_post_meta( $product->id, '_regular_price', '10' ); // Create coupon - $coupon = \WC_Helper_Coupon::create_coupon(); + $coupon = WC_Helper_Coupon::create_coupon(); update_post_meta( $coupon->id, 'discount_type', 'percent_product' ); update_post_meta( $coupon->id, 'coupon_amount', '5' ); // Create a flat rate method - \WC_Helper_Shipping::create_simple_flat_rate(); + WC_Helper_Shipping::create_simple_flat_rate(); // We need this to have the calculate_totals() method calculate totals if ( ! defined( 'WOOCOMMERCE_CHECKOUT' ) ) { @@ -272,7 +270,7 @@ class Coupon extends \WC_Unit_Test_Case { } // Add fee - \WC_Helper_Fee::add_cart_fee(); + WC_Helper_Fee::add_cart_fee(); // Add product to cart WC()->cart->add_to_cart( $product->id, 1 ); @@ -297,17 +295,17 @@ class Coupon extends \WC_Unit_Test_Case { WC()->cart->remove_coupons(); // Remove fee - \WC_Helper_Fee::remove_cart_fee(); + WC_Helper_Fee::remove_cart_fee(); // Delete the flat rate method WC()->session->set( 'chosen_shipping_methods', array() ); - \WC_Helper_Shipping::delete_simple_flat_rate(); + WC_Helper_Shipping::delete_simple_flat_rate(); // Delete coupon - \WC_Helper_Coupon::delete_coupon( $coupon->id ); + WC_Helper_Coupon::delete_coupon( $coupon->id ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } } diff --git a/tests/unit-tests/coupon/functions.php b/tests/unit-tests/coupon/functions.php index 6f821ce8097..5dd4f74358d 100644 --- a/tests/unit-tests/coupon/functions.php +++ b/tests/unit-tests/coupon/functions.php @@ -1,13 +1,11 @@ set_content( 'testing' ); $object->save(); return $object; @@ -21,7 +20,7 @@ class Meta extends \WC_Unit_Test_Case { * Create a test user we can add/test meta against. */ public function create_test_user() { - $object = new \WC_Mock_WC_data(); + $object = new WC_Mock_WC_data(); $object->set_meta_type( 'user' ); $object->set_object_id_field( 'user_id' ); $object->set_content( 'testing@woo.dev' ); @@ -101,7 +100,7 @@ class Meta extends \WC_Unit_Test_Case { ); } - $object = new \WC_Mock_WC_data(); + $object = new WC_Mock_WC_data(); $object->set_meta_data( $metadata ); $this->assertEquals( $metadata, $object->get_meta_data() ); @@ -206,7 +205,7 @@ class Meta extends \WC_Unit_Test_Case { * data before a save. */ function test_add_meta_data_overwrite_before_save() { - $object = new \WC_Mock_WC_data; + $object = new WC_Mock_WC_data; $object->add_meta_data( 'test_field_0', 'another field', true ); $object->add_meta_data( 'test_field_1', 'another field', true ); $object->add_meta_data( 'test_field_2', 'val1', true ); diff --git a/tests/unit-tests/customer/customer.php b/tests/unit-tests/customer/customer.php index 5d1fe2885dc..35ae9505767 100644 --- a/tests/unit-tests/customer/customer.php +++ b/tests/unit-tests/customer/customer.php @@ -1,66 +1,65 @@ get_taxable_address(); // Default is geolocation! // Get the original settings for the session and the WooCommerce options - $original_chosen_shipping_methods = \WC_Helper_Customer::get_chosen_shipping_methods(); - $original_tax_based_on = \WC_Helper_Customer::get_tax_based_on(); - $original_customer_details = \WC_Helper_Customer::get_customer_details(); + $original_chosen_shipping_methods = WC_Helper_Customer::get_chosen_shipping_methods(); + $original_tax_based_on = WC_Helper_Customer::get_tax_based_on(); + $original_customer_details = WC_Helper_Customer::get_customer_details(); // Create dummy product, and add the product to the cart. - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); WC()->cart->add_to_cart( $product->id, 1 ); // Customer is going with the Local Pickup option, and the store calculates tax based on the store location. - \WC_Helper_Customer::set_chosen_shipping_methods( array( 'local_pickup' ) ); - \WC_Helper_Customer::set_tax_based_on( 'base' ); + WC_Helper_Customer::set_chosen_shipping_methods( array( 'local_pickup' ) ); + WC_Helper_Customer::set_tax_based_on( 'base' ); $this->assertEquals( $customer->get_taxable_address(), $base_store_address ); // Customer is going with the Local Pickup option, and the store calculates tax based on the customer's billing address. - \WC_Helper_Customer::set_chosen_shipping_methods( array( 'local_pickup' ) ); - \WC_Helper_Customer::set_tax_based_on( 'billing' ); + WC_Helper_Customer::set_chosen_shipping_methods( array( 'local_pickup' ) ); + WC_Helper_Customer::set_tax_based_on( 'billing' ); $this->assertEquals( $customer->get_taxable_address(), $base_store_address ); // Customer is going with the Free Shipping option, and the store calculates tax based on the customer's billing address. - \WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) ); - \WC_Helper_Customer::set_tax_based_on( 'billing' ); + WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) ); + WC_Helper_Customer::set_tax_based_on( 'billing' ); $this->assertEquals( $customer->get_taxable_address(), $customer_address ); // Customer is going with the Free Shipping option, and the store calculates tax based on the store base location. - \WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) ); - \WC_Helper_Customer::set_tax_based_on( 'base' ); + WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) ); + WC_Helper_Customer::set_tax_based_on( 'base' ); $this->assertEquals( $customer->get_taxable_address(), $base_store_address ); //Now reset the settings back to the way they were before this test - \WC_Helper_Customer::set_chosen_shipping_methods( $original_chosen_shipping_methods ); - \WC_Helper_Customer::set_tax_based_on( $original_tax_based_on ); - \WC_Helper_Customer::set_customer_details( $original_customer_details ); + WC_Helper_Customer::set_chosen_shipping_methods( $original_chosen_shipping_methods ); + WC_Helper_Customer::set_tax_based_on( $original_tax_based_on ); + WC_Helper_Customer::set_customer_details( $original_customer_details ); // Clean up the cart WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -69,51 +68,51 @@ class Customer extends \WC_Unit_Test_Case { public function test_is_customer_outside_base() { // Get the original settings for the session and the WooCommerce options - $original_chosen_shipping_methods = \WC_Helper_Customer::get_chosen_shipping_methods(); - $original_tax_based_on = \WC_Helper_Customer::get_tax_based_on(); - $original_customer_details = \WC_Helper_Customer::get_customer_details(); + $original_chosen_shipping_methods = WC_Helper_Customer::get_chosen_shipping_methods(); + $original_tax_based_on = WC_Helper_Customer::get_tax_based_on(); + $original_customer_details = WC_Helper_Customer::get_customer_details(); - $customer = \WC_Helper_Customer::create_mock_customer(); + $customer = WC_Helper_Customer::create_mock_customer(); // Create dummy product, and add the product to the cart. - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); WC()->cart->add_to_cart( $product->id, 1 ); // Customer is going with the Local Pickup option, and the store calculates tax based on the store location. - \WC_Helper_Customer::set_chosen_shipping_methods( array( 'local_pickup' ) ); - \WC_Helper_Customer::set_tax_based_on( 'base' ); + WC_Helper_Customer::set_chosen_shipping_methods( array( 'local_pickup' ) ); + WC_Helper_Customer::set_tax_based_on( 'base' ); $this->assertEquals( $customer->is_customer_outside_base(), false ); // Customer is going with the Local Pickup option, and the store calculates tax based on the customer's billing address. - \WC_Helper_Customer::set_chosen_shipping_methods( array( 'local_pickup' ) ); - \WC_Helper_Customer::set_tax_based_on( 'billing' ); + WC_Helper_Customer::set_chosen_shipping_methods( array( 'local_pickup' ) ); + WC_Helper_Customer::set_tax_based_on( 'billing' ); $this->assertEquals( $customer->is_customer_outside_base(), false ); // Customer is going with the Free Shipping option, and the store calculates tax based on the customer's billing address. - \WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) ); - \WC_Helper_Customer::set_tax_based_on( 'billing' ); + WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) ); + WC_Helper_Customer::set_tax_based_on( 'billing' ); $this->assertEquals( $customer->is_customer_outside_base(), true ); // Customer is going with the Free Shipping option, and the store calculates tax based on the store base location. - \WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) ); - \WC_Helper_Customer::set_tax_based_on( 'base' ); + WC_Helper_Customer::set_chosen_shipping_methods( array( 'free_shipping' ) ); + WC_Helper_Customer::set_tax_based_on( 'base' ); $this->assertEquals( $customer->is_customer_outside_base(), false ); //Now reset the settings back to the way they were before this test - \WC_Helper_Customer::set_chosen_shipping_methods( $original_chosen_shipping_methods ); - \WC_Helper_Customer::set_tax_based_on( $original_tax_based_on ); - \WC_Helper_Customer::set_customer_details( $original_customer_details ); + WC_Helper_Customer::set_chosen_shipping_methods( $original_chosen_shipping_methods ); + WC_Helper_Customer::set_tax_based_on( $original_tax_based_on ); + WC_Helper_Customer::set_customer_details( $original_customer_details ); // Clean up the cart WC()->cart->empty_cart(); // Clean up product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } } diff --git a/tests/unit-tests/formatting/functions.php b/tests/unit-tests/formatting/functions.php index 85608b5f5f9..0c7e06cf49b 100644 --- a/tests/unit-tests/formatting/functions.php +++ b/tests/unit-tests/formatting/functions.php @@ -1,7 +1,5 @@ assertInstanceOf( 'WC_Order', $order ); @@ -130,10 +128,10 @@ class Functions extends \WC_Unit_Test_Case { * @since 2.6 */ public function test_wc_order_get_payment_tokens() { - $order = \WC_Helper_Order::create_order(); + $order = WC_Helper_Order::create_order(); $this->assertEmpty( $order->get_payment_tokens() ); - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); update_post_meta( $order->id, '_payment_tokens', array( $token->get_id() ) ); $this->assertCount( 1, $order->get_payment_tokens() ); @@ -146,10 +144,10 @@ class Functions extends \WC_Unit_Test_Case { * @since 2.6 */ public function test_wc_order_add_payment_token() { - $order = \WC_Helper_Order::create_order(); + $order = WC_Helper_Order::create_order(); $this->assertEmpty( $order->get_payment_tokens() ); - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $order->add_payment_token( $token ); $this->assertCount( 1, $order->get_payment_tokens() ); diff --git a/tests/unit-tests/payment-tokens/cc.php b/tests/unit-tests/payment-tokens/cc.php index 1e122f6db03..3a7f5a9d173 100644 --- a/tests/unit-tests/payment-tokens/cc.php +++ b/tests/unit-tests/payment-tokens/cc.php @@ -1,18 +1,17 @@ set_token( time() . ' ' . __FUNCTION__ ); $this->assertFalse( $token->validate() ); $token->set_last4( '1111' ); @@ -27,7 +26,7 @@ class Payment_Token_CC extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_payment_token_cc_validate_expiry_length() { - $token = new \WC_Payment_Token_CC(); + $token = new WC_Payment_Token_CC(); $token->set_token( time() . ' ' . __FUNCTION__ ); $this->assertFalse( $token->validate() ); @@ -51,7 +50,7 @@ class Payment_Token_CC extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_cc_card_type() { - $token = new \WC_Payment_Token_CC(); + $token = new WC_Payment_Token_CC(); $token->set_card_type( 'visa' ); $this->assertEquals( 'visa', $token->get_card_type() ); } @@ -61,7 +60,7 @@ class Payment_Token_CC extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_cc_expiry_year() { - $token = new \WC_Payment_Token_CC(); + $token = new WC_Payment_Token_CC(); $token->set_expiry_year( '2016' ); $this->assertEquals( '2016', $token->get_expiry_year() ); } @@ -71,7 +70,7 @@ class Payment_Token_CC extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_cc_expiry_month() { - $token = new \WC_Payment_Token_CC(); + $token = new WC_Payment_Token_CC(); $token->set_expiry_month( '08' ); $this->assertEquals( '08', $token->get_expiry_month() ); } @@ -81,7 +80,7 @@ class Payment_Token_CC extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_cc_last4() { - $token = new \WC_Payment_Token_CC(); + $token = new WC_Payment_Token_CC(); $token->set_last4( '1111' ); $this->assertEquals( '1111', $token->get_last4() ); } @@ -91,9 +90,9 @@ class Payment_Token_CC extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_cc_read_pulls_meta() { - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token_id = $token->get_id(); - $token_read = new \WC_Payment_Token_CC(); + $token_read = new WC_Payment_Token_CC(); $token_read->read( $token_id ); $this->assertEquals( '1234', $token_read->get_last4() ); } diff --git a/tests/unit-tests/payment-tokens/echeck.php b/tests/unit-tests/payment-tokens/echeck.php index a1f7721615b..7cd9142d32e 100644 --- a/tests/unit-tests/payment-tokens/echeck.php +++ b/tests/unit-tests/payment-tokens/echeck.php @@ -1,18 +1,17 @@ set_token( time() . ' ' . __FUNCTION__ ); $this->assertFalse( $token->validate() ); $token->set_last4( '1111' ); @@ -24,7 +23,7 @@ class Payment_Token_eCheck extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_echeck_last4() { - $token = new \WC_Payment_Token_eCheck(); + $token = new WC_Payment_Token_eCheck(); $token->set_last4( '1111' ); $this->assertEquals( '1111', $token->get_last4() ); } @@ -34,10 +33,10 @@ class Payment_Token_eCheck extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_echeck_read_pulls_meta() { - $token = \WC_Helper_Payment_Token::create_eCheck_token(); + $token = WC_Helper_Payment_Token::create_eCheck_token(); $token_id = $token->get_id(); - $token_read = new \WC_Payment_Token_eCheck(); + $token_read = new WC_Payment_Token_eCheck(); $token_read->read( $token_id ); $this->assertEquals( '1234', $token_read->get_last4() ); diff --git a/tests/unit-tests/payment-tokens/payment-token.php b/tests/unit-tests/payment-tokens/payment-token.php index 6feeaa19371..0d16fdc9e21 100644 --- a/tests/unit-tests/payment-tokens/payment-token.php +++ b/tests/unit-tests/payment-tokens/payment-token.php @@ -1,18 +1,17 @@ assertEquals( 'stub', $token->get_type() ); } @@ -22,7 +21,7 @@ class Payment_Token extends \WC_Unit_Test_Case { */ public function test_wc_payment_token_token() { $raw_token = time() . ' ' . __FUNCTION__; - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $token->set_token( $raw_token ); $this->assertEquals( $raw_token, $token->get_token() ); } @@ -32,7 +31,7 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_user_id() { - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $token->set_user_id( 1 ); $this->assertEquals( 1, $token->get_user_id() ); } @@ -42,7 +41,7 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_get_user_id_defaults_to_0() { - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $this->assertEquals( 0, $token->get_user_id() ); } @@ -51,7 +50,7 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_gateway_id() { - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $token->set_gateway_id( 'paypal' ); $this->assertEquals( 'paypal', $token->get_gateway_id() ); } @@ -61,7 +60,7 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_is_default() { - $token = new \WC_Payment_Token_Stub( 1 ); + $token = new WC_Payment_Token_Stub( 1 ); $token->set_default( true ); $this->assertTrue( $token->is_default() ); $token->set_default( false ); @@ -75,7 +74,7 @@ class Payment_Token extends \WC_Unit_Test_Case { */ public function test_wc_payment_token_get_data() { $raw_token = time() . ' ' . __FUNCTION__; - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $token->set_token( $raw_token ); $token->set_gateway_id( 'paypal' ); $token->set_extra( 'woocommerce' ); @@ -94,11 +93,11 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_validation() { - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $token->set_token( time() . ' ' . __FUNCTION__ ); $this->assertTrue( $token->validate() ); - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $this->assertFalse( $token->validate() ); } @@ -107,10 +106,10 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_read() { - $token = \WC_Helper_Payment_Token::create_stub_token( __FUNCTION__ ); + $token = WC_Helper_Payment_Token::create_stub_token( __FUNCTION__ ); $token_id = $token->get_id(); - $token_read = new \WC_Payment_Token_Stub(); + $token_read = new WC_Payment_Token_Stub(); $token_read->read( $token_id ); $this->assertEquals( $token->get_token(), $token_read->get_token() ); @@ -122,7 +121,7 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_update() { - $token = \WC_Helper_Payment_Token::create_stub_token( __FUNCTION__ ); + $token = WC_Helper_Payment_Token::create_stub_token( __FUNCTION__ ); $this->assertEquals( __FUNCTION__, $token->get_extra() ); $token->set_extra( ':)' ); $token->update(); @@ -134,7 +133,7 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_create() { - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $token->set_extra( __FUNCTION__ ); $token->set_token( time() ); $token->create(); @@ -148,10 +147,10 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_delete() { - $token = \WC_Helper_Payment_Token::create_stub_token( __FUNCTION__ ); + $token = WC_Helper_Payment_Token::create_stub_token( __FUNCTION__ ); $token_id = $token->get_id(); $token->delete(); - $get_token = \WC_Payment_Tokens::get( $token_id ); + $get_token = WC_Payment_Tokens::get( $token_id ); $this->assertNull( $get_token ); } @@ -160,7 +159,7 @@ class Payment_Token extends \WC_Unit_Test_Case { * @since 2.6.0 */ public function test_wc_payment_token_last4_doesnt_work() { - $token = new \WC_Payment_Token_Stub(); + $token = new WC_Payment_Token_Stub(); $this->assertFalse( is_callable( $token, 'get_last4' ) ); } diff --git a/tests/unit-tests/payment-tokens/payment-tokens.php b/tests/unit-tests/payment-tokens/payment-tokens.php index e6ee877c8ad..563512730ca 100644 --- a/tests/unit-tests/payment-tokens/payment-tokens.php +++ b/tests/unit-tests/payment-tokens/payment-tokens.php @@ -1,11 +1,10 @@ assertEmpty( \WC_Payment_Tokens::get_order_tokens( $order->id ) ); + $order = WC_Helper_Order::create_order(); + $this->assertEmpty( WC_Payment_Tokens::get_order_tokens( $order->id ) ); - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); update_post_meta( $order->id, '_payment_tokens', array( $token->get_id() ) ); - $this->assertCount( 1, \WC_Payment_Tokens::get_order_tokens( $order->id ) ); + $this->assertCount( 1, WC_Payment_Tokens::get_order_tokens( $order->id ) ); } @@ -33,17 +32,17 @@ class Payment_Tokens extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_payment_tokens_get_customer_tokens_no_gateway() { - $this->assertEmpty( \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); + $this->assertEmpty( WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token->set_user_id( $this->user_id ); $token->save(); - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token->set_user_id( $this->user_id ); $token->save(); - $this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); + $this->assertCount( 2, WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); } /** @@ -51,22 +50,22 @@ class Payment_Tokens extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_payment_tokens_get_customer_tokens_with_gateway() { - $this->assertEmpty( \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); + $this->assertEmpty( WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token->set_user_id( $this->user_id ); $token->set_gateway_id( 'simplify_commerce' ); $token->save(); - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token->set_user_id( $this->user_id ); $token->set_gateway_id( 'paypal' ); $token->save(); - $this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); - $this->assertCount( 1, \WC_Payment_Tokens::get_customer_tokens( $this->user_id, 'simplify_commerce' ) ); + $this->assertCount( 2, WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); + $this->assertCount( 1, WC_Payment_Tokens::get_customer_tokens( $this->user_id, 'simplify_commerce' ) ); - foreach ( \WC_Payment_Tokens::get_customer_tokens( $this->user_id, 'simplify_commerce' ) as $simplify_token ) { + foreach ( WC_Payment_Tokens::get_customer_tokens( $this->user_id, 'simplify_commerce' ) as $simplify_token ) { $this->assertEquals( 'simplify_commerce', $simplify_token->get_gateway_id() ); } } @@ -76,20 +75,20 @@ class Payment_Tokens extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_get_customer_default_token() { - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token->set_user_id( $this->user_id ); $token->set_gateway_id( 'simplify_commerce' ); $token->save(); - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token->set_user_id( $this->user_id ); $token->set_default( true ); $token->set_gateway_id( 'paypal' ); $token->save(); - $this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); + $this->assertCount( 2, WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); - $default_token = \WC_Payment_Tokens::get_customer_default_token( $this->user_id ); + $default_token = WC_Payment_Tokens::get_customer_default_token( $this->user_id ); $this->assertEquals( 'paypal', $default_token->get_gateway_id() ); } @@ -101,17 +100,17 @@ class Payment_Tokens extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_get_customer_default_token_returns_first_created_when_no_default_token_set() { - $token = \WC_Helper_Payment_Token::create_cc_token( $this->user_id ); + $token = WC_Helper_Payment_Token::create_cc_token( $this->user_id ); $token->set_gateway_id( 'simplify_commerce' ); $token->save(); - $token = \WC_Helper_Payment_Token::create_cc_token( $this->user_id ); + $token = WC_Helper_Payment_Token::create_cc_token( $this->user_id ); $token->set_gateway_id( 'paypal' ); $token->save(); - $this->assertCount( 2, \WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); + $this->assertCount( 2, WC_Payment_Tokens::get_customer_tokens( $this->user_id ) ); - $default_token = \WC_Payment_Tokens::get_customer_default_token( $this->user_id ); + $default_token = WC_Payment_Tokens::get_customer_default_token( $this->user_id ); $this->assertEquals( 'simplify_commerce', $default_token->get_gateway_id() ); } @@ -120,9 +119,9 @@ class Payment_Tokens extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_payment_tokens_get() { - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token_id = $token->get_id(); - $get_token = \WC_Payment_Tokens::get( $token_id ); + $get_token = WC_Payment_Tokens::get( $token_id ); $this->assertEquals( $token->get_token(), $get_token->get_token() ); } @@ -131,12 +130,12 @@ class Payment_Tokens extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_payment_tokens_delete() { - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token_id = $token->get_id(); - \WC_Payment_Tokens::delete( $token_id ); + WC_Payment_Tokens::delete( $token_id ); - $get_token = \WC_Payment_Tokens::get( $token_id ); + $get_token = WC_Payment_Tokens::get( $token_id ); $this->assertNull( $get_token ); } @@ -145,9 +144,9 @@ class Payment_Tokens extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_payment_tokens_get_type_by_id() { - $token = \WC_Helper_Payment_Token::create_cc_token(); + $token = WC_Helper_Payment_Token::create_cc_token(); $token_id = $token->get_id(); - $this->assertEquals( 'CC', \WC_Payment_Tokens::get_token_type_by_id( $token_id ) ); + $this->assertEquals( 'CC', WC_Payment_Tokens::get_token_type_by_id( $token_id ) ); } /** @@ -155,24 +154,24 @@ class Payment_Tokens extends \WC_Unit_Test_Case { * @since 2.6.0 */ function test_wc_payment_tokens_set_users_default() { - $token = \WC_Helper_Payment_Token::create_cc_token( $this->user_id ); + $token = WC_Helper_Payment_Token::create_cc_token( $this->user_id ); $token_id = $token->get_id(); $token->save(); - $token2 = \WC_Helper_Payment_Token::create_cc_token( $this->user_id ); + $token2 = WC_Helper_Payment_Token::create_cc_token( $this->user_id ); $token_id_2 = $token2->get_id(); $token2->save(); $this->assertTrue( $token->is_default() ); // first created is default $this->assertFalse( $token2->is_default() ); - \WC_Payment_Tokens::set_users_default( $this->user_id, $token_id_2 ); + WC_Payment_Tokens::set_users_default( $this->user_id, $token_id_2 ); $token->read( $token_id ); $token2->read( $token_id_2 ); $this->assertFalse( $token->is_default() ); $this->assertTrue( $token2->is_default() ); - \WC_Payment_Tokens::set_users_default( $this->user_id, $token_id ); + WC_Payment_Tokens::set_users_default( $this->user_id, $token_id ); $token->read( $token_id ); $token2->read( $token_id_2 ); $this->assertTrue( $token->is_default() ); diff --git a/tests/unit-tests/product/functions.php b/tests/unit-tests/product/functions.php index 0adda7d313c..7ea15a0d371 100644 --- a/tests/unit-tests/product/functions.php +++ b/tests/unit-tests/product/functions.php @@ -1,13 +1,11 @@ id ); $this->assertEquals( $product->id, $product_copy->id ); // Delete Product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -34,7 +32,7 @@ class Functions extends \WC_Unit_Test_Case { */ public function test_wc_update_product_stock() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_manage_stock', 'yes' ); @@ -42,7 +40,7 @@ class Functions extends \WC_Unit_Test_Case { $this->assertEquals( 5, $product->stock ); // Delete Product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -52,7 +50,7 @@ class Functions extends \WC_Unit_Test_Case { */ public function test_wc_delete_product_transients() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_regular_price', wc_format_decimal( 10 ) ); update_post_meta( $product->id, '_price', wc_format_decimal( 5 ) ); @@ -67,7 +65,7 @@ class Functions extends \WC_Unit_Test_Case { $this->assertFalse( get_transient( 'wc_products_onsale' ) ); $this->assertFalse( get_transient( 'wc_featured_products' ) ); - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -81,7 +79,7 @@ class Functions extends \WC_Unit_Test_Case { delete_transient( 'wc_products_onsale' ); // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_regular_price', wc_format_decimal( 10 ) ); update_post_meta( $product->id, '_price', wc_format_decimal( 5 ) ); @@ -90,7 +88,7 @@ class Functions extends \WC_Unit_Test_Case { $this->assertEquals( array( $product->id ), wc_get_product_ids_on_sale() ); // Delete Product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -104,14 +102,14 @@ class Functions extends \WC_Unit_Test_Case { delete_transient( 'wc_featured_products' ); // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); update_post_meta( $product->id, '_featured', 'yes' ); $this->assertEquals( array( $product->id ), wc_get_featured_product_ids() ); // Delete Product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -157,18 +155,18 @@ class Functions extends \WC_Unit_Test_Case { * @since 2.3 */ public function test_wc_product_has_unique_sku() { - $product_1 = \WC_Helper_Product::create_simple_product(); + $product_1 = WC_Helper_Product::create_simple_product(); $this->assertEquals( true, wc_product_has_unique_sku( $product_1->id, $product_1->sku ) ); - $product_2 = \WC_Helper_Product::create_simple_product(); + $product_2 = WC_Helper_Product::create_simple_product(); $this->assertEquals( false, wc_product_has_unique_sku( $product_2->id, $product_2->sku ) ); - \WC_Helper_Product::delete_product( $product_1->id ); + WC_Helper_Product::delete_product( $product_1->id ); $this->assertEquals( true, wc_product_has_unique_sku( $product_2->id, $product_2->sku ) ); - \WC_Helper_Product::delete_product( $product_2->id ); + WC_Helper_Product::delete_product( $product_2->id ); } /** @@ -178,11 +176,11 @@ class Functions extends \WC_Unit_Test_Case { */ public function test_wc_get_product_id_by_sku() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEquals( $product->id, wc_get_product_id_by_sku( $product->sku ) ); // Delete Product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } } diff --git a/tests/unit-tests/product/product-simple.php b/tests/unit-tests/product/product-simple.php index d34ede911f3..fb6dee675fb 100644 --- a/tests/unit-tests/product/product-simple.php +++ b/tests/unit-tests/product/product-simple.php @@ -1,13 +1,11 @@ assertEquals( __( 'Add to cart', 'woocommerce' ), $product->add_to_cart_text() ); @@ -24,7 +22,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertEquals( __( 'Read More', 'woocommerce' ), $product->add_to_cart_text() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -34,12 +32,12 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_single_add_to_cart_text() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEquals( __( 'Add to cart', 'woocommerce' ), $product->single_add_to_cart_text() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -49,12 +47,12 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_get_title() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEquals( 'Dummy Product', $product->get_title() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -64,12 +62,12 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_get_permalink() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEquals( get_permalink( $product->id ), $product->get_permalink() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -79,12 +77,12 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_get_sku() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEquals( $product->sku, $product->get_sku() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -94,7 +92,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_get_stock_quantity() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEmpty( $product->get_stock_quantity() ); @@ -103,7 +101,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertEquals( 0, $product->get_stock_quantity() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -113,7 +111,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_get_total_stock() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEmpty( $product->get_total_stock() ); @@ -121,7 +119,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertEquals( 0, $product->get_total_stock() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -131,7 +129,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_set_stock() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $product->manage_stock = 'yes'; $this->assertEquals( 5, $product->set_stock( 5 ) ); @@ -139,7 +137,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertEquals( 5, $product->set_stock( 3, 'add' ) ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -149,14 +147,14 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_reduce_stock() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $product->manage_stock = 'yes'; $product->set_stock( 5 ); $this->assertEquals( 2, $product->reduce_stock( 3 ) ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -166,14 +164,14 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_increase_stock() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $product->manage_stock = 'yes'; $product->set_stock( 5 ); $this->assertEquals( 8, $product->increase_stock( 3 ) ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -183,7 +181,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_is_type() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertTrue( $product->is_type( 'simple' ) ); $this->assertFalse( $product->is_type( 'grouped' ) ); @@ -191,7 +189,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertFalse( $product->is_type( 'external' ) ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -201,7 +199,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_is_downloadable() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEmpty( $product->is_downloadable() ); @@ -212,7 +210,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertFalse( $product->is_downloadable() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -222,7 +220,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_is_virtual() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $this->assertEmpty( $product->is_virtual() ); @@ -233,7 +231,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertFalse( $product->is_virtual() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -243,7 +241,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_needs_shipping() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $product->virtual = 'yes'; $this->assertFalse( $product->needs_shipping() ); @@ -252,7 +250,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertTrue( $product->needs_shipping() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -262,7 +260,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_is_sold_individually() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $product->sold_individually = 'yes'; $this->assertTrue( $product->is_sold_individually() ); @@ -271,7 +269,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertFalse( $product->is_sold_individually() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -281,7 +279,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_backorders_allowed() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $product->backorders = 'yes'; $this->assertTrue( $product->backorders_allowed() ); @@ -293,7 +291,7 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertFalse( $product->backorders_allowed() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } /** @@ -303,7 +301,7 @@ class Product_Simple extends \WC_Unit_Test_Case { */ public function test_backorders_require_notification() { // Create product - $product = \WC_Helper_Product::create_simple_product(); + $product = WC_Helper_Product::create_simple_product(); $product->backorders = 'notify'; $product->manage_stock = 'yes'; @@ -320,6 +318,6 @@ class Product_Simple extends \WC_Unit_Test_Case { $this->assertFalse( $product->backorders_require_notification() ); // Delete product - \WC_Helper_Product::delete_product( $product->id ); + WC_Helper_Product::delete_product( $product->id ); } } diff --git a/tests/unit-tests/shipping-zones/shipping-zone.php b/tests/unit-tests/shipping-zones/shipping-zone.php index 6ceb385a17f..e1d9261323d 100644 --- a/tests/unit-tests/shipping-zones/shipping-zone.php +++ b/tests/unit-tests/shipping-zones/shipping-zone.php @@ -1,28 +1,27 @@ get_data(); // Assert $this->assertTrue( \is_array( $data ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -30,16 +29,16 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_get_zone_id() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert $this->assertEquals( $zone->get_zone_id(), 1 ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -47,16 +46,16 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_get_zone_name() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert $this->assertEquals( $zone->get_zone_name(), 'Local' ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -64,16 +63,16 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_get_zone_order() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert $this->assertEquals( $zone->get_zone_order(), 1 ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -81,17 +80,17 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_get_zone_locations() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert $this->assertTrue( \is_array( $zone->get_zone_locations() ) ); $this->assertTrue( 2 === \sizeof( $zone->get_zone_locations() ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -99,34 +98,34 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_get_formatted_location() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert $this->assertEquals( $zone->get_formatted_location(), 'United Kingdom (UK), CB*' ); // Test - $zone = \WC_Shipping_Zones::get_zone( 2 ); + $zone = WC_Shipping_Zones::get_zone( 2 ); // Assert $this->assertEquals( $zone->get_formatted_location(), 'Europe' ); // Test - $zone = \WC_Shipping_Zones::get_zone( 3 ); + $zone = WC_Shipping_Zones::get_zone( 3 ); // Assert $this->assertEquals( $zone->get_formatted_location(), 'California' ); // Test - $zone = \WC_Shipping_Zones::get_zone( 4 ); + $zone = WC_Shipping_Zones::get_zone( 4 ); // Assert $this->assertEquals( $zone->get_formatted_location(), 'United States (US)' ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -134,10 +133,10 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_get_shipping_methods() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->add_shipping_method( 'flat_rate' ); $methods = $zone->get_shipping_methods(); @@ -146,7 +145,7 @@ class Shipping_Zone extends \WC_Unit_Test_Case { $this->assertInstanceOf( 'WC_Shipping_Method', current( $methods ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -154,17 +153,17 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_set_zone_name() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->set_zone_name( 'I am a fish' ); // Assert $this->assertEquals( $zone->get_zone_name(), 'I am a fish' ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -172,17 +171,17 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_set_zone_order() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->set_zone_order( 100 ); // Assert $this->assertEquals( $zone->get_zone_order(), 100 ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -190,16 +189,16 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_is_valid_location_type() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert $this->assertEquals( $zone->get_zone_order(), 1 ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -207,10 +206,10 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_add_location() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert $this->assertTrue( $zone->is_valid_location_type( 'state' ) ); @@ -220,7 +219,7 @@ class Shipping_Zone extends \WC_Unit_Test_Case { $this->assertFalse( $zone->is_valid_location_type( 'poop' ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -228,10 +227,10 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_clear_locations() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->clear_locations(); // Assert @@ -239,7 +238,7 @@ class Shipping_Zone extends \WC_Unit_Test_Case { $this->assertTrue( empty( $zone_locations ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -247,10 +246,10 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_set_locations() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->clear_locations(); $zone->set_locations( array( array( @@ -276,7 +275,7 @@ class Shipping_Zone extends \WC_Unit_Test_Case { ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -284,19 +283,19 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_save() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->set_zone_name( 'I am a fish' ); $zone->save(); - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert $this->assertEquals( $zone->get_zone_name(), 'I am a fish' ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -304,10 +303,10 @@ class Shipping_Zone extends \WC_Unit_Test_Case { */ public function test_add_shipping_method() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); $zone->add_shipping_method( 'flat_rate' ); $zone->add_shipping_method( 'free_shipping' ); @@ -319,6 +318,6 @@ class Shipping_Zone extends \WC_Unit_Test_Case { $this->assertInstanceOf( 'WC_Shipping_Method', current( $methods ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } } diff --git a/tests/unit-tests/shipping-zones/shipping-zones.php b/tests/unit-tests/shipping-zones/shipping-zones.php index 2699d5bdae2..08667ac3bdf 100644 --- a/tests/unit-tests/shipping-zones/shipping-zones.php +++ b/tests/unit-tests/shipping-zones/shipping-zones.php @@ -1,28 +1,27 @@ assertTrue( \is_array( $zones ) ); $this->assertTrue( 4 === \sizeof( $zones ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -30,17 +29,17 @@ class Shipping_Zones extends \WC_Unit_Test_Case { */ public function test_get_zone() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone( 1 ); + $zone = WC_Shipping_Zones::get_zone( 1 ); // Assert that the first zone is our local zone $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); $this->assertEquals( $zone->get_zone_name(), 'Local' ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -48,10 +47,10 @@ class Shipping_Zones extends \WC_Unit_Test_Case { */ public function test_get_zone_by() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone_by( 'zone_id', 2 ); + $zone = WC_Shipping_Zones::get_zone_by( 'zone_id', 2 ); // Assert $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); @@ -60,14 +59,14 @@ class Shipping_Zones extends \WC_Unit_Test_Case { // Test instance_id $instance_id = $zone->add_shipping_method( 'flat_rate' ); - $zone = \WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id ); + $zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id ); // Assert $this->assertInstanceOf( 'WC_Shipping_Zone', $zone ); $this->assertEquals( $zone->get_zone_name(), 'Europe' ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -75,18 +74,18 @@ class Shipping_Zones extends \WC_Unit_Test_Case { */ public function test_get_shipping_method() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone = \WC_Shipping_Zones::get_zone_by( 'zone_id', 1 ); + $zone = WC_Shipping_Zones::get_zone_by( 'zone_id', 1 ); $instance_id = $zone->add_shipping_method( 'flat_rate' ); - $shipping_method = \WC_Shipping_Zones::get_shipping_method( $instance_id ); + $shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id ); // Assert $this->assertInstanceOf( 'WC_Shipping_Flat_Rate', $shipping_method ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -94,17 +93,17 @@ class Shipping_Zones extends \WC_Unit_Test_Case { */ public function test_delete_zone() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - \WC_Shipping_Zones::delete_zone( 1 ); - $zones = \WC_Shipping_Zones::get_zones(); + WC_Shipping_Zones::delete_zone( 1 ); + $zones = WC_Shipping_Zones::get_zones(); // Assert $this->assertTrue( 3 === \sizeof( $zones ) ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } /** @@ -112,31 +111,31 @@ class Shipping_Zones extends \WC_Unit_Test_Case { */ public function test_get_zone_matching_package() { // Setup - \WC_Helper_Shipping_Zones::create_mock_zones(); + WC_Helper_Shipping_Zones::create_mock_zones(); // Test - $zone1 = \WC_Shipping_Zones::get_zone_matching_package( array( + $zone1 = WC_Shipping_Zones::get_zone_matching_package( array( 'destination' => array( 'country' => 'GB', 'state' => 'Cambs', 'postcode' => 'CB23 1GG', ) ) ); - $zone2 = \WC_Shipping_Zones::get_zone_matching_package( array( + $zone2 = WC_Shipping_Zones::get_zone_matching_package( array( 'destination' => array( 'country' => 'GB', 'state' => 'Cambs', 'postcode' => 'PE12 1BG', ) ) ); - $zone3 = \WC_Shipping_Zones::get_zone_matching_package( array( + $zone3 = WC_Shipping_Zones::get_zone_matching_package( array( 'destination' => array( 'country' => 'US', 'state' => 'CA', 'postcode' => '90210', ) ) ); - $zone4 = \WC_Shipping_Zones::get_zone_matching_package( array( + $zone4 = WC_Shipping_Zones::get_zone_matching_package( array( 'destination' => array( 'country' => 'US', 'state' => 'AL', @@ -151,6 +150,6 @@ class Shipping_Zones extends \WC_Unit_Test_Case { $this->assertEquals( 'US', $zone4->get_zone_name() ); // Clean - \WC_Helper_Shipping_Zones::remove_mock_zones(); + WC_Helper_Shipping_Zones::remove_mock_zones(); } } diff --git a/tests/unit-tests/tax/tax.php b/tests/unit-tests/tax/tax.php index bf6f033f89a..56359f29cda 100644 --- a/tests/unit-tests/tax/tax.php +++ b/tests/unit-tests/tax/tax.php @@ -1,11 +1,10 @@ query( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rates" ); $wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations" ); - $customer_location = \WC_Tax::get_tax_location(); + $customer_location = WC_Tax::get_tax_location(); $tax_rate = array( 'tax_rate_country' => $customer_location[0], 'tax_rate_state' => '', @@ -29,13 +28,13 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $tax_rates = \WC_Tax::get_rates(); + $tax_rates = WC_Tax::get_rates(); $this->assertEquals( $tax_rates, array( $tax_rate_id => array( 'rate' => '20.0000', 'label' => 'VAT', 'shipping' => 'yes', 'compound' => 'no' ) ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -47,7 +46,7 @@ class Tax extends \WC_Unit_Test_Case { $wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rates" ); $wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations" ); - $customer_location = \WC_Tax::get_tax_location(); + $customer_location = WC_Tax::get_tax_location(); $tax_rate = array( 'tax_rate_country' => $customer_location[0], 'tax_rate_state' => '', @@ -60,13 +59,13 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $tax_rates = \WC_Tax::get_shipping_tax_rates(); + $tax_rates = WC_Tax::get_shipping_tax_rates(); $this->assertEquals( $tax_rates, array( $tax_rate_id => array( 'rate' => '20.0000', 'label' => 'VAT', 'shipping' => 'yes', 'compound' => 'no' ) ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -90,13 +89,13 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $tax_rates = \WC_Tax::get_base_tax_rates(); + $tax_rates = WC_Tax::get_base_tax_rates(); $this->assertEquals( $tax_rates, array( $tax_rate_id => array( 'rate' => '20.0000', 'label' => 'VAT', 'shipping' => 'yes', 'compound' => 'no' ) ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -120,9 +119,9 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $tax_rates = \WC_Tax::find_rates( array( + $tax_rates = WC_Tax::find_rates( array( 'country' => 'GB', 'state' => 'Cambs', 'postcode' => 'PE14 1XX', @@ -132,7 +131,7 @@ class Tax extends \WC_Unit_Test_Case { $this->assertEquals( $tax_rates, array( $tax_rate_id => array( 'rate' => '20.0000', 'label' => 'VAT', 'shipping' => 'yes', 'compound' => 'no' ) ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -156,9 +155,9 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $tax_rates = \WC_Tax::find_shipping_rates( array( + $tax_rates = WC_Tax::find_shipping_rates( array( 'country' => 'GB', 'state' => 'Cambs', 'postcode' => 'PE14 1XX', @@ -168,7 +167,7 @@ class Tax extends \WC_Unit_Test_Case { $this->assertEquals( $tax_rates, array( $tax_rate_id => array( 'rate' => '20.0000', 'label' => 'VAT', 'shipping' => 'yes', 'compound' => 'no' ) ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -192,9 +191,9 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $tax_rates = \WC_Tax::find_rates( array( + $tax_rates = WC_Tax::find_rates( array( 'country' => 'GB', 'state' => 'Cambs', 'postcode' => 'PE14 1XX', @@ -202,15 +201,15 @@ class Tax extends \WC_Unit_Test_Case { 'tax_class' => '' ) ); - $calced_tax = \WC_Tax::calc_tax( '9.99', $tax_rates, true, false ); + $calced_tax = WC_Tax::calc_tax( '9.99', $tax_rates, true, false ); $this->assertEquals( $calced_tax, array( $tax_rate_id => '1.665' ) ); - $calced_tax = \WC_Tax::calc_tax( '9.99', $tax_rates, false, false ); + $calced_tax = WC_Tax::calc_tax( '9.99', $tax_rates, false, false ); $this->assertEquals( $calced_tax, array( $tax_rate_id => '1.998' ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -249,10 +248,10 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_1_id = \WC_Tax::_insert_tax_rate( $tax_rate_1 ); - $tax_rate_2_id = \WC_Tax::_insert_tax_rate( $tax_rate_2 ); + $tax_rate_1_id = WC_Tax::_insert_tax_rate( $tax_rate_1 ); + $tax_rate_2_id = WC_Tax::_insert_tax_rate( $tax_rate_2 ); - $tax_rates = \WC_Tax::find_rates( array( + $tax_rates = WC_Tax::find_rates( array( 'country' => 'CA', 'state' => 'QC', 'postcode' => '12345', @@ -261,11 +260,11 @@ class Tax extends \WC_Unit_Test_Case { ) ); // prices exclusive of tax - $calced_tax = \WC_Tax::calc_tax( '100', $tax_rates, false, false ); + $calced_tax = WC_Tax::calc_tax( '100', $tax_rates, false, false ); $this->assertEquals( $calced_tax, array( $tax_rate_1_id => '5.0000', $tax_rate_2_id => '8.925' ) ); // prices inclusive of tax - $calced_tax = \WC_Tax::calc_tax( '100', $tax_rates, true, false ); + $calced_tax = WC_Tax::calc_tax( '100', $tax_rates, true, false ); /** * 100 is inclusive of all taxes. * @@ -275,8 +274,8 @@ class Tax extends \WC_Unit_Test_Case { */ $this->assertEquals( $calced_tax, array( $tax_rate_1_id => 4.3889, $tax_rate_2_id => 7.8341 ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_1_id ); - \WC_Tax::_delete_tax_rate( $tax_rate_2_id ); + WC_Tax::_delete_tax_rate( $tax_rate_1_id ); + WC_Tax::_delete_tax_rate( $tax_rate_2_id ); update_option( 'woocommerce_default_country', 'GB' ); update_option( 'woocommerce_default_state', '' ); } @@ -302,9 +301,9 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $tax_rates = \WC_Tax::find_rates( array( + $tax_rates = WC_Tax::find_rates( array( 'country' => 'GB', 'state' => 'Cambs', 'postcode' => 'PE14 1XX', @@ -312,11 +311,11 @@ class Tax extends \WC_Unit_Test_Case { 'tax_class' => '' ) ); - $calced_tax = \WC_Tax::calc_shipping_tax( '10', $tax_rates ); + $calced_tax = WC_Tax::calc_shipping_tax( '10', $tax_rates ); $this->assertEquals( $calced_tax, array( $tax_rate_id => '2' ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -337,11 +336,11 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $this->assertEquals(\WC_Tax::get_rate_label( $tax_rate_id ), 'VAT' ); + $this->assertEquals(WC_Tax::get_rate_label( $tax_rate_id ), 'VAT' ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -362,11 +361,11 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $this->assertEquals(\WC_Tax::get_rate_percent( $tax_rate_id ), '20%' ); + $this->assertEquals(WC_Tax::get_rate_percent( $tax_rate_id ), '20%' ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -387,11 +386,11 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $this->assertEquals(\WC_Tax::get_rate_code( $tax_rate_id ), 'GB-VAT-1' ); + $this->assertEquals(WC_Tax::get_rate_code( $tax_rate_id ), 'GB-VAT-1' ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -412,18 +411,18 @@ class Tax extends \WC_Unit_Test_Case { 'tax_rate_class' => '' ); - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - $this->assertTrue(\WC_Tax::is_compound( $tax_rate_id ) ); + $this->assertTrue(WC_Tax::is_compound( $tax_rate_id ) ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** * Test the rounding method. */ public function test_round() { - $this->assertEquals(\WC_Tax::round( '2.1234567' ), '2.1235' ); + $this->assertEquals(WC_Tax::round( '2.1234567' ), '2.1235' ); } /** @@ -435,14 +434,14 @@ class Tax extends \WC_Unit_Test_Case { '2' => '2', ); - $this->assertEquals(\WC_Tax::get_tax_total( $to_total ), '3.665' ); + $this->assertEquals(WC_Tax::get_tax_total( $to_total ), '3.665' ); } /** * Test getting the tax classes. */ public function test_get_tax_classes() { - $tax_classes = \WC_Tax::get_tax_classes(); + $tax_classes = WC_Tax::get_tax_classes(); $this->assertEquals( $tax_classes, array( 'Reduced Rate', 'Zero Rate' ) ); } @@ -467,7 +466,7 @@ class Tax extends \WC_Unit_Test_Case { ); // Run function - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); $this->assertGreaterThan( 0, $tax_rate_id ); @@ -483,7 +482,7 @@ class Tax extends \WC_Unit_Test_Case { $this->assertEquals( $new_row->tax_rate_order, '1' ); $this->assertEquals( $new_row->tax_rate_class, '' ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -506,7 +505,7 @@ class Tax extends \WC_Unit_Test_Case { ); // Run function - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); // Update a rate $tax_rate = array( @@ -514,11 +513,11 @@ class Tax extends \WC_Unit_Test_Case { ); // Run function - \WC_Tax::_update_tax_rate( $tax_rate_id, $tax_rate ); + WC_Tax::_update_tax_rate( $tax_rate_id, $tax_rate ); $this->assertNotFalse( $wpdb->last_result ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -541,14 +540,14 @@ class Tax extends \WC_Unit_Test_Case { ); // Run function - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); // Run function - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); $this->assertNotFalse( $wpdb->last_result ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -571,15 +570,15 @@ class Tax extends \WC_Unit_Test_Case { ); // Run function - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - \WC_Tax::_update_tax_rate_postcodes( $tax_rate_id, $to_save ); + WC_Tax::_update_tax_rate_postcodes( $tax_rate_id, $to_save ); $results = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d ORDER BY location_code ASC", $tax_rate_id ) ); $this->assertEquals( array( '12345', '90210', '90211', '90212', '90213', '90214', '90215' ), $results ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } /** @@ -602,14 +601,14 @@ class Tax extends \WC_Unit_Test_Case { ); // Run function - $tax_rate_id = \WC_Tax::_insert_tax_rate( $tax_rate ); + $tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate ); - \WC_Tax::_update_tax_rate_cities( $tax_rate_id, $to_save ); + WC_Tax::_update_tax_rate_cities( $tax_rate_id, $to_save ); $results = $wpdb->get_col( $wpdb->prepare( "SELECT location_code FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d ORDER BY location_code ASC", $tax_rate_id ) ); $this->assertEquals( array( 'SOMEWHERE', 'SOMEWHERE_ELSE' ), $results ); - \WC_Tax::_delete_tax_rate( $tax_rate_id ); + WC_Tax::_delete_tax_rate( $tax_rate_id ); } } diff --git a/tests/unit-tests/util/conditional-functions.php b/tests/unit-tests/util/conditional-functions.php index b76ed7e80f1..5da4d4142fd 100644 --- a/tests/unit-tests/util/conditional-functions.php +++ b/tests/unit-tests/util/conditional-functions.php @@ -1,12 +1,11 @@ version - 1 ); update_option( 'woocommerce_db_version', WC()->version ); - \WC_Install::check_version(); + WC_Install::check_version(); $this->assertTrue( did_action( 'woocommerce_updated' ) === 1 ); update_option( 'woocommerce_version', WC()->version ); update_option( 'woocommerce_db_version', WC()->version ); - \WC_Install::check_version(); + WC_Install::check_version(); $this->assertTrue( did_action( 'woocommerce_updated' ) === 1 ); } @@ -39,7 +37,7 @@ class WC_Tests_Install extends \WC_Unit_Test_Case { include( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/uninstall.php' ); - \WC_Install::install(); + WC_Install::install(); $this->assertTrue( get_option( 'woocommerce_version' ) === WC()->version ); } @@ -54,7 +52,7 @@ class WC_Tests_Install extends \WC_Unit_Test_Case { delete_option( 'woocommerce_checkout_page_id' ); delete_option( 'woocommerce_myaccount_page_id' ); - \WC_Install::create_pages(); + WC_Install::create_pages(); $this->assertGreaterThan( 0, get_option( 'woocommerce_shop_page_id' ) ); $this->assertGreaterThan( 0, get_option( 'woocommerce_cart_page_id' ) ); @@ -73,7 +71,7 @@ class WC_Tests_Install extends \WC_Unit_Test_Case { delete_option( 'woocommerce_checkout_page_id' ); delete_option( 'woocommerce_myaccount_page_id' ); - \WC_Install::create_pages(); + WC_Install::create_pages(); $this->assertGreaterThan( 0, get_option( 'woocommerce_shop_page_id' ) ); $this->assertGreaterThan( 0, get_option( 'woocommerce_cart_page_id' ) ); @@ -92,7 +90,7 @@ class WC_Tests_Install extends \WC_Unit_Test_Case { } include( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/uninstall.php' ); - \WC_Install::create_roles(); + WC_Install::create_roles(); $this->assertNotNull( get_role( 'customer' ) ); $this->assertNotNull( get_role( 'shop_manager' ) ); @@ -102,7 +100,7 @@ class WC_Tests_Install extends \WC_Unit_Test_Case { * Test - remove roles. */ public function test_remove_roles() { - \WC_Install::remove_roles(); + WC_Install::remove_roles(); $this->assertNull( get_role( 'customer' ) ); $this->assertNull( get_role( 'shop_manager' ) ); @@ -113,7 +111,7 @@ class WC_Tests_Install extends \WC_Unit_Test_Case { */ public function test_in_plugin_update_message() { ob_start(); - \WC_install::in_plugin_update_message( array( 'Version' => '2.0.0' ) ); + WC_install::in_plugin_update_message( array( 'Version' => '2.0.0' ) ); $result = ob_get_clean(); $this->assertTrue( is_string( $result ) ); } diff --git a/tests/unit-tests/util/log.php b/tests/unit-tests/util/log.php index cb81958443a..152ff08b952 100644 --- a/tests/unit-tests/util/log.php +++ b/tests/unit-tests/util/log.php @@ -1,12 +1,11 @@ add( 'unit-tests', 'this is a message' ); @@ -31,7 +30,7 @@ class Log extends \WC_Unit_Test_Case { * @since 2.4 */ public function test_clear() { - $log = new \WC_Logger(); + $log = new WC_Logger(); $log->add( 'unit-tests', 'this is a message' ); $log->clear( 'unit-tests' ); diff --git a/tests/unit-tests/util/main-class.php b/tests/unit-tests/util/main-class.php index 273052c03d7..e525c9b9ad4 100644 --- a/tests/unit-tests/util/main-class.php +++ b/tests/unit-tests/util/main-class.php @@ -1,12 +1,10 @@ assertInstanceOf( 'WC_Customer', $this->wc->customer ); } } - diff --git a/tests/unit-tests/util/notice-functions.php b/tests/unit-tests/util/notice-functions.php index fdaf4363a26..3b43e314d85 100644 --- a/tests/unit-tests/util/notice-functions.php +++ b/tests/unit-tests/util/notice-functions.php @@ -1,13 +1,11 @@ assertEquals( 'email@domain.com', \WC_Validation::is_email( 'email@domain.com' ) ); - $this->assertFalse( \WC_Validation::is_email( 'not a mail' ) ); - $this->assertFalse( \WC_Validation::is_email( 'http://test.com' ) ); + $this->assertEquals( 'email@domain.com', WC_Validation::is_email( 'email@domain.com' ) ); + $this->assertFalse( WC_Validation::is_email( 'not a mail' ) ); + $this->assertFalse( WC_Validation::is_email( 'http://test.com' ) ); } /** @@ -25,11 +24,11 @@ class Validation extends \WC_Unit_Test_Case { */ public function data_provider_test_is_phone() { return array( - array( true, \WC_Validation::is_phone( '+00 000 00 00 000' ) ), - array( true, \WC_Validation::is_phone( '+00-000-00-00-000' ) ), - array( true, \WC_Validation::is_phone( '(000) 00 00 000' ) ), - array( false, \WC_Validation::is_phone( '+00.000.00.00.000' ) ), - array( false, \WC_Validation::is_phone( '+00 aaa dd ee fff' ) ) + array( true, WC_Validation::is_phone( '+00 000 00 00 000' ) ), + array( true, WC_Validation::is_phone( '+00-000-00-00-000' ) ), + array( true, WC_Validation::is_phone( '(000) 00 00 000' ) ), + array( false, WC_Validation::is_phone( '+00.000.00.00.000' ) ), + array( false, WC_Validation::is_phone( '+00 aaa dd ee fff' ) ) ); } @@ -50,47 +49,47 @@ class Validation extends \WC_Unit_Test_Case { */ public function data_provider_test_is_postcode() { $generic = array( - array( true, \WC_Validation::is_postcode( '99999', 'IT' ) ), - array( true, \WC_Validation::is_postcode( '99999', 'IT' ) ), - array( true, \WC_Validation::is_postcode( '9999', 'IT' ) ), - array( true, \WC_Validation::is_postcode( 'ABC 999', 'IT' ) ), - array( true, \WC_Validation::is_postcode( 'ABC-999', 'IT' ) ), - array( false, \WC_Validation::is_postcode( 'ABC_123', 'IT' ) ) + array( true, WC_Validation::is_postcode( '99999', 'IT' ) ), + array( true, WC_Validation::is_postcode( '99999', 'IT' ) ), + array( true, WC_Validation::is_postcode( '9999', 'IT' ) ), + array( true, WC_Validation::is_postcode( 'ABC 999', 'IT' ) ), + array( true, WC_Validation::is_postcode( 'ABC-999', 'IT' ) ), + array( false, WC_Validation::is_postcode( 'ABC_123', 'IT' ) ) ); $gb = array( - array( true, \WC_Validation::is_postcode( 'A9 9AA', 'GB' ) ), - array( false, \WC_Validation::is_postcode( '99999', 'GB' ) ) + array( true, WC_Validation::is_postcode( 'A9 9AA', 'GB' ) ), + array( false, WC_Validation::is_postcode( '99999', 'GB' ) ) ); $us = array( - array( true, \WC_Validation::is_postcode( '99999', 'US' ) ), - array( true, \WC_Validation::is_postcode( '99999-9999', 'US' ) ), - array( false, \WC_Validation::is_postcode( 'ABCDE', 'US' ) ), - array( false, \WC_Validation::is_postcode( 'ABCDE-9999', 'US' ) ) + array( true, WC_Validation::is_postcode( '99999', 'US' ) ), + array( true, WC_Validation::is_postcode( '99999-9999', 'US' ) ), + array( false, WC_Validation::is_postcode( 'ABCDE', 'US' ) ), + array( false, WC_Validation::is_postcode( 'ABCDE-9999', 'US' ) ) ); $ch = array( - array( true, \WC_Validation::is_postcode( '9999', 'CH' ) ), - array( false, \WC_Validation::is_postcode( '99999', 'CH' ) ), - array( false, \WC_Validation::is_postcode( 'ABCDE', 'CH' ) ) + array( true, WC_Validation::is_postcode( '9999', 'CH' ) ), + array( false, WC_Validation::is_postcode( '99999', 'CH' ) ), + array( false, WC_Validation::is_postcode( 'ABCDE', 'CH' ) ) ); $br = array( - array( true, \WC_Validation::is_postcode( '99999-999', 'BR' ) ), - array( true, \WC_Validation::is_postcode( '99999999', 'BR' ) ), - array( false, \WC_Validation::is_postcode( '99999 999', 'BR' ) ), - array( false, \WC_Validation::is_postcode( '99999-ABC', 'BR' ) ) + array( true, WC_Validation::is_postcode( '99999-999', 'BR' ) ), + array( true, WC_Validation::is_postcode( '99999999', 'BR' ) ), + array( false, WC_Validation::is_postcode( '99999 999', 'BR' ) ), + array( false, WC_Validation::is_postcode( '99999-ABC', 'BR' ) ) ); - + $ca = array( - array( true, \WC_Validation::is_postcode( 'A9A 9A9', 'CA' ) ), - array( true, \WC_Validation::is_postcode( 'A9A9A9', 'CA' ) ), - array( true, \WC_Validation::is_postcode( 'a9a9a9', 'CA' ) ), - array( false, \WC_Validation::is_postcode( 'D0A 9A9', 'CA' ) ), - array( false, \WC_Validation::is_postcode( '99999', 'CA' ) ), - array( false, \WC_Validation::is_postcode( 'ABC999', 'CA' ) ), - array( false, \WC_Validation::is_postcode( '0A0A0A', 'CA' ) ) + array( true, WC_Validation::is_postcode( 'A9A 9A9', 'CA' ) ), + array( true, WC_Validation::is_postcode( 'A9A9A9', 'CA' ) ), + array( true, WC_Validation::is_postcode( 'a9a9a9', 'CA' ) ), + array( false, WC_Validation::is_postcode( 'D0A 9A9', 'CA' ) ), + array( false, WC_Validation::is_postcode( '99999', 'CA' ) ), + array( false, WC_Validation::is_postcode( 'ABC999', 'CA' ) ), + array( false, WC_Validation::is_postcode( '0A0A0A', 'CA' ) ) ); return array_merge( $generic, $gb, $us, $ch, $br, $ca ); @@ -113,17 +112,17 @@ class Validation extends \WC_Unit_Test_Case { */ public function data_provider_test_is_GB_postcode() { return array( - array( true, \WC_Validation::is_GB_postcode( 'AA9A 9AA' ) ), - array( true, \WC_Validation::is_GB_postcode( 'A9A 9AA' ) ), - array( true, \WC_Validation::is_GB_postcode( 'A9 9AA' ) ), - array( true, \WC_Validation::is_GB_postcode( 'A99 9AA' ) ), - array( true, \WC_Validation::is_GB_postcode( 'AA99 9AA' ) ), - array( true, \WC_Validation::is_GB_postcode( 'BFPO 801' ) ), - array( false, \WC_Validation::is_GB_postcode( '99999' ) ), - array( false, \WC_Validation::is_GB_postcode( '9999 999' ) ), - array( false, \WC_Validation::is_GB_postcode( '999 999' ) ), - array( false, \WC_Validation::is_GB_postcode( '99 999' ) ), - array( false, \WC_Validation::is_GB_postcode( '9A A9A' ) ) + array( true, WC_Validation::is_GB_postcode( 'AA9A 9AA' ) ), + array( true, WC_Validation::is_GB_postcode( 'A9A 9AA' ) ), + array( true, WC_Validation::is_GB_postcode( 'A9 9AA' ) ), + array( true, WC_Validation::is_GB_postcode( 'A99 9AA' ) ), + array( true, WC_Validation::is_GB_postcode( 'AA99 9AA' ) ), + array( true, WC_Validation::is_GB_postcode( 'BFPO 801' ) ), + array( false, WC_Validation::is_GB_postcode( '99999' ) ), + array( false, WC_Validation::is_GB_postcode( '9999 999' ) ), + array( false, WC_Validation::is_GB_postcode( '999 999' ) ), + array( false, WC_Validation::is_GB_postcode( '99 999' ) ), + array( false, WC_Validation::is_GB_postcode( '9A A9A' ) ) ); } @@ -144,12 +143,12 @@ class Validation extends \WC_Unit_Test_Case { */ public function data_provider_test_format_postcode() { return array( - array( '99999', \WC_Validation::format_postcode( '99999', 'IT' ) ), - array( '99999', \WC_Validation::format_postcode( ' 99999 ', 'IT' ) ), - array( '99999', \WC_Validation::format_postcode( '999 99', 'IT' ) ), - array( 'ABCDE', \WC_Validation::format_postcode( 'abcde', 'IT' ) ), - array( 'AB CDE', \WC_Validation::format_postcode( 'abcde', 'GB' ) ), - array( 'AB CDE', \WC_Validation::format_postcode( 'abcde', 'CA' ) ) + array( '99999', WC_Validation::format_postcode( '99999', 'IT' ) ), + array( '99999', WC_Validation::format_postcode( ' 99999 ', 'IT' ) ), + array( '99999', WC_Validation::format_postcode( '999 99', 'IT' ) ), + array( 'ABCDE', WC_Validation::format_postcode( 'abcde', 'IT' ) ), + array( 'AB CDE', WC_Validation::format_postcode( 'abcde', 'GB' ) ), + array( 'AB CDE', WC_Validation::format_postcode( 'abcde', 'CA' ) ) ); } @@ -169,7 +168,7 @@ class Validation extends \WC_Unit_Test_Case { * @since 2.4 */ public function test_format_phone() { - $this->assertEquals( '+00-000-00-00-000', \WC_Validation::format_phone( '+00.000.00.00.000' ) ); - $this->assertEquals( '+00 000 00 00 000', \WC_Validation::format_phone( '+00 000 00 00 000' ) ); + $this->assertEquals( '+00-000-00-00-000', WC_Validation::format_phone( '+00.000.00.00.000' ) ); + $this->assertEquals( '+00 000 00 00 000', WC_Validation::format_phone( '+00 000 00 00 000' ) ); } }