';
break;
diff --git a/templates/loop/pagination.php b/templates/loop/pagination.php
index e2188dc8368..cf394db03b2 100644
--- a/templates/loop/pagination.php
+++ b/templates/loop/pagination.php
@@ -38,7 +38,7 @@ if ( $wp_query->max_num_pages <= 1 ) {
'next_text' => '→',
'type' => 'list',
'end_size' => 3,
- 'mid_size' => 3
+ 'mid_size' => 3,
) ) );
?>
diff --git a/templates/myaccount/downloads.php b/templates/myaccount/downloads.php
index 7381b89ed6b..0b375a70c79 100644
--- a/templates/myaccount/downloads.php
+++ b/templates/myaccount/downloads.php
@@ -72,8 +72,8 @@ do_action( 'woocommerce_before_account_downloads', $has_downloads ); ?>
$actions = array(
'download' => array(
'url' => $download['download_url'],
- 'name' => __( 'Download', 'woocommerce' )
- )
+ 'name' => __( 'Download', 'woocommerce' ),
+ ),
);
if ( $actions = apply_filters( 'woocommerce_account_download_actions', $actions, $download ) ) {
diff --git a/templates/myaccount/my-address.php b/templates/myaccount/my-address.php
index b8b345f0401..b082813a506 100644
--- a/templates/myaccount/my-address.php
+++ b/templates/myaccount/my-address.php
@@ -25,11 +25,11 @@ $customer_id = get_current_user_id();
if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) {
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing Address', 'woocommerce' ),
- 'shipping' => __( 'Shipping Address', 'woocommerce' )
+ 'shipping' => __( 'Shipping Address', 'woocommerce' ),
), $customer_id );
} else {
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
- 'billing' => __( 'Billing Address', 'woocommerce' )
+ 'billing' => __( 'Billing Address', 'woocommerce' ),
), $customer_id );
}
@@ -61,7 +61,7 @@ $col = 1;
'city' => get_user_meta( $customer_id, $name . '_city', true ),
'state' => get_user_meta( $customer_id, $name . '_state', true ),
'postcode' => get_user_meta( $customer_id, $name . '_postcode', true ),
- 'country' => get_user_meta( $customer_id, $name . '_country', true )
+ 'country' => get_user_meta( $customer_id, $name . '_country', true ),
), $customer_id, $name );
$formatted_address = WC()->countries->get_formatted_address( $address );
diff --git a/templates/myaccount/my-orders.php b/templates/myaccount/my-orders.php
index 071b5723027..ce5c3ba86ee 100644
--- a/templates/myaccount/my-orders.php
+++ b/templates/myaccount/my-orders.php
@@ -22,7 +22,7 @@ $customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_q
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
- 'post_status' => array_keys( wc_get_order_statuses() )
+ 'post_status' => array_keys( wc_get_order_statuses() ),
) ) );
if ( $customer_orders ) : ?>
@@ -69,16 +69,16 @@ if ( $customer_orders ) : ?>
$actions = array(
'pay' => array(
'url' => $order->get_checkout_payment_url(),
- 'name' => __( 'Pay', 'woocommerce' )
+ 'name' => __( 'Pay', 'woocommerce' ),
),
'view' => array(
'url' => $order->get_view_order_url(),
- 'name' => __( 'View', 'woocommerce' )
+ 'name' => __( 'View', 'woocommerce' ),
),
'cancel' => array(
'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
- 'name' => __( 'Cancel', 'woocommerce' )
- )
+ 'name' => __( 'Cancel', 'woocommerce' ),
+ ),
);
if ( ! $order->needs_payment() ) {
diff --git a/templates/myaccount/orders.php b/templates/myaccount/orders.php
index 0ee143e8610..6bfc7dee172 100644
--- a/templates/myaccount/orders.php
+++ b/templates/myaccount/orders.php
@@ -65,16 +65,16 @@ do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
$actions = array(
'pay' => array(
'url' => $order->get_checkout_payment_url(),
- 'name' => __( 'Pay', 'woocommerce' )
+ 'name' => __( 'Pay', 'woocommerce' ),
),
'view' => array(
'url' => $order->get_view_order_url(),
- 'name' => __( 'View', 'woocommerce' )
+ 'name' => __( 'View', 'woocommerce' ),
),
'cancel' => array(
'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
- 'name' => __( 'Cancel', 'woocommerce' )
- )
+ 'name' => __( 'Cancel', 'woocommerce' ),
+ ),
);
if ( ! $order->needs_payment() ) {
diff --git a/templates/notices/error.php b/templates/notices/error.php
index c5bf82c2530..0322ae3bd87 100644
--- a/templates/notices/error.php
+++ b/templates/notices/error.php
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
-if ( ! $messages ){
+if ( ! $messages ) {
return;
}
diff --git a/templates/notices/notice.php b/templates/notices/notice.php
index 0bcc8695204..fe92bbe9b11 100644
--- a/templates/notices/notice.php
+++ b/templates/notices/notice.php
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
-if ( ! $messages ){
+if ( ! $messages ) {
return;
}
diff --git a/templates/notices/success.php b/templates/notices/success.php
index 5d0918280c7..c3940e511b0 100644
--- a/templates/notices/success.php
+++ b/templates/notices/success.php
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
-if ( ! $messages ){
+if ( ! $messages ) {
return;
}
diff --git a/templates/order/order-details.php b/templates/order/order-details.php
index fe6f38afaad..899b3b53132 100644
--- a/templates/order/order-details.php
+++ b/templates/order/order-details.php
@@ -35,7 +35,7 @@ $show_customer_details = is_user_logged_in() && $order->get_user_id() === get_cu
get_items() as $item_id => $item ) {
+ foreach ( $order->get_items() as $item_id => $item ) {
$product = apply_filters( 'woocommerce_order_item_product', $item->get_product(), $item );
wc_get_template( 'order/order-details-item.php', array(
@@ -67,5 +67,5 @@ $show_customer_details = is_user_logged_in() && $order->get_user_id() === get_cu
- $order ) ); ?>
+ $order ) ); ?>
diff --git a/templates/single-product-reviews.php b/templates/single-product-reviews.php
index b508f259a23..6bd2a13444e 100644
--- a/templates/single-product-reviews.php
+++ b/templates/single-product-reviews.php
@@ -79,7 +79,7 @@ if ( ! comments_open() ) {
),
'label_submit' => __( 'Submit', 'woocommerce' ),
'logged_in_as' => '',
- 'comment_field' => ''
+ 'comment_field' => '',
);
if ( $account_page_url = wc_get_page_permalink( 'myaccount' ) ) {
diff --git a/templates/single-product/add-to-cart/grouped.php b/templates/single-product/add-to-cart/grouped.php
index 8cb239c6ccc..c4c5b0db5c0 100644
--- a/templates/single-product/add-to-cart/grouped.php
+++ b/templates/single-product/add-to-cart/grouped.php
@@ -51,9 +51,9 @@ do_action( 'woocommerce_before_add_to_cart_form' ); ?>
$quantites_required = true;
woocommerce_quantity_input( array(
'input_name' => 'quantity[' . $product_id . ']',
- 'input_value' => ( isset( $_POST['quantity'][$product_id] ) ? wc_stock_amount( $_POST['quantity'][$product_id] ) : 0 ),
+ 'input_value' => ( isset( $_POST['quantity'][ $product_id ] ) ? wc_stock_amount( $_POST['quantity'][ $product_id ] ) : 0 ),
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 0, $product ),
- 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product )
+ 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product ),
) );
?>
diff --git a/templates/single-product/add-to-cart/simple.php b/templates/single-product/add-to-cart/simple.php
index 51a9795bf2a..7d03628e084 100644
--- a/templates/single-product/add-to-cart/simple.php
+++ b/templates/single-product/add-to-cart/simple.php
@@ -48,7 +48,7 @@ if ( ! $product->is_purchasable() ) {
woocommerce_quantity_input( array(
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ),
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product ),
- 'input_value' => ( isset( $_POST['quantity'] ) ? wc_stock_amount( $_POST['quantity'] ) : 1 )
+ 'input_value' => ( isset( $_POST['quantity'] ) ? wc_stock_amount( $_POST['quantity'] ) : 1 ),
) );
}
?>
diff --git a/templates/single-product/related.php b/templates/single-product/related.php
index 63c902925f6..330f6356030 100644
--- a/templates/single-product/related.php
+++ b/templates/single-product/related.php
@@ -37,7 +37,7 @@ $args = apply_filters( 'woocommerce_related_products_args', array(
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'post__in' => $related,
- 'post__not_in' => array( $product->id )
+ 'post__not_in' => array( $product->id ),
) );
$products = new WP_Query( $args );
diff --git a/templates/single-product/tabs/additional-information.php b/templates/single-product/tabs/additional-information.php
index ba2a9ea7a1a..218d8d809c4 100644
--- a/templates/single-product/tabs/additional-information.php
+++ b/templates/single-product/tabs/additional-information.php
@@ -26,7 +26,7 @@ $heading = esc_html( apply_filters( 'woocommerce_product_additional_information_
?>
-
+
diff --git a/templates/single-product/tabs/description.php b/templates/single-product/tabs/description.php
index 036f380757d..08bb56d31af 100644
--- a/templates/single-product/tabs/description.php
+++ b/templates/single-product/tabs/description.php
@@ -26,7 +26,7 @@ $heading = esc_html( apply_filters( 'woocommerce_product_description_heading', _
?>
-
+
diff --git a/templates/single-product/up-sells.php b/templates/single-product/up-sells.php
index 9464d5fc0d5..af09d978c05 100644
--- a/templates/single-product/up-sells.php
+++ b/templates/single-product/up-sells.php
@@ -34,7 +34,7 @@ $args = array(
'orderby' => $orderby,
'post__in' => $upsells,
'post__not_in' => array( $product->id ),
- 'meta_query' => WC()->query->get_meta_query()
+ 'meta_query' => WC()->query->get_meta_query(),
);
$products = new WP_Query( $args );
diff --git a/tests/bin/travis.sh b/tests/bin/travis.sh
index 974c7e7e3ee..fd65b242322 100644
--- a/tests/bin/travis.sh
+++ b/tests/bin/travis.sh
@@ -14,14 +14,16 @@ if [ $1 == 'before' ]; then
elif [ $1 == 'after' ]; then
- # no Xdebug and therefore no coverage in PHP 5.2
+ # no Xdebug and therefore no coverage in PHP 5.2 or 5.3
[ $TRAVIS_PHP_VERSION == '5.2' ] && exit;
+ [ $TRAVIS_PHP_VERSION == '5.3' ] && exit;
# send coverage data to coveralls
php vendor/bin/coveralls --verbose --exclude-no-stmt
# get scrutinizer ocular and run it
wget https://scrutinizer-ci.com/ocular.phar
- ocular.phar code-coverage:upload --format=php-clover ./tmp/clover.xml
+ chmod +x ocular.phar
+ php ocular.phar code-coverage:upload --format=php-clover ./tmp/clover.xml
fi
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index fe531a3c5cf..cefb49b467d 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -130,7 +130,6 @@ class WC_Unit_Tests_Bootstrap {
return self::$instance;
}
-
}
WC_Unit_Tests_Bootstrap::instance();
diff --git a/tests/framework/class-wc-api-unit-test-case.php b/tests/framework/class-wc-api-unit-test-case.php
index 7de6af421f3..dd71381a655 100644
--- a/tests/framework/class-wc-api-unit-test-case.php
+++ b/tests/framework/class-wc-api-unit-test-case.php
@@ -30,7 +30,7 @@ class WC_API_Unit_Test_Case extends WC_Unit_Test_Case {
$_SERVER['REQUEST_METHOD'] = null;
// mock the API server to prevent headers from being sent
- $this->mock_server = $this->getMock( 'WC_API_Server', array ('header' ), array( '/' ) );
+ $this->mock_server = $this->getMock( 'WC_API_Server', array( 'header' ), array( '/' ) );
WC()->api->register_resources( $this->mock_server );
}
@@ -75,5 +75,4 @@ class WC_API_Unit_Test_Case extends WC_Unit_Test_Case {
$user->get_role_caps();
$user->update_user_level_from_caps();
}
-
}
diff --git a/tests/framework/class-wc-mock-wc-data.php b/tests/framework/class-wc-mock-wc-data.php
index 16ad2d54ec2..4c87761eada 100644
--- a/tests/framework/class-wc-mock-wc-data.php
+++ b/tests/framework/class-wc-mock-wc-data.php
@@ -126,7 +126,7 @@ class WC_Mock_WC_Data extends WC_Data {
if ( 'user' === $this->_meta_type ) {
$content_id = wc_create_new_customer( $this->get_content(), 'username-' . time(), 'hunter2' );
} else {
- $content_id = wp_insert_post( array ( 'post_title' => $this->get_content() ) );
+ $content_id = wp_insert_post( array( 'post_title' => $this->get_content() ) );
}
if ( $content_id ) {
$this->_data['id'] = $content_id;
@@ -192,5 +192,4 @@ class WC_Mock_WC_Data extends WC_Data {
}
$this->save_meta_data();
}
-
}
diff --git a/tests/framework/class-wc-payment-token-stub.php b/tests/framework/class-wc-payment-token-stub.php
index 4fd312e4be3..669f7745d96 100644
--- a/tests/framework/class-wc-payment-token-stub.php
+++ b/tests/framework/class-wc-payment-token-stub.php
@@ -26,5 +26,4 @@ class WC_Payment_Token_Stub extends WC_Payment_Token {
public function set_extra( $extra ) {
$this->add_meta_data( 'extra', $extra, true );
}
-
}
diff --git a/tests/framework/class-wc-rest-unit-test-case.php b/tests/framework/class-wc-rest-unit-test-case.php
index 1ffde43bd18..b72f1f756a0 100644
--- a/tests/framework/class-wc-rest-unit-test-case.php
+++ b/tests/framework/class-wc-rest-unit-test-case.php
@@ -29,5 +29,4 @@
global $wp_rest_server;
$wp_rest_server = null;
}
-
}
diff --git a/tests/framework/class-wc-unit-test-case.php b/tests/framework/class-wc-unit-test-case.php
index 839038d0365..85048e4bb74 100644
--- a/tests/framework/class-wc-unit-test-case.php
+++ b/tests/framework/class-wc-unit-test-case.php
@@ -100,5 +100,4 @@ class WC_Unit_Test_Case extends WP_UnitTestCase {
parent::assertNotFalse( $condition, $message );
}
}
-
}
diff --git a/tests/framework/class-wc-unit-test-factory.php b/tests/framework/class-wc-unit-test-factory.php
index 60d42a945ee..3e483d1f36b 100644
--- a/tests/framework/class-wc-unit-test-factory.php
+++ b/tests/framework/class-wc-unit-test-factory.php
@@ -24,5 +24,4 @@ class WC_Unit_Test_Factory extends WP_UnitTest_Factory {
$this->webhook = new WC_Unit_Test_Factory_For_Webhook( $this );
$this->webhook_delivery = new WC_Unit_Test_Factory_For_Webhook_Delivery( $this );
}
-
}
diff --git a/tests/framework/factories/class-wc-unit-test-factory-for-webhook-delivery.php b/tests/framework/factories/class-wc-unit-test-factory-for-webhook-delivery.php
index e93839718d9..8e9524d538e 100644
--- a/tests/framework/factories/class-wc-unit-test-factory-for-webhook-delivery.php
+++ b/tests/framework/factories/class-wc-unit-test-factory-for-webhook-delivery.php
@@ -58,5 +58,4 @@ class WC_Unit_Test_Factory_For_Webhook_Delivery extends WP_UnitTest_Factory_For_
return $id;
}
-
}
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 2dd09d562a9..c26799dbe35 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
@@ -67,5 +67,4 @@ class WC_Unit_Test_Factory_For_Webhook extends WP_UnitTest_Factory_For_Post {
return new WC_Webhook( $id );
}
-
}
diff --git a/tests/framework/helpers/class-wc-helper-coupon.php b/tests/framework/helpers/class-wc-helper-coupon.php
index 05206b867b8..1f4ab4e01a7 100644
--- a/tests/framework/helpers/class-wc-helper-coupon.php
+++ b/tests/framework/helpers/class-wc-helper-coupon.php
@@ -18,7 +18,7 @@ class WC_Helper_Coupon {
'post_title' => $coupon_code,
'post_type' => 'shop_coupon',
'post_status' => 'publish',
- 'post_excerpt' => 'This is a dummy coupon'
+ 'post_excerpt' => 'This is a dummy coupon',
) );
// Update meta
@@ -54,5 +54,4 @@ class WC_Helper_Coupon {
wp_delete_post( $coupon_id, true );
return true;
}
-
}
diff --git a/tests/framework/helpers/class-wc-helper-customer.php b/tests/framework/helpers/class-wc-helper-customer.php
index b585bd4582b..0d8dbd790a8 100644
--- a/tests/framework/helpers/class-wc-helper-customer.php
+++ b/tests/framework/helpers/class-wc-helper-customer.php
@@ -29,7 +29,7 @@ class WC_Helper_Customer {
'shipping_address' => '123 South Street',
'shipping_address_2' => 'Apt 1',
'is_vat_exempt' => false,
- 'calculated_shipping' => false
+ 'calculated_shipping' => false,
);
WC_Helper_Customer::set_customer_details( $customer_data );
@@ -60,7 +60,7 @@ class WC_Helper_Customer {
$customer->set_username( $username );
$customer->set_password( $password );
$customer->set_email( $email );
- $customer->create();
+ $customer->save();
return $customer;
}
diff --git a/tests/framework/helpers/class-wc-helper-payment-token.php b/tests/framework/helpers/class-wc-helper-payment-token.php
index 681aa98e2a0..e0168d42322 100644
--- a/tests/framework/helpers/class-wc-helper-payment-token.php
+++ b/tests/framework/helpers/class-wc-helper-payment-token.php
@@ -54,5 +54,4 @@ class WC_Helper_Payment_Token {
$token->save();
return $token;
}
-
}
diff --git a/tests/framework/helpers/class-wc-helper-product.php b/tests/framework/helpers/class-wc-helper-product.php
index e2bf15c64d1..968356d2b88 100644
--- a/tests/framework/helpers/class-wc-helper-product.php
+++ b/tests/framework/helpers/class-wc-helper-product.php
@@ -38,7 +38,7 @@ class WC_Helper_Product {
$product = wp_insert_post( array(
'post_title' => 'Dummy Product',
'post_type' => 'product',
- 'post_status' => 'publish'
+ 'post_status' => 'publish',
) );
update_post_meta( $product, '_price', '10' );
update_post_meta( $product, '_regular_price', '10' );
@@ -71,7 +71,7 @@ class WC_Helper_Product {
$product_id = wp_insert_post( array(
'post_title' => 'Dummy Product',
'post_type' => 'product',
- 'post_status' => 'publish'
+ 'post_status' => 'publish',
) );
// Set it as variable.
@@ -102,15 +102,15 @@ class WC_Helper_Product {
'position' => '1',
'is_visible' => 0,
'is_variation' => 1,
- 'is_taxonomy' => 1
- )
+ 'is_taxonomy' => 1,
+ ),
) );
// Link the product to the attribute
$wpdb->insert( $wpdb->prefix . 'term_relationships', array(
'object_id' => $product_id,
'term_taxonomy_id' => $attribute_data['term_taxonomy_id'],
- 'term_order' => 0
+ 'term_order' => 0,
) );
$return['term_taxonomy_id'] = $wpdb->insert_id;
@@ -119,7 +119,7 @@ class WC_Helper_Product {
'post_title' => 'Variation #' . ( $product_id + 1 ) . ' of Dummy Product',
'post_type' => 'product_variation',
'post_parent' => $product_id,
- 'post_status' => 'publish'
+ 'post_status' => 'publish',
) );
// Price related meta
@@ -141,7 +141,7 @@ class WC_Helper_Product {
'post_title' => 'Variation #' . ( $product_id + 2 ) . ' of Dummy Product',
'post_type' => 'product_variation',
'post_parent' => $product_id,
- 'post_status' => 'publish'
+ 'post_status' => 'publish',
) );
// Price related meta
@@ -198,11 +198,11 @@ class WC_Helper_Product {
$wpdb->insert( $wpdb->prefix . 'terms', array(
'name' => 'small',
'slug' => 'small',
- 'term_group' => 0
+ 'term_group' => 0,
), array(
'%s',
'%s',
- '%d'
+ '%d',
) );
$return['term_id'] = $wpdb->insert_id;
@@ -212,7 +212,7 @@ class WC_Helper_Product {
'taxonomy' => 'pa_dummyattribute',
'description' => '',
'parent' => 0,
- 'count' => 1
+ 'count' => 1,
) );
$return['term_taxonomy_id'] = $wpdb->insert_id;
@@ -261,5 +261,4 @@ class WC_Helper_Product {
return wp_insert_comment( $data );
}
-
}
diff --git a/tests/framework/helpers/class-wc-helper-settings.php b/tests/framework/helpers/class-wc-helper-settings.php
index 93495166dee..680eaee941b 100644
--- a/tests/framework/helpers/class-wc-helper-settings.php
+++ b/tests/framework/helpers/class-wc-helper-settings.php
@@ -77,5 +77,4 @@ class WC_Helper_Settings {
);
return $settings;
}
-
}
diff --git a/tests/framework/helpers/class-wc-helper-shipping.php b/tests/framework/helpers/class-wc-helper-shipping.php
index f70300117a9..99c22f60abe 100644
--- a/tests/framework/helpers/class-wc-helper-shipping.php
+++ b/tests/framework/helpers/class-wc-helper-shipping.php
@@ -19,7 +19,7 @@ class WC_Helper_Shipping {
'availability' => 'all',
'countries' => '',
'tax_status' => 'taxable',
- 'cost' => '10'
+ 'cost' => '10',
);
update_option( 'woocommerce_flat_rate_settings', $flat_rate_settings );
diff --git a/tests/unit-tests/api/coupons.php b/tests/unit-tests/api/coupons.php
index 7e9d30285f1..4d293b004b1 100644
--- a/tests/unit-tests/api/coupons.php
+++ b/tests/unit-tests/api/coupons.php
@@ -12,65 +12,66 @@ class WC_Tests_API_Coupons extends WC_REST_Unit_Test_Case {
* Setup test coupon data.
* @since 2.7.0
*/
- public function setUp() {
- parent::setUp();
- $this->endpoint = new WC_REST_Coupons_Controller();
- $this->user = $this->factory->user->create( array(
- 'role' => 'administrator',
- ) );
- }
+ public function setUp() {
+ parent::setUp();
+ $this->endpoint = new WC_REST_Coupons_Controller();
+ $this->user = $this->factory->user->create( array(
+ 'role' => 'administrator',
+ ) );
+ }
- /**
- * Test route registration.
- * @since 2.7.0
- */
- public function test_register_routes() {
- $routes = $this->server->get_routes();
- $this->assertArrayHasKey( '/wc/v1/coupons', $routes );
- $this->assertArrayHasKey( '/wc/v1/coupons/(?P[\d]+)', $routes );
- $this->assertArrayHasKey( '/wc/v1/coupons/batch', $routes );
- }
+ /**
+ * Test route registration.
+ * @since 2.7.0
+ */
+ public function test_register_routes() {
+ $routes = $this->server->get_routes();
+ $this->assertArrayHasKey( '/wc/v1/coupons', $routes );
+ $this->assertArrayHasKey( '/wc/v1/coupons/(?P[\d]+)', $routes );
+ $this->assertArrayHasKey( '/wc/v1/coupons/batch', $routes );
+ }
- /**
- * Test getting coupons.
- * @since 2.7.0
- */
- public function test_get_coupons() {
- wp_set_current_user( $this->user );
+ /**
+ * Test getting coupons.
+ * @since 2.7.0
+ */
+ public function test_get_coupons() {
+ wp_set_current_user( $this->user );
- $coupon_1 = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
- $post_1 = get_post( $coupon_1->get_id() );
- $coupon_2 = WC_Helper_Coupon::create_coupon( 'dummycoupon-2' );
+ $coupon_1 = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
+ $post_1 = get_post( $coupon_1->get_id() );
+ $coupon_2 = WC_Helper_Coupon::create_coupon( 'dummycoupon-2' );
- $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/coupons' ) );
- $coupons = $response->get_data();
+ $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/coupons' ) );
+ $coupons = $response->get_data();
- $this->assertEquals( 200, $response->get_status() );
- $this->assertEquals( 2, count( $coupons ) );
- $this->assertContains( array(
+ $this->assertEquals( 200, $response->get_status() );
+ $this->assertEquals( 2, count( $coupons ) );
+ $this->assertContains( array(
'id' => $coupon_1->get_id(),
- 'code' => 'dummycoupon-1',
- 'amount' => '1.00',
+ 'code' => 'dummycoupon-1',
+ 'amount' => '1.00',
'date_created' => wc_rest_prepare_date_response( $post_1->post_date_gmt ),
- 'date_modified' => wc_rest_prepare_date_response( $post_1->post_modified_gmt ),
+ 'date_modified' => wc_rest_prepare_date_response( $post_1->post_modified_gmt ),
'discount_type' => 'fixed_cart',
'description' => 'This is a dummy coupon',
- 'expiry_date' => '',
- 'usage_count' => 0,
- 'individual_use' => false,
- 'product_ids' => array(),
- 'exclude_product_ids' => array(),
- 'usage_limit' => '',
- 'usage_limit_per_user' => '',
- 'limit_usage_to_x_items' => 0,
- 'free_shipping' => false,
- 'product_categories' => array(),
- 'excluded_product_categories' => array(),
- 'exclude_sale_items' => false,
- 'minimum_amount' => '0.00',
- 'maximum_amount' => '0.00',
- 'email_restrictions' => array(),
- 'used_by' => array(),
+ 'date_expires' => '',
+ 'usage_count' => 0,
+ 'individual_use' => false,
+ 'product_ids' => array(),
+ 'excluded_product_ids' => array(),
+ 'usage_limit' => '',
+ 'usage_limit_per_user' => '',
+ 'limit_usage_to_x_items' => 0,
+ 'free_shipping' => false,
+ 'product_categories' => array(),
+ 'excluded_product_categories' => array(),
+ 'exclude_sale_items' => false,
+ 'minimum_amount' => '0.00',
+ 'maximum_amount' => '0.00',
+ 'email_restrictions' => array(),
+ 'used_by' => array(),
+ 'meta_data' => array(),
'_links' => array(
'self' => array(
array(
@@ -84,278 +85,280 @@ class WC_Tests_API_Coupons extends WC_REST_Unit_Test_Case {
),
),
), $coupons );
- }
+ }
- /**
- * Test getting coupons without valid permissions.
- * @since 2.7.0
- */
- public function test_get_coupons_without_permission() {
- wp_set_current_user( 0 );
+ /**
+ * Test getting coupons without valid permissions.
+ * @since 2.7.0
+ */
+ public function test_get_coupons_without_permission() {
+ wp_set_current_user( 0 );
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/coupons' ) );
$this->assertEquals( 401, $response->get_status() );
- }
+ }
- /**
- * Test getting a single coupon.
- * @since 2.7.0
- */
- public function test_get_coupon() {
- wp_set_current_user( $this->user );
+ /**
+ * Test getting a single coupon.
+ * @since 2.7.0
+ */
+ public function test_get_coupon() {
+ wp_set_current_user( $this->user );
$coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
- $post = get_post( $coupon->get_id() );
+ $post = get_post( $coupon->get_id() );
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/coupons/' . $coupon->get_id() ) );
$data = $response->get_data();
$this->assertEquals( 200, $response->get_status() );
$this->assertEquals( array(
- 'id' => $coupon->get_id(),
- 'code' => 'dummycoupon-1',
- 'amount' => '1.00',
- 'date_created' => wc_rest_prepare_date_response( $post->post_date_gmt ),
- 'date_modified' => wc_rest_prepare_date_response( $post->post_modified_gmt ),
- 'discount_type' => 'fixed_cart',
- 'description' => 'This is a dummy coupon',
- 'expiry_date' => null,
- 'usage_count' => 0,
- 'individual_use' => false,
- 'product_ids' => array(),
- 'exclude_product_ids' => array(),
- 'usage_limit' => null,
- 'usage_limit_per_user' => null,
- 'limit_usage_to_x_items' => 0,
- 'free_shipping' => false,
- 'product_categories' => array(),
- 'excluded_product_categories' => array(),
- 'exclude_sale_items' => false,
- 'minimum_amount' => '0.00',
- 'maximum_amount' => '0.00',
- 'email_restrictions' => array(),
- 'used_by' => array(),
+ 'id' => $coupon->get_id(),
+ 'code' => 'dummycoupon-1',
+ 'amount' => '1.00',
+ 'date_created' => wc_rest_prepare_date_response( $post->post_date_gmt ),
+ 'date_modified' => wc_rest_prepare_date_response( $post->post_modified_gmt ),
+ 'discount_type' => 'fixed_cart',
+ 'description' => 'This is a dummy coupon',
+ 'date_expires' => null,
+ 'usage_count' => 0,
+ 'individual_use' => false,
+ 'product_ids' => array(),
+ 'excluded_product_ids' => array(),
+ 'usage_limit' => null,
+ 'usage_limit_per_user' => null,
+ 'limit_usage_to_x_items' => 0,
+ 'free_shipping' => false,
+ 'product_categories' => array(),
+ 'excluded_product_categories' => array(),
+ 'exclude_sale_items' => false,
+ 'minimum_amount' => '0.00',
+ 'maximum_amount' => '0.00',
+ 'email_restrictions' => array(),
+ 'used_by' => array(),
+ 'meta_data' => array(),
), $data );
- }
+ }
- /**
- * Test getting a single coupon with an invalid ID.
- * @since 2.7.0
- */
- public function test_get_coupon_invalid_id() {
- wp_set_current_user( $this->user );
+ /**
+ * Test getting a single coupon with an invalid ID.
+ * @since 2.7.0
+ */
+ public function test_get_coupon_invalid_id() {
+ wp_set_current_user( $this->user );
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/coupons/0' ) );
$this->assertEquals( 404, $response->get_status() );
- }
+ }
- /**
- * Test getting a single coupon without valid permissions.
- * @since 2.7.0
- */
- public function test_get_coupon_without_permission() {
- wp_set_current_user( 0 );
- $coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
+ /**
+ * Test getting a single coupon without valid permissions.
+ * @since 2.7.0
+ */
+ public function test_get_coupon_without_permission() {
+ wp_set_current_user( 0 );
+ $coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/coupons/' . $coupon->get_id() ) );
$this->assertEquals( 401, $response->get_status() );
- }
+ }
- /**
- * Test creating a single coupon.
- * @since 2.7.0
- */
- public function test_create_coupon() {
- wp_set_current_user( $this->user );
- $request = new WP_REST_Request( 'POST', '/wc/v1/coupons' );
- $request->set_body_params( array(
- 'code' => 'test',
- 'amount' => '5.00',
- 'discount_type' => 'fixed_product',
- 'description' => 'Test',
- 'usage_limit' => 10,
- ) );
- $response = $this->server->dispatch( $request );
- $data = $response->get_data();
+ /**
+ * Test creating a single coupon.
+ * @since 2.7.0
+ */
+ public function test_create_coupon() {
+ wp_set_current_user( $this->user );
+ $request = new WP_REST_Request( 'POST', '/wc/v1/coupons' );
+ $request->set_body_params( array(
+ 'code' => 'test',
+ 'amount' => '5.00',
+ 'discount_type' => 'fixed_product',
+ 'description' => 'Test',
+ 'usage_limit' => 10,
+ ) );
+ $response = $this->server->dispatch( $request );
+ $data = $response->get_data();
- $this->assertEquals( 201, $response->get_status() );
- $this->assertEquals( array(
- 'id' => $data['id'],
- 'code' => 'test',
- 'amount' => '5.00',
- 'date_created' => $data['date_created'],
- 'date_modified' => $data['date_modified'],
- 'discount_type' => 'fixed_product',
- 'description' => 'Test',
- 'expiry_date' => null,
- 'usage_count' => 0,
- 'individual_use' => false,
- 'product_ids' => array(),
- 'exclude_product_ids' => array(),
- 'usage_limit' => 10,
- 'usage_limit_per_user' => null,
- 'limit_usage_to_x_items' => 0,
- 'free_shipping' => false,
- 'product_categories' => array(),
- 'excluded_product_categories' => array(),
- 'exclude_sale_items' => false,
- 'minimum_amount' => '0.00',
- 'maximum_amount' => '0.00',
- 'email_restrictions' => array(),
- 'used_by' => array(),
- ), $data );
- }
+ $this->assertEquals( 201, $response->get_status() );
+ $this->assertEquals( array(
+ 'id' => $data['id'],
+ 'code' => 'test',
+ 'amount' => '5.00',
+ 'date_created' => $data['date_created'],
+ 'date_modified' => $data['date_modified'],
+ 'discount_type' => 'fixed_product',
+ 'description' => 'Test',
+ 'date_expires' => null,
+ 'usage_count' => 0,
+ 'individual_use' => false,
+ 'product_ids' => array(),
+ 'excluded_product_ids' => array(),
+ 'usage_limit' => 10,
+ 'usage_limit_per_user' => null,
+ 'limit_usage_to_x_items' => 0,
+ 'free_shipping' => false,
+ 'product_categories' => array(),
+ 'excluded_product_categories' => array(),
+ 'exclude_sale_items' => false,
+ 'minimum_amount' => '0.00',
+ 'maximum_amount' => '0.00',
+ 'email_restrictions' => array(),
+ 'used_by' => array(),
+ 'meta_data' => array(),
+ ), $data );
+ }
- /**
- * Test creating a single coupon with invalid fields.
- * @since 2.7.0
- */
- public function test_create_coupon_invalid_fields() {
- wp_set_current_user( $this->user );
+ /**
+ * Test creating a single coupon with invalid fields.
+ * @since 2.7.0
+ */
+ public function test_create_coupon_invalid_fields() {
+ wp_set_current_user( $this->user );
- // test no code...
- $request = new WP_REST_Request( 'POST', '/wc/v1/coupons' );
- $request->set_body_params( array(
- 'amount' => '5.00',
- 'discount_type' => 'fixed_product',
- ) );
- $response = $this->server->dispatch( $request );
- $data = $response->get_data();
+ // test no code...
+ $request = new WP_REST_Request( 'POST', '/wc/v1/coupons' );
+ $request->set_body_params( array(
+ 'amount' => '5.00',
+ 'discount_type' => 'fixed_product',
+ ) );
+ $response = $this->server->dispatch( $request );
+ $data = $response->get_data();
- $this->assertEquals( 400, $response->get_status() );
- }
+ $this->assertEquals( 400, $response->get_status() );
+ }
- /**
- * Test creating a single coupon without valid permissions.
- * @since 2.7.0
- */
- public function test_create_coupon_without_permission() {
- wp_set_current_user( 0 );
+ /**
+ * Test creating a single coupon without valid permissions.
+ * @since 2.7.0
+ */
+ public function test_create_coupon_without_permission() {
+ wp_set_current_user( 0 );
- // test no code...
- $request = new WP_REST_Request( 'POST', '/wc/v1/coupons' );
- $request->set_body_params( array(
- 'code' => 'fail',
- 'amount' => '5.00',
- 'discount_type' => 'fixed_product',
- ) );
- $response = $this->server->dispatch( $request );
- $data = $response->get_data();
+ // test no code...
+ $request = new WP_REST_Request( 'POST', '/wc/v1/coupons' );
+ $request->set_body_params( array(
+ 'code' => 'fail',
+ 'amount' => '5.00',
+ 'discount_type' => 'fixed_product',
+ ) );
+ $response = $this->server->dispatch( $request );
+ $data = $response->get_data();
- $this->assertEquals( 401, $response->get_status() );
- }
+ $this->assertEquals( 401, $response->get_status() );
+ }
- /**
- * Test updating a single coupon.
- * @since 2.7.0
- */
- public function test_update_coupon() {
- wp_set_current_user( $this->user );
- $coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
- $post = get_post( $coupon->get_id() );
+ /**
+ * Test updating a single coupon.
+ * @since 2.7.0
+ */
+ public function test_update_coupon() {
+ wp_set_current_user( $this->user );
+ $coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
+ $post = get_post( $coupon->get_id() );
- $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/coupons/' . $coupon->get_id() ) );
- $data = $response->get_data();
- $this->assertEquals( 'This is a dummy coupon', $data['description'] );
- $this->assertEquals( 'fixed_cart', $data['discount_type'] );
- $this->assertEquals( '1.00', $data['amount'] );
+ $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/coupons/' . $coupon->get_id() ) );
+ $data = $response->get_data();
+ $this->assertEquals( 'This is a dummy coupon', $data['description'] );
+ $this->assertEquals( 'fixed_cart', $data['discount_type'] );
+ $this->assertEquals( '1.00', $data['amount'] );
- $request = new WP_REST_Request( 'PUT', '/wc/v1/coupons/' . $coupon->get_id() );
- $request->set_body_params( array(
- 'amount' => '10.00',
- 'description' => 'New description',
- ) );
- $response = $this->server->dispatch( $request );
- $data = $response->get_data();
+ $request = new WP_REST_Request( 'PUT', '/wc/v1/coupons/' . $coupon->get_id() );
+ $request->set_body_params( array(
+ 'amount' => '10.00',
+ 'description' => 'New description',
+ ) );
+ $response = $this->server->dispatch( $request );
+ $data = $response->get_data();
- $this->assertEquals( '10.00', $data['amount'] );
- $this->assertEquals( 'New description', $data['description'] );
- $this->assertEquals( 'fixed_cart', $data['discount_type'] );
- }
+ $this->assertEquals( '10.00', $data['amount'] );
+ $this->assertEquals( 'New description', $data['description'] );
+ $this->assertEquals( 'fixed_cart', $data['discount_type'] );
+ }
- /**
- * Test updating a single coupon with an invalid ID.
- * @since 2.7.0
- */
- public function test_update_coupon_invalid_id() {
- wp_set_current_user( $this->user );
+ /**
+ * Test updating a single coupon with an invalid ID.
+ * @since 2.7.0
+ */
+ public function test_update_coupon_invalid_id() {
+ wp_set_current_user( $this->user );
- $request = new WP_REST_Request( 'PUT', '/wc/v1/coupons/0' );
- $request->set_body_params( array(
- 'code' => 'tester',
- 'amount' => '10.00',
- 'description' => 'New description',
- ) );
- $response = $this->server->dispatch( $request );
- $data = $response->get_data();
+ $request = new WP_REST_Request( 'PUT', '/wc/v1/coupons/0' );
+ $request->set_body_params( array(
+ 'code' => 'tester',
+ 'amount' => '10.00',
+ 'description' => 'New description',
+ ) );
+ $response = $this->server->dispatch( $request );
+ $data = $response->get_data();
- $this->assertEquals( 400, $response->get_status() );
- }
+ $this->assertEquals( 400, $response->get_status() );
+ }
- /**
- * Test updating a single coupon without valid permissions.
- * @since 2.7.0
- */
- public function test_update_coupon_without_permission() {
- wp_set_current_user( 0 );
- $coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
- $post = get_post( $coupon->get_id() );
+ /**
+ * Test updating a single coupon without valid permissions.
+ * @since 2.7.0
+ */
+ public function test_update_coupon_without_permission() {
+ wp_set_current_user( 0 );
+ $coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
+ $post = get_post( $coupon->get_id() );
- $request = new WP_REST_Request( 'PUT', '/wc/v1/coupons/' . $coupon->get_id() );
- $request->set_body_params( array(
- 'amount' => '10.00',
- 'description' => 'New description',
- ) );
- $response = $this->server->dispatch( $request );
+ $request = new WP_REST_Request( 'PUT', '/wc/v1/coupons/' . $coupon->get_id() );
+ $request->set_body_params( array(
+ 'amount' => '10.00',
+ 'description' => 'New description',
+ ) );
+ $response = $this->server->dispatch( $request );
- $this->assertEquals( 401, $response->get_status() );
- }
+ $this->assertEquals( 401, $response->get_status() );
+ }
- /**
- * Test deleting a single coupon.
- * @since 2.7.0
- */
- public function test_delete_coupon() {
- wp_set_current_user( $this->user );
+ /**
+ * Test deleting a single coupon.
+ * @since 2.7.0
+ */
+ public function test_delete_coupon() {
+ wp_set_current_user( $this->user );
$coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
$request = new WP_REST_Request( 'DELETE', '/wc/v1/coupons/' . $coupon->get_id() );
$request->set_param( 'force', true );
$response = $this->server->dispatch( $request );
$this->assertEquals( 200, $response->get_status() );
- }
+ }
- /**
- * Test deleting a single coupon with an invalid ID.
- * @since 2.7.0
- */
- public function test_delete_coupon_invalid_id() {
- wp_set_current_user( $this->user );
+ /**
+ * Test deleting a single coupon with an invalid ID.
+ * @since 2.7.0
+ */
+ public function test_delete_coupon_invalid_id() {
+ wp_set_current_user( $this->user );
$request = new WP_REST_Request( 'DELETE', '/wc/v1/coupons/0' );
$request->set_param( 'force', true );
$response = $this->server->dispatch( $request );
$this->assertEquals( 404, $response->get_status() );
- }
+ }
- /**
- * Test deleting a single coupon without valid permissions.
- * @since 2.7.0
- */
- public function test_delete_coupon_without_permission() {
- wp_set_current_user( 0 );
- $coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
- $request = new WP_REST_Request( 'DELETE', '/wc/v1/coupons/' . $coupon->get_id() );
- $response = $this->server->dispatch( $request );
+ /**
+ * Test deleting a single coupon without valid permissions.
+ * @since 2.7.0
+ */
+ public function test_delete_coupon_without_permission() {
+ wp_set_current_user( 0 );
+ $coupon = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
+ $request = new WP_REST_Request( 'DELETE', '/wc/v1/coupons/' . $coupon->get_id() );
+ $response = $this->server->dispatch( $request );
- $this->assertEquals( 401, $response->get_status() );
- }
+ $this->assertEquals( 401, $response->get_status() );
+ }
- /**
- * Test batch operations on coupons.
- * @since 2.7.0
- */
- public function test_batch_coupon() {
- wp_set_current_user( $this->user );
+ /**
+ * Test batch operations on coupons.
+ * @since 2.7.0
+ */
+ public function test_batch_coupon() {
+ wp_set_current_user( $this->user );
$coupon_1 = WC_Helper_Coupon::create_coupon( 'dummycoupon-1' );
- $coupon_2 = WC_Helper_Coupon::create_coupon( 'dummycoupon-2' );
- $coupon_3 = WC_Helper_Coupon::create_coupon( 'dummycoupon-3' );
- $coupon_4 = WC_Helper_Coupon::create_coupon( 'dummycoupon-4' );
+ $coupon_2 = WC_Helper_Coupon::create_coupon( 'dummycoupon-2' );
+ $coupon_3 = WC_Helper_Coupon::create_coupon( 'dummycoupon-3' );
+ $coupon_4 = WC_Helper_Coupon::create_coupon( 'dummycoupon-4' );
$request = new WP_REST_Request( 'POST', '/wc/v1/coupons/batch' );
$request->set_body_params( array(
@@ -367,7 +370,7 @@ class WC_Tests_API_Coupons extends WC_REST_Unit_Test_Case {
),
'delete' => array(
$coupon_2->get_id(),
- $coupon_3->get_id(),
+ $coupon_3->get_id(),
),
'create' => array(
array(
@@ -381,7 +384,7 @@ class WC_Tests_API_Coupons extends WC_REST_Unit_Test_Case {
$this->assertEquals( '5.15', $data['update'][0]['amount'] );
$this->assertEquals( '11.00', $data['create'][0]['amount'] );
- $this->assertEquals( 'new-coupon', $data['create'][0]['code'] );
+ $this->assertEquals( 'new-coupon', $data['create'][0]['code'] );
$this->assertEquals( $coupon_2->get_id(), $data['delete'][0]['id'] );
$this->assertEquals( $coupon_3->get_id(), $data['delete'][1]['id'] );
@@ -390,43 +393,42 @@ class WC_Tests_API_Coupons extends WC_REST_Unit_Test_Case {
$data = $response->get_data();
$this->assertEquals( 3, count( $data ) );
- }
+ }
- /**
- * Test coupon schema.
- * @since 2.7.0
- */
- public function test_coupon_schema() {
- wp_set_current_user( $this->user );
+ /**
+ * Test coupon schema.
+ * @since 2.7.0
+ */
+ public function test_coupon_schema() {
+ wp_set_current_user( $this->user );
$request = new WP_REST_Request( 'OPTIONS', '/wc/v1/coupons' );
$response = $this->server->dispatch( $request );
$data = $response->get_data();
$properties = $data['schema']['properties'];
- $this->assertEquals( 23, count( $properties ) );
- $this->assertArrayHasKey( 'id', $properties );
+ $this->assertEquals( 24, count( $properties ) );
+ $this->assertArrayHasKey( 'id', $properties );
$this->assertArrayHasKey( 'code', $properties );
- $this->assertArrayHasKey( 'date_created', $properties );
- $this->assertArrayHasKey( 'date_modified', $properties );
- $this->assertArrayHasKey( 'description', $properties );
- $this->assertArrayHasKey( 'discount_type', $properties );
- $this->assertArrayHasKey( 'amount', $properties );
- $this->assertArrayHasKey( 'expiry_date', $properties );
- $this->assertArrayHasKey( 'usage_count', $properties );
- $this->assertArrayHasKey( 'individual_use', $properties );
- $this->assertArrayHasKey( 'product_ids', $properties );
- $this->assertArrayHasKey( 'exclude_product_ids', $properties );
- $this->assertArrayHasKey( 'usage_limit', $properties );
- $this->assertArrayHasKey( 'usage_limit_per_user', $properties );
- $this->assertArrayHasKey( 'limit_usage_to_x_items', $properties );
- $this->assertArrayHasKey( 'free_shipping', $properties );
- $this->assertArrayHasKey( 'product_categories', $properties );
- $this->assertArrayHasKey( 'excluded_product_categories', $properties );
- $this->assertArrayHasKey( 'exclude_sale_items', $properties );
- $this->assertArrayHasKey( 'minimum_amount', $properties );
- $this->assertArrayHasKey( 'maximum_amount', $properties );
- $this->assertArrayHasKey( 'email_restrictions', $properties );
- $this->assertArrayHasKey( 'used_by', $properties );
- }
-
+ $this->assertArrayHasKey( 'date_created', $properties );
+ $this->assertArrayHasKey( 'date_modified', $properties );
+ $this->assertArrayHasKey( 'description', $properties );
+ $this->assertArrayHasKey( 'discount_type', $properties );
+ $this->assertArrayHasKey( 'amount', $properties );
+ $this->assertArrayHasKey( 'date_expires', $properties );
+ $this->assertArrayHasKey( 'usage_count', $properties );
+ $this->assertArrayHasKey( 'individual_use', $properties );
+ $this->assertArrayHasKey( 'product_ids', $properties );
+ $this->assertArrayHasKey( 'excluded_product_ids', $properties );
+ $this->assertArrayHasKey( 'usage_limit', $properties );
+ $this->assertArrayHasKey( 'usage_limit_per_user', $properties );
+ $this->assertArrayHasKey( 'limit_usage_to_x_items', $properties );
+ $this->assertArrayHasKey( 'free_shipping', $properties );
+ $this->assertArrayHasKey( 'product_categories', $properties );
+ $this->assertArrayHasKey( 'excluded_product_categories', $properties );
+ $this->assertArrayHasKey( 'exclude_sale_items', $properties );
+ $this->assertArrayHasKey( 'minimum_amount', $properties );
+ $this->assertArrayHasKey( 'maximum_amount', $properties );
+ $this->assertArrayHasKey( 'email_restrictions', $properties );
+ $this->assertArrayHasKey( 'used_by', $properties );
+ }
}
diff --git a/tests/unit-tests/api/customers.php b/tests/unit-tests/api/customers.php
index a7db36a3d9b..58d2cbb950f 100644
--- a/tests/unit-tests/api/customers.php
+++ b/tests/unit-tests/api/customers.php
@@ -18,8 +18,8 @@ class Customers extends WC_REST_Unit_Test_Case {
/**
* Test route registration.
- *
- * @since 2.7.0
+ *
+ * @since 2.7.0
*/
public function test_register_routes() {
$routes = $this->server->get_routes();
@@ -29,88 +29,90 @@ class Customers extends WC_REST_Unit_Test_Case {
$this->assertArrayHasKey( '/wc/v1/customers/batch', $routes );
}
- /**
- * Test getting customers.
- *
- * @since 2.7.0
- */
- public function test_get_customers() {
- wp_set_current_user( 1 );
+ /**
+ * Test getting customers.
+ *
+ * @since 2.7.0
+ */
+ public function test_get_customers() {
+ wp_set_current_user( 1 );
- $customer_1 = WC_Helper_Customer::create_customer();
- WC_Helper_Customer::create_customer( 'test2', 'test2', 'test2@woo.local' );
+ $customer_1 = WC_Helper_Customer::create_customer();
+ WC_Helper_Customer::create_customer( 'test2', 'test2', 'test2@woo.local' );
- $request = new WP_REST_Request( 'GET', '/wc/v1/customers' );
- $request->set_query_params( array(
+ $request = new WP_REST_Request( 'GET', '/wc/v1/customers' );
+ $request->set_query_params( array(
'orderby' => 'id',
) );
- $response = $this->server->dispatch( $request );
- $customers = $response->get_data();
+ $response = $this->server->dispatch( $request );
+ $customers = $response->get_data();
- $this->assertEquals( 200, $response->get_status() );
- $this->assertEquals( 2, count( $customers ) );
+ $this->assertEquals( 200, $response->get_status() );
+ $this->assertEquals( 2, count( $customers ) );
- $this->assertContains( array(
- 'id' => $customer_1->get_id(),
- 'date_created' => wc_rest_prepare_date_response( date( 'Y-m-d H:i:s', $customer_1->get_date_created() ) ),
- 'date_modified' => wc_rest_prepare_date_response( date( 'Y-m-d H:i:s', $customer_1->get_date_modified() ) ),
- 'email' => 'test@woo.local',
- 'first_name' => 'Justin',
- 'last_name' => '',
- 'username' => 'testcustomer',
- 'last_order' => null,
- 'orders_count' => 0,
- 'total_spent' => '0.00',
- 'avatar_url' => $customer_1->get_avatar_url(),
- 'billing' => array(
- 'first_name' => '',
- 'last_name' => '',
- 'company' => '',
- 'address_1' => '123 South Street',
- 'address_2' => 'Apt 1',
- 'city' => 'Philadelphia',
- 'state' => 'PA',
- 'postcode' => '19123',
- 'country' => 'US',
- 'email' => '',
- 'phone' => '',
- ),
- 'shipping' => array(
- 'first_name' => '',
- 'last_name' => '',
- 'company' => '',
- 'address_1' => '123 South Street',
- 'address_2' => 'Apt 1',
- 'city' => 'Philadelphia',
- 'state' => 'PA',
- 'postcode' => '19123',
- 'country' => 'US',
- ),
- '_links' => array(
- 'self' => array(
- array(
- 'href' => rest_url( '/wc/v1/customers/' . $customer_1->get_id() . '' ),
- ),
- ),
- 'collection' => array(
- array(
- 'href' => rest_url( '/wc/v1/customers' ),
- ),
- ),
- ),
- ), $customers );
- }
+ $this->assertContains( array(
+ 'id' => $customer_1->get_id(),
+ 'date_created' => wc_rest_prepare_date_response( date( 'Y-m-d H:i:s', $customer_1->get_date_created() ) ),
+ 'date_modified' => wc_rest_prepare_date_response( date( 'Y-m-d H:i:s', $customer_1->get_date_modified() ) ),
+ 'email' => 'test@woo.local',
+ 'first_name' => 'Justin',
+ 'last_name' => '',
+ 'username' => 'testcustomer',
+ 'billing' => array(
+ 'first_name' => '',
+ 'last_name' => '',
+ 'company' => '',
+ 'address_1' => '123 South Street',
+ 'address_2' => 'Apt 1',
+ 'city' => 'Philadelphia',
+ 'state' => 'PA',
+ 'postcode' => '19123',
+ 'country' => 'US',
+ 'email' => '',
+ 'phone' => '',
+ ),
+ 'shipping' => array(
+ 'first_name' => '',
+ 'last_name' => '',
+ 'company' => '',
+ 'address_1' => '123 South Street',
+ 'address_2' => 'Apt 1',
+ 'city' => 'Philadelphia',
+ 'state' => 'PA',
+ 'postcode' => '19123',
+ 'country' => 'US',
+ ),
+ 'is_paying_customer' => false,
+ 'last_order' => null,
+ 'orders_count' => 0,
+ 'total_spent' => '0.00',
+ 'avatar_url' => $customer_1->get_avatar_url(),
+ 'meta_data' => array(),
+ '_links' => array(
+ 'self' => array(
+ array(
+ 'href' => rest_url( '/wc/v1/customers/' . $customer_1->get_id() . '' ),
+ ),
+ ),
+ 'collection' => array(
+ array(
+ 'href' => rest_url( '/wc/v1/customers' ),
+ ),
+ ),
+ ),
+ ), $customers );
+ }
- /**
- * Test getting customers without valid permissions.
- *
- * @since 2.7.0
- */
- public function test_get_customers_without_permission() {
+ /**
+ * Test getting customers without valid permissions.
+ *
+ * @since 2.7.0
+ */
+ public function test_get_customers_without_permission() {
wp_set_current_user( 0 );
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v1/customers' ) );
$this->assertEquals( 401, $response->get_status() );
- }
+ }
/**
* Test creating a new customer.
@@ -139,10 +141,6 @@ class Customers extends WC_REST_Unit_Test_Case {
'first_name' => '',
'last_name' => '',
'username' => 'create_customer_test',
- 'last_order' => null,
- 'orders_count' => 0,
- 'total_spent' => '0',
- 'avatar_url' => $data['avatar_url'],
'billing' => array(
'first_name' => '',
'last_name' => '',
@@ -167,12 +165,18 @@ class Customers extends WC_REST_Unit_Test_Case {
'postcode' => '',
'country' => '',
),
+ 'is_paying_customer' => false,
+ 'meta_data' => array(),
+ 'last_order' => null,
+ 'orders_count' => 0,
+ 'total_spent' => '0.00',
+ 'avatar_url' => $data['avatar_url'],
), $data );
// Test extra data
$request = new WP_REST_Request( 'POST', '/wc/v1/customers' );
$request->set_body_params( array(
- 'username' => 'create_customer_test2',
+ 'username' => 'create_customer_test2',
'password' => 'test123',
'email' => 'create_customer_test2@woo.local',
'first_name' => 'Test',
@@ -198,10 +202,6 @@ class Customers extends WC_REST_Unit_Test_Case {
'first_name' => 'Test',
'last_name' => 'McTestFace',
'username' => 'create_customer_test2',
- 'last_order' => null,
- 'orders_count' => 0,
- 'total_spent' => '0',
- 'avatar_url' => $data['avatar_url'],
'billing' => array(
'first_name' => '',
'last_name' => '',
@@ -226,6 +226,12 @@ class Customers extends WC_REST_Unit_Test_Case {
'postcode' => '',
'country' => 'US',
),
+ 'is_paying_customer' => false,
+ 'meta_data' => array(),
+ 'last_order' => null,
+ 'orders_count' => 0,
+ 'total_spent' => '0.00',
+ 'avatar_url' => $data['avatar_url'],
), $data );
// Test without required field
@@ -275,12 +281,6 @@ class Customers extends WC_REST_Unit_Test_Case {
'date_modified' => $data['date_modified'],
'email' => 'get_customer_test@woo.local',
'first_name' => 'Justin',
- 'last_name' => '',
- 'username' => 'get_customer_test',
- 'last_order' => null,
- 'orders_count' => 0,
- 'total_spent' => '0.00',
- 'avatar_url' => $data['avatar_url'],
'billing' => array(
'first_name' => '',
'last_name' => '',
@@ -305,6 +305,14 @@ class Customers extends WC_REST_Unit_Test_Case {
'postcode' => '19123',
'country' => 'US',
),
+ 'is_paying_customer' => false,
+ 'meta_data' => array(),
+ 'last_name' => '',
+ 'username' => 'get_customer_test',
+ 'last_order' => null,
+ 'orders_count' => 0,
+ 'total_spent' => '0.00',
+ 'avatar_url' => $data['avatar_url'],
), $data );
}
@@ -483,7 +491,7 @@ class Customers extends WC_REST_Unit_Test_Case {
$data = $response->get_data();
$properties = $data['schema']['properties'];
- $this->assertEquals( 14, count( $properties ) );
+ $this->assertEquals( 16, count( $properties ) );
$this->assertArrayHasKey( 'id', $properties );
$this->assertArrayHasKey( 'date_created', $properties );
$this->assertArrayHasKey( 'date_modified', $properties );
@@ -521,5 +529,4 @@ class Customers extends WC_REST_Unit_Test_Case {
$this->assertArrayHasKey( 'postcode', $properties['shipping']['properties'] );
$this->assertArrayHasKey( 'country', $properties['shipping']['properties'] );
}
-
}
diff --git a/tests/unit-tests/api/legacy/coupons.php b/tests/unit-tests/api/legacy/coupons.php
index c490a0b7f2d..c2e72550f2b 100644
--- a/tests/unit-tests/api/legacy/coupons.php
+++ b/tests/unit-tests/api/legacy/coupons.php
@@ -38,7 +38,7 @@ class WC_Tests_API_Legacy_Coupons extends WC_API_Unit_Test_Case {
$this->assertEquals( (int) $coupon->get_usage_limit_per_user(), $response['usage_limit_per_user'] );
$this->assertEquals( (int) $coupon->get_limit_usage_to_x_items(), $response['limit_usage_to_x_items'] );
$this->assertEquals( (int) $coupon->get_usage_count(), $response['usage_count'] );
- $this->assertEquals( $coupon->get_expiry_date(), $response['expiry_date'] );
+ $this->assertEquals( $coupon->get_date_expires(), $response['expiry_date'] );
$this->assertEquals( $coupon->get_free_shipping(), $response['enable_free_shipping'] );
$this->assertEquals( $coupon->get_product_categories(), $response['product_category_ids'] );
$this->assertEquals( $coupon->get_excluded_product_categories(), $response['exclude_product_category_ids'] );
@@ -317,5 +317,4 @@ class WC_Tests_API_Legacy_Coupons extends WC_API_Unit_Test_Case {
$this->assertArrayHasKey( 'coupons', $response );
$this->check_get_coupon_response( $response['coupons'][0], new WC_Coupon( $response['coupons'][0]['code'] ) );
}
-
}
diff --git a/tests/unit-tests/api/legacy/webhooks.php b/tests/unit-tests/api/legacy/webhooks.php
index 6072da4e58b..6b7308daaca 100644
--- a/tests/unit-tests/api/legacy/webhooks.php
+++ b/tests/unit-tests/api/legacy/webhooks.php
@@ -439,7 +439,7 @@ class WC_Tests_API_Webhooks extends WC_API_Unit_Test_Case {
* @since 2.2
* @param $response
*/
- protected function check_create_webhook_response( $response ) {
+ protected function check_create_webhook_response( $response ) {
$this->assertNotWPError( $response );
$this->assertArrayHasKey( 'webhook', $response );
@@ -497,5 +497,4 @@ class WC_Tests_API_Webhooks extends WC_API_Unit_Test_Case {
$this->assertEquals( $delivery, $response );
}
-
}
diff --git a/tests/unit-tests/api/orders.php b/tests/unit-tests/api/orders.php
index 6120e26cd57..3c9e0f81f61 100644
--- a/tests/unit-tests/api/orders.php
+++ b/tests/unit-tests/api/orders.php
@@ -139,7 +139,7 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe@example.com',
- 'phone' => '(555) 555-5555'
+ 'phone' => '(555) 555-5555',
),
'shipping' => array(
'first_name' => 'John',
@@ -154,14 +154,14 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
'line_items' => array(
array(
'product_id' => $product->get_id(),
- 'quantity' => 2
+ 'quantity' => 2,
),
),
'shipping_lines' => array(
array(
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
- 'total' => 10
+ 'total' => 10,
),
),
) );
@@ -223,7 +223,7 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe@example.com',
- 'phone' => '(555) 555-5555'
+ 'phone' => '(555) 555-5555',
),
'shipping' => array(
'first_name' => 'John',
@@ -238,14 +238,14 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
'line_items' => array(
array(
'product_id' => $product->get_id(),
- 'quantity' => 2
+ 'quantity' => 2,
),
),
'shipping_lines' => array(
array(
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
- 'total' => 10
+ 'total' => 10,
),
),
) );
@@ -415,5 +415,4 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
$this->assertArrayHasKey( 'id', $properties );
wp_delete_post( $order->get_id(), true );
}
-
}
diff --git a/tests/unit-tests/api/product-reviews.php b/tests/unit-tests/api/product-reviews.php
index 356dba8d5fd..fa31e027820 100644
--- a/tests/unit-tests/api/product-reviews.php
+++ b/tests/unit-tests/api/product-reviews.php
@@ -114,7 +114,7 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
$this->assertEquals( 200, $response->get_status() );
$this->assertEquals( array(
- 'id' => $product_review_id ,
+ 'id' => $product_review_id,
'date_created' => '2016-01-01T11:11:11',
'review' => 'Review content here',
'rating' => 0,
@@ -419,5 +419,4 @@ class Product_Reviews extends WC_REST_Unit_Test_Case {
$this->assertArrayHasKey( 'email', $properties );
$this->assertArrayHasKey( 'verified', $properties );
}
-
}
diff --git a/tests/unit-tests/api/products.php b/tests/unit-tests/api/products.php
new file mode 100644
index 00000000000..96d2a176512
--- /dev/null
+++ b/tests/unit-tests/api/products.php
@@ -0,0 +1,105 @@
+endpoint = new WC_REST_Products_Controller();
+ $this->user = $this->factory->user->create( array(
+ 'role' => 'administrator',
+ ) );
+ }
+
+ /**
+ * Tests to make sure you can filter products post statuses by both
+ * the status query arg and WP_Query.
+ *
+ * @since 2.7.0
+ */
+ public function test_products_filter_post_status() {
+ wp_set_current_user( $this->user );
+ for ( $i = 0; $i < 8; $i++ ) {
+ $product = WC_Helper_Product::create_simple_product();
+ if ( 0 === $i % 2 ) {
+ wp_update_post( array(
+ 'ID' => $product->get_id(),
+ 'post_status' => 'draft',
+ ) );
+ }
+ }
+
+ // Test filtering with filter[post_status]=publish
+ $request = new WP_REST_Request( 'GET', '/wc/v1/products' );
+ $request->set_param( 'filter', array( 'post_status' => 'publish' ) );
+ $response = $this->server->dispatch( $request );
+ $products = $response->get_data();
+
+ $this->assertEquals( 4, count( $products ) );
+ foreach ( $products as $product ) {
+ $this->assertEquals( 'publish', $product['status'] );
+ }
+
+ // Test filtering with filter[post_status]=draft
+ $request = new WP_REST_Request( 'GET', '/wc/v1/products' );
+ $request->set_param( 'filter', array( 'post_status' => 'draft' ) );
+ $response = $this->server->dispatch( $request );
+ $products = $response->get_data();
+
+ $this->assertEquals( 4, count( $products ) );
+ foreach ( $products as $product ) {
+ $this->assertEquals( 'draft', $product['status'] );
+ }
+
+ // Test filtering with status=publish
+ $request = new WP_REST_Request( 'GET', '/wc/v1/products' );
+ $request->set_param( 'status', 'publish' );
+ $response = $this->server->dispatch( $request );
+ $products = $response->get_data();
+
+ $this->assertEquals( 4, count( $products ) );
+ foreach ( $products as $product ) {
+ $this->assertEquals( 'publish', $product['status'] );
+ }
+
+ // Test filtering with status=draft
+ $request = new WP_REST_Request( 'GET', '/wc/v1/products' );
+ $request->set_param( 'status', 'draft' );
+ $response = $this->server->dispatch( $request );
+ $products = $response->get_data();
+
+ $this->assertEquals( 4, count( $products ) );
+ foreach ( $products as $product ) {
+ $this->assertEquals( 'draft', $product['status'] );
+ }
+
+ // Test filtering with status=draft and filter[post_status]=publish
+ // filter[post_status]=publish should win
+ $request = new WP_REST_Request( 'GET', '/wc/v1/products' );
+ $request->set_param( 'status', 'draft' );
+ $request->set_param( 'filter', array( 'post_status' => 'publish' ) );
+ $response = $this->server->dispatch( $request );
+ $products = $response->get_data();
+
+ $this->assertEquals( 4, count( $products ) );
+ foreach ( $products as $product ) {
+ $this->assertEquals( 'publish', $product['status'] );
+ }
+
+ // Test filtering with no filters - which should return 'any' (all 8)
+ $request = new WP_REST_Request( 'GET', '/wc/v1/products' );
+ $response = $this->server->dispatch( $request );
+ $products = $response->get_data();
+
+ $this->assertEquals( 8, count( $products ) );
+ }
+
+}
diff --git a/tests/unit-tests/api/settings.php b/tests/unit-tests/api/settings.php
index 8f9c0583373..d0b20cb9f8f 100644
--- a/tests/unit-tests/api/settings.php
+++ b/tests/unit-tests/api/settings.php
@@ -137,10 +137,11 @@ class Settings extends WC_REST_Unit_Test_Case {
$response = $this->server->dispatch( $request );
$data = $response->get_data();
$properties = $data['schema']['properties'];
- $this->assertEquals( 8, count( $properties ) );
+ $this->assertEquals( 9, count( $properties ) );
$this->assertArrayHasKey( 'id', $properties );
$this->assertArrayHasKey( 'label', $properties );
$this->assertArrayHasKey( 'description', $properties );
+ $this->assertArrayHasKey( 'value', $properties );
$this->assertArrayHasKey( 'default', $properties );
$this->assertArrayHasKey( 'tip', $properties );
$this->assertArrayHasKey( 'placeholder', $properties );
@@ -191,7 +192,7 @@ class Settings extends WC_REST_Unit_Test_Case {
'href' => rest_url( '/wc/v1/settings/general' ),
),
),
- )
+ ),
), $data );
// test getting a valid group with settings attached to it
@@ -537,5 +538,4 @@ class Settings extends WC_REST_Unit_Test_Case {
$this->assertEquals( 'yd', $data['value'] );
$this->assertEquals( 'yd', get_option(' woocommerce_dimension_unit' ) );
}
-
}
diff --git a/tests/unit-tests/api/shipping-methods.php b/tests/unit-tests/api/shipping-methods.php
index ff23b7e9022..4c700cdfee8 100644
--- a/tests/unit-tests/api/shipping-methods.php
+++ b/tests/unit-tests/api/shipping-methods.php
@@ -132,5 +132,4 @@ class Shipping_Methods extends WC_REST_Unit_Test_Case {
$this->assertArrayHasKey( 'title', $properties );
$this->assertArrayHasKey( 'description', $properties );
}
-
}
diff --git a/tests/unit-tests/api/shipping-zones.php b/tests/unit-tests/api/shipping-zones.php
index 8c032759204..aab1a2c1c5d 100644
--- a/tests/unit-tests/api/shipping-zones.php
+++ b/tests/unit-tests/api/shipping-zones.php
@@ -32,7 +32,7 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
*/
public function tearDown() {
parent::tearDown();
- foreach( $this->zones as $zone ) {
+ foreach ( $this->zones as $zone ) {
$zone->delete();
}
}
@@ -296,6 +296,47 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
$this->assertEquals( 404, $response->get_status() );
}
+ /**
+ * Test Shipping Zone delete endpoint.
+ * @since 2.7.0
+ */
+ public function test_delete_shipping_zone() {
+ wp_set_current_user( $this->user );
+ $zone = $this->create_shipping_zone( 'Zone 1' );
+
+ $request = new WP_REST_Request( 'DELETE', '/wc/v1/shipping/zones/' . $zone->get_id() );
+ $request->set_param( 'force', true );
+ $response = $this->server->dispatch( $request );
+ $data = $response->get_data();
+
+ $this->assertEquals( 200, $response->get_status() );
+ }
+
+ /**
+ * Test Shipping Zone delete endpoint without permissions.
+ * @since 2.7.0
+ */
+ public function test_delete_shipping_zone_without_permission() {
+ wp_set_current_user( 0 );
+ $zone = $this->create_shipping_zone( 'Zone 1' );
+
+ $request = new WP_REST_Request( 'DELETE', '/wc/v1/shipping/zones/' . $zone->get_id() );
+ $request->set_param( 'force', true );
+ $response = $this->server->dispatch( $request );
+ $this->assertEquals( 401, $response->get_status() );
+ }
+
+ /**
+ * Test Shipping Zone delete endpoint with a bad zone ID.
+ * @since 2.7.0
+ */
+ public function test_delete_shipping_zone_invalid_id() {
+ wp_set_current_user( $this->user );
+ $request = new WP_REST_Request( 'DELETE', '/wc/v1/shipping/zones/0' );
+ $response = $this->server->dispatch( $request );
+ $this->assertEquals( 404, $response->get_status() );
+ }
+
/**
* Test getting a single Shipping Zone.
* @since 2.7.0
@@ -691,5 +732,4 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
$response = $this->server->dispatch( $request );
$this->assertEquals( 200, $response->get_status() );
}
-
}
diff --git a/tests/unit-tests/api/system-status.php b/tests/unit-tests/api/system-status.php
index ffb0ba2d834..428b1c77320 100644
--- a/tests/unit-tests/api/system-status.php
+++ b/tests/unit-tests/api/system-status.php
@@ -320,5 +320,4 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
$this->assertArrayHasKey( 'success', $properties );
$this->assertArrayHasKey( 'message', $properties );
}
-
}
diff --git a/tests/unit-tests/cart/cart.php b/tests/unit-tests/cart/cart.php
index d8ddc0f080e..bbc6270c867 100644
--- a/tests/unit-tests/cart/cart.php
+++ b/tests/unit-tests/cart/cart.php
@@ -71,7 +71,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
WC_Tax::_insert_tax_rate( $tax_rate );
$product = wc_get_product( $product->id );
@@ -90,7 +90,6 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
WC()->cart->remove_coupons();
WC_Helper_Product::delete_product( $product->id );
-
# Test case 3 #11626
update_post_meta( $coupon->get_id(), 'discount_type', 'percent' );
update_post_meta( $coupon->get_id(), 'coupon_amount', '50' );
@@ -106,13 +105,20 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
WC_Tax::_insert_tax_rate( $tax_rate );
$product_ids = array();
$products_data = array(
- '5.17', '3.32', '1.25', '3.50', '5.01', '3.34', '5.99', '5.51'
+ '5.17',
+ '3.32',
+ '1.25',
+ '3.50',
+ '5.01',
+ '3.34',
+ '5.99',
+ '5.51',
);
foreach ( $products_data as $price ) {
$loop_product = WC_Helper_Product::create_simple_product();
@@ -300,8 +306,8 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
'this',
'is',
'an',
- 'array'
- )
+ 'array',
+ ),
);
// Manually generate ID
@@ -582,5 +588,4 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
WC_Helper_Coupon::delete_coupon( $coupon->get_id() );
}
-
}
diff --git a/tests/unit-tests/coupon/coupon.php b/tests/unit-tests/coupon/coupon.php
index cee96253035..07430fc6aea 100644
--- a/tests/unit-tests/coupon/coupon.php
+++ b/tests/unit-tests/coupon/coupon.php
@@ -307,5 +307,4 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
// Delete product
WC_Helper_Product::delete_product( $product->id );
}
-
}
diff --git a/tests/unit-tests/coupon/crud.php b/tests/unit-tests/coupon/crud.php
index 024c768f40f..2986721b022 100644
--- a/tests/unit-tests/coupon/crud.php
+++ b/tests/unit-tests/coupon/crud.php
@@ -118,10 +118,26 @@ class WC_Tests_CouponCRUD extends WC_Unit_Test_Case {
// Accessing properties directly will throw some wanted deprected notices
// So we need to let PHPUnit know we are expecting them and it's fine to continue
$legacy_keys = array(
- 'id', 'exists', 'coupon_custom_fields', 'type', 'discount_type', 'amount', 'code',
- 'individual_use', 'product_ids', 'exclude_product_ids', 'usage_limit', 'usage_limit_per_user',
- 'limit_usage_to_x_items', 'usage_count', 'expiry_date', 'product_categories',
- 'exclude_product_categories', 'minimum_amount', 'maximum_amount', 'customer_email',
+ 'id',
+ 'exists',
+ 'coupon_custom_fields',
+ 'type',
+ 'discount_type',
+ 'amount',
+ 'code',
+ 'individual_use',
+ 'product_ids',
+ 'exclude_product_ids',
+ 'usage_limit',
+ 'usage_limit_per_user',
+ 'limit_usage_to_x_items',
+ 'usage_count',
+ 'expiry_date',
+ 'product_categories',
+ 'exclude_product_categories',
+ 'minimum_amount',
+ 'maximum_amount',
+ 'customer_email',
);
$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $legacy_keys );
@@ -144,7 +160,7 @@ class WC_Tests_CouponCRUD extends WC_Unit_Test_Case {
$this->assertEquals( $coupon->get_usage_limit_per_user(), $coupon->usage_limit_per_user );
$this->assertEquals( $coupon->get_limit_usage_to_x_items(), $coupon->limit_usage_to_x_items );
$this->assertEquals( $coupon->get_usage_count(), $coupon->usage_count );
- $this->assertEquals( $coupon->get_expiry_date(), $coupon->expiry_date );
+ $this->assertEquals( $coupon->get_date_expires(), $coupon->expiry_date );
$this->assertEquals( $coupon->get_product_categories(), $coupon->product_categories );
$this->assertEquals( $coupon->get_excluded_product_categories(), $coupon->exclude_product_categories );
$this->assertEquals( $coupon->get_minimum_amount(), $coupon->minimum_amount );
@@ -176,7 +192,7 @@ class WC_Tests_CouponCRUD extends WC_Unit_Test_Case {
'exclude_sale_items' => false,
'minimum_amount' => '',
'maximum_amount' => 100,
- 'customer_email' => ''
+ 'customer_email' => '',
) );
$this->assertEquals( $code, $coupon->get_code() );
$this->assertEquals( true, $coupon->get_individual_use() );
@@ -208,7 +224,7 @@ class WC_Tests_CouponCRUD extends WC_Unit_Test_Case {
'exclude_sale_items' => 'no',
'minimum_amount' => '',
'maximum_amount' => 100,
- 'customer_email' => ''
+ 'customer_email' => '',
) );
$this->assertEquals( $code, $coupon->get_code() );
$this->assertEquals( true, $coupon->get_individual_use() );
@@ -225,13 +241,26 @@ class WC_Tests_CouponCRUD extends WC_Unit_Test_Case {
public function test_coupon_getters_and_setters() {
$time = time();
$standard_getters_and_setters = array(
- 'code' => 'test', 'description' => 'hello world', 'discount_type' => 'percent_product',
- 'amount' => 10.50, 'expiry_date' => time(), 'usage_count' => 5, 'individual_use' => true,
- 'product_ids' => array( 5, 10 ), 'exclude_product_ids' => array( 2, 1 ), 'usage_limit' => 2,
- 'usage_limit_per_user' => 10, 'limit_usage_to_x_items' => 2, 'free_shipping' => true,
- 'product_categories' => array( 6 ), 'exclude_product_categories' => array( 8 ),
- 'exclude_sale_items' => true, 'minimum_amount' => 2, 'maximum_amount' => 1000,
- 'customer_email' => array( 'test@woo.local' ), 'used_by' => array( 1 ),
+ 'code' => 'test',
+ 'description' => 'hello world',
+ 'discount_type' => 'percent_product',
+ 'amount' => 10.50,
+ 'date_expires' => time(),
+ 'usage_count' => 5,
+ 'individual_use' => true,
+ 'product_ids' => array( 5, 10 ),
+ 'exclude_product_ids' => array( 2, 1 ),
+ 'usage_limit' => 2,
+ 'usage_limit_per_user' => 10,
+ 'limit_usage_to_x_items' => 2,
+ 'free_shipping' => true,
+ 'product_categories' => array( 6 ),
+ 'exclude_product_categories' => array( 8 ),
+ 'exclude_sale_items' => true,
+ 'minimum_amount' => 2,
+ 'maximum_amount' => 1000,
+ 'customer_email' => array( 'test@woo.local' ),
+ 'used_by' => array( 1 ),
);
$coupon = new WC_Coupon;
@@ -270,5 +299,4 @@ class WC_Tests_CouponCRUD extends WC_Unit_Test_Case {
$coupon->read( $coupon_id );
$this->assertEquals( $meta_value, $coupon->get_meta( 'my-custom-field' ) );
}
-
}
diff --git a/tests/unit-tests/coupon/functions.php b/tests/unit-tests/coupon/functions.php
index a91c03048f5..4bb00b89b25 100644
--- a/tests/unit-tests/coupon/functions.php
+++ b/tests/unit-tests/coupon/functions.php
@@ -18,7 +18,7 @@ class WC_Tests_Functions extends WC_Unit_Test_Case {
'fixed_cart' => __( 'Cart Discount', 'woocommerce' ),
'percent' => __( 'Cart % Discount', 'woocommerce' ),
'fixed_product' => __( 'Product Discount', 'woocommerce' ),
- 'percent_product' => __( 'Product % Discount', 'woocommerce' )
+ 'percent_product' => __( 'Product % Discount', 'woocommerce' ),
);
$this->assertEquals( $coupon_types, wc_get_coupon_types() );
@@ -61,5 +61,4 @@ class WC_Tests_Functions extends WC_Unit_Test_Case {
$this->assertEmpty( wc_get_coupon_code_by_id( 0 ) );
}
-
}
diff --git a/tests/unit-tests/crud/data.php b/tests/unit-tests/crud/data.php
index 67e6d2186aa..6081239754d 100644
--- a/tests/unit-tests/crud/data.php
+++ b/tests/unit-tests/crud/data.php
@@ -54,7 +54,7 @@ class WC_Tests_CRUD_Data extends WC_Unit_Test_Case {
$object = new WC_Mock_WC_Data();
$data_to_set = array(
'content' => 'I am a fish',
- 'bool_value' => true
+ 'bool_value' => true,
);
$result = $object->set_props( $data_to_set );
$this->assertFalse( is_wp_error( $result ) );
@@ -63,7 +63,7 @@ class WC_Tests_CRUD_Data extends WC_Unit_Test_Case {
$data_to_set = array(
'content' => 'I am also a fish',
- 'bool_value' => 'thisisinvalid'
+ 'bool_value' => 'thisisinvalid',
);
$result = $object->set_props( $data_to_set );
$this->assertTrue( is_wp_error( $result ) );
@@ -218,7 +218,6 @@ class WC_Tests_CRUD_Data extends WC_Unit_Test_Case {
WHERE post_id = %d ORDER BY meta_id
", $object_id ) );
-
$object->delete_meta_data( 'test_meta_key' );
$object->update_meta_data( 'test_meta_key_2', 'updated_value', $raw_metadata[1]->meta_id );
@@ -255,5 +254,4 @@ class WC_Tests_CRUD_Data extends WC_Unit_Test_Case {
$object->update_meta_data( 'test_field_0', 'another field 2' );
$this->assertEquals( 'val1', $object->get_meta( 'test_field_2' ) );
}
-
}
diff --git a/tests/unit-tests/customer/crud.php b/tests/unit-tests/customer/crud.php
index 9dedb3bf0de..04aa788c1c0 100644
--- a/tests/unit-tests/customer/crud.php
+++ b/tests/unit-tests/customer/crud.php
@@ -110,8 +110,6 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
/**
* Tests backwards compat / legacy handling.
- * @expectedDeprecated WC_Customer::is_vat_exempt
- * @expectedDeprecated WC_Customer::has_calculated_shipping
* @expectedDeprecated WC_Customer::get_default_country
* @expectedDeprecated WC_Customer::get_default_state
* @expectedDeprecated WC_Customer::is_paying_customer
@@ -123,10 +121,23 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
// Accessing properties directly will throw some wanted deprected notices
// So we need to let PHPUnit know we are expecting them and it's fine to continue
$legacy_keys = array(
- 'id', 'country', 'state', 'postcode', 'city', 'address', 'address_1', 'address_2',
- 'shipping_country', 'shipping_state', 'shipping_postcode', 'shipping_city',
- 'shipping_address', 'shipping_address_1', 'shipping_address_2',
- 'is_vat_exempt', 'calculated_shipping',
+ 'id',
+ 'country',
+ 'state',
+ 'postcode',
+ 'city',
+ 'address',
+ 'address_1',
+ 'address_2',
+ 'shipping_country',
+ 'shipping_state',
+ 'shipping_postcode',
+ 'shipping_city',
+ 'shipping_address',
+ 'shipping_address_1',
+ 'shipping_address_2',
+ 'is_vat_exempt',
+ 'calculated_shipping',
);
$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $legacy_keys );
@@ -149,17 +160,17 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
$this->assertEquals( $customer->get_shipping_address(), $customer->shipping_address_1 );
$this->assertEquals( $customer->get_shipping_address_2(), $customer->shipping_address_2 );
$this->assertEquals( $customer->get_is_vat_exempt(), $customer->is_vat_exempt );
- $this->assertEquals( $customer->get_calculated_shipping(), $customer->calculated_shipping );
+ $this->assertEquals( $customer->has_calculated_shipping(), $customer->calculated_shipping );
// Functions
$this->assertEquals( $customer->get_is_vat_exempt(), $customer->is_vat_exempt() );
- $this->assertEquals( $customer->get_calculated_shipping(), $customer->has_calculated_shipping() );
+ $this->assertEquals( $customer->has_calculated_shipping(), $customer->has_calculated_shipping() );
$default = wc_get_customer_default_location();
$this->assertEquals( $default['country'], $customer->get_default_country() );
$this->assertEquals( $default['state'], $customer->get_default_state() );
- $this->assertFalse( $customer->get_calculated_shipping() );
+ $this->assertFalse( $customer->has_calculated_shipping() );
$customer->calculated_shipping( true );
- $this->assertTrue( $customer->get_calculated_shipping() );
+ $this->assertTrue( $customer->has_calculated_shipping() );
$this->assertEquals( $customer->get_is_paying_customer(), $customer->is_paying_customer() );
}
@@ -170,13 +181,29 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
public function test_customer_setters_and_getters() {
$time = time();
$standard_getters_and_setters = array(
- 'username' => 'test', 'email' => 'test@woo.local', 'first_name' => 'Bob', 'last_name' => 'tester',
- 'role' => 'customer', 'date_created' => $time, 'date_modified' => $time, 'billing_postcode' => 11010,
- 'billing_city' => 'New York', 'billing_address' => '123 Main St.', 'billing_address_1' => '123 Main St.', 'billing_address_2' => 'Apt 2', 'billing_state' => 'NY',
- 'billing_country' => 'US', 'shipping_state' => 'NY', 'shipping_postcode' => 11011, 'shipping_city' =>
- 'New York', 'shipping_address' => '123 Main St.', 'shipping_address_1' => '123 Main St.',
- 'shipping_address_2' => 'Apt 2', 'is_vat_exempt' => true, 'calculated_shipping' => true,
- 'is_paying_customer' => true
+ 'username' => 'test',
+ 'email' => 'test@woo.local',
+ 'first_name' => 'Bob',
+ 'last_name' => 'tester',
+ 'role' => 'customer',
+ 'date_created' => $time,
+ 'date_modified' => $time,
+ 'billing_postcode' => 11010,
+ 'billing_city' => 'New York',
+ 'billing_address' => '123 Main St.',
+ 'billing_address_1' => '123 Main St.',
+ 'billing_address_2' => 'Apt 2',
+ 'billing_state' => 'NY',
+ 'billing_country' => 'US',
+ 'shipping_state' => 'NY',
+ 'shipping_postcode' => 11011,
+ 'shipping_city' => 'New York',
+ 'shipping_address' => '123 Main St.',
+ 'shipping_address_1' => '123 Main St.',
+ 'shipping_address_2' => 'Apt 2',
+ 'is_vat_exempt' => true,
+ 'calculated_shipping' => true,
+ 'is_paying_customer' => true,
);
$customer = new WC_Customer;
@@ -453,5 +480,4 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
$customer->read( $customer_id );
$this->assertEquals( $meta_value, $customer->get_meta( 'my-field' ) );
}
-
}
diff --git a/tests/unit-tests/formatting/functions.php b/tests/unit-tests/formatting/functions.php
index fbbcbf3386f..b372eeb847a 100644
--- a/tests/unit-tests/formatting/functions.php
+++ b/tests/unit-tests/formatting/functions.php
@@ -97,7 +97,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
array( 25.4, wc_get_dimension( 10, 'cm', 'in' ) ),
array( 914.4, wc_get_dimension( 10, 'cm', 'yd' ) ),
array( 393.7, wc_get_dimension( 10, 'in', 'm' ) ),
- array( 0.010936133, wc_get_dimension( 10, 'yd', 'mm' ) )
+ array( 0.010936133, wc_get_dimension( 10, 'yd', 'mm' ) ),
);
// restore default
@@ -313,7 +313,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
'pear' => 'grape',
'vegetables' => array(
'cucumber' => 'asparagus',
- )
+ ),
);
$a2 = array(
@@ -643,5 +643,4 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
$this->assertEquals( 'st.', wc_trim_string( 'string', 3, '.' ) );
$this->assertEquals( 'string¥', wc_trim_string( 'string¥', 7, '' ) );
}
-
}
diff --git a/tests/unit-tests/order/crud.php b/tests/unit-tests/order/crud.php
index 51c70c2bb3c..882b024194a 100644
--- a/tests/unit-tests/order/crud.php
+++ b/tests/unit-tests/order/crud.php
@@ -235,11 +235,11 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$object = new WC_Order();
$item_1 = new WC_Order_Item_Product( array(
'product' => $product,
- 'quantity' => 4
+ 'quantity' => 4,
) );
$item_2 = new WC_Order_Item_Product( array(
'product' => $product,
- 'quantity' => 2
+ 'quantity' => 2,
) );
$object->add_item( $item_1 );
@@ -257,11 +257,11 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$object = new WC_Order();
$item_1 = new WC_Order_Item_Product( array(
'product' => WC_Helper_Product::create_simple_product(),
- 'quantity' => 4
+ 'quantity' => 4,
) );
$item_2 = new WC_Order_Item_Product( array(
'product' => WC_Helper_Product::create_simple_product(),
- 'quantity' => 2
+ 'quantity' => 2,
) );
$object->add_item( $item_1 );
@@ -301,14 +301,14 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
WC_Tax::_insert_tax_rate( $tax_rate );
$object = new WC_Order();
$item_1 = new WC_Order_Item_Product( array(
'product' => WC_Helper_Product::create_simple_product(),
- 'quantity' => 4
+ 'quantity' => 4,
) );
$object->add_item( $item_1 );
$object->calculate_totals();
@@ -399,11 +399,11 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$object = new WC_Order();
$item_1 = new WC_Order_Item_Product( array(
'product' => WC_Helper_Product::create_simple_product(),
- 'quantity' => 4
+ 'quantity' => 4,
) );
$item_2 = new WC_Order_Item_Product( array(
'product' => WC_Helper_Product::create_simple_product(),
- 'quantity' => 2
+ 'quantity' => 2,
) );
$object->add_item( $item_1 );
@@ -419,7 +419,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$object = new WC_Order();
$item = new WC_Order_Item_Product( array(
'product' => WC_Helper_Product::create_simple_product(),
- 'quantity' => 4
+ 'quantity' => 4,
) );
$item_id = $item->save();
$object->add_item( $item_id );
@@ -508,7 +508,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
WC_Tax::_insert_tax_rate( $tax_rate );
@@ -549,7 +549,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
WC_Tax::_insert_tax_rate( $tax_rate );
@@ -1079,7 +1079,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
$object->set_shipping_state( 'Boulder' );
$object->set_shipping_postcode( '00001' );
$object->set_shipping_country( 'US' );
- $this->assertEquals( 'http://maps.google.com/maps?&q=Barney%2C+Rubble%2C+Bedrock+Ltd.%2C+34+Stonepants+avenue%2C+Rockville%2C+Bedrock%2C+Boulder%2C+00001%2C+US&z=16', $object->get_shipping_address_map_url() );
+ $this->assertEquals( 'https://maps.google.com/maps?&q=Barney%2C+Rubble%2C+Bedrock+Ltd.%2C+34+Stonepants+avenue%2C+Rockville%2C+Bedrock%2C+Boulder%2C+00001%2C+US&z=16', $object->get_shipping_address_map_url() );
}
/**
diff --git a/tests/unit-tests/order/functions.php b/tests/unit-tests/order/functions.php
index ad516a63739..ff183fa8edd 100644
--- a/tests/unit-tests/order/functions.php
+++ b/tests/unit-tests/order/functions.php
@@ -152,5 +152,4 @@ class WC_Tests_Order_Functions extends WC_Unit_Test_Case {
$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 9c7dd98057d..9df1371af37 100644
--- a/tests/unit-tests/payment-tokens/cc.php
+++ b/tests/unit-tests/payment-tokens/cc.php
@@ -96,5 +96,4 @@ class WC_Tests_Payment_Token_CC extends WC_Unit_Test_Case {
$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 7cd9142d32e..e59b1e6b70c 100644
--- a/tests/unit-tests/payment-tokens/echeck.php
+++ b/tests/unit-tests/payment-tokens/echeck.php
@@ -41,5 +41,4 @@ class WC_Tests_Payment_Token_eCheck extends WC_Unit_Test_Case {
$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 0d16fdc9e21..c130e72c3ec 100644
--- a/tests/unit-tests/payment-tokens/payment-token.php
+++ b/tests/unit-tests/payment-tokens/payment-token.php
@@ -162,5 +162,4 @@ class WC_Tests_Payment_Token extends WC_Unit_Test_Case {
$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 558bb37ae5d..8a745dc602d 100644
--- a/tests/unit-tests/payment-tokens/payment-tokens.php
+++ b/tests/unit-tests/payment-tokens/payment-tokens.php
@@ -177,5 +177,4 @@ class WC_Tests_Payment_Tokens extends WC_Unit_Test_Case {
$this->assertTrue( $token->is_default() );
$this->assertFalse( $token2->is_default() );
}
-
}
diff --git a/tests/unit-tests/product/functions.php b/tests/unit-tests/product/functions.php
index 7ea15a0d371..b616fc08ba2 100644
--- a/tests/unit-tests/product/functions.php
+++ b/tests/unit-tests/product/functions.php
@@ -121,7 +121,7 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
$sizes = array(
'shop_thumbnail' => array( 'width' => '180', 'height' => '180' ),
'shop_single' => array( 'width' => '600', 'height' => '600' ),
- 'shop_catalog' => array( 'width' => '300', 'height' => '300' )
+ 'shop_catalog' => array( 'width' => '300', 'height' => '300' ),
);
foreach ( $sizes as $size => $values ) {
@@ -143,7 +143,7 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
'simple' => __( 'Simple product', 'woocommerce' ),
'grouped' => __( 'Grouped product', 'woocommerce' ),
'external' => __( 'External/Affiliate product', 'woocommerce' ),
- 'variable' => __( 'Variable product', 'woocommerce' )
+ 'variable' => __( 'Variable product', 'woocommerce' ),
) );
$this->assertEquals( $product_types, wc_get_product_types() );
diff --git a/tests/unit-tests/shipping-zones/shipping-zone.php b/tests/unit-tests/shipping-zones/shipping-zone.php
index 26b36354229..d38a92fde21 100644
--- a/tests/unit-tests/shipping-zones/shipping-zone.php
+++ b/tests/unit-tests/shipping-zones/shipping-zone.php
@@ -254,24 +254,24 @@ class WC_Tests_Shipping_Zone extends WC_Unit_Test_Case {
$zone->set_locations( array(
array(
'code' => 'US',
- 'type' => 'country'
+ 'type' => 'country',
),
array(
'code' => '90210',
- 'type' => 'postcode'
- )
+ 'type' => 'postcode',
+ ),
) );
// Assert
$this->assertEquals( $zone->get_zone_locations(), array(
2 => (object) array(
'code' => 'US',
- 'type' => 'country'
+ 'type' => 'country',
),
3 => (object) array(
'code' => '90210',
- 'type' => 'postcode'
- )
+ 'type' => 'postcode',
+ ),
) );
// Clean
diff --git a/tests/unit-tests/shipping-zones/shipping-zones.php b/tests/unit-tests/shipping-zones/shipping-zones.php
index 4c19ef31013..5fd81d1ba14 100644
--- a/tests/unit-tests/shipping-zones/shipping-zones.php
+++ b/tests/unit-tests/shipping-zones/shipping-zones.php
@@ -119,28 +119,28 @@ class WC_Tests_Shipping_Zones extends WC_Unit_Test_Case {
'country' => 'GB',
'state' => 'Cambs',
'postcode' => 'CB23 1GG',
- )
+ ),
) );
$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(
'destination' => array(
'country' => 'US',
'state' => 'CA',
'postcode' => '90210',
- )
+ ),
) );
$zone4 = WC_Shipping_Zones::get_zone_matching_package( array(
'destination' => array(
'country' => 'US',
'state' => 'AL',
'postcode' => '12345',
- )
+ ),
) );
// Assert
diff --git a/tests/unit-tests/tax/tax.php b/tests/unit-tests/tax/tax.php
index 7c1713eb0fa..b20bce811a3 100644
--- a/tests/unit-tests/tax/tax.php
+++ b/tests/unit-tests/tax/tax.php
@@ -25,7 +25,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -56,7 +56,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -86,7 +86,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -116,7 +116,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -126,7 +126,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'state' => 'Cambs',
'postcode' => 'PE14 1XX',
'city' => 'Somewhere',
- 'tax_class' => ''
+ 'tax_class' => '',
) );
$this->assertEquals( $tax_rates, array( $tax_rate_id => array( 'rate' => '20.0000', 'label' => 'VAT', 'shipping' => 'yes', 'compound' => 'no' ) ) );
@@ -152,7 +152,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -162,7 +162,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'state' => 'Cambs',
'postcode' => 'PE14 1XX',
'city' => 'Somewhere',
- 'tax_class' => ''
+ 'tax_class' => '',
) );
$this->assertEquals( $tax_rates, array( $tax_rate_id => array( 'rate' => '20.0000', 'label' => 'VAT', 'shipping' => 'yes', 'compound' => 'no' ) ) );
@@ -188,7 +188,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -198,7 +198,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'state' => 'Cambs',
'postcode' => 'PE14 1XX',
'city' => 'Somewhere',
- 'tax_class' => ''
+ 'tax_class' => '',
) );
$calced_tax = WC_Tax::calc_tax( '9.99', $tax_rates, true, false );
@@ -233,7 +233,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_2 = array(
@@ -245,7 +245,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '1',
'tax_rate_shipping' => '1',
'tax_rate_order' => '2',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_1_id = WC_Tax::_insert_tax_rate( $tax_rate_1 );
@@ -256,7 +256,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'state' => 'QC',
'postcode' => '12345',
'city' => '',
- 'tax_class' => ''
+ 'tax_class' => '',
) );
// prices exclusive of tax
@@ -298,7 +298,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -308,7 +308,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'state' => 'Cambs',
'postcode' => 'PE14 1XX',
'city' => 'Somewhere',
- 'tax_class' => ''
+ 'tax_class' => '',
) );
$calced_tax = WC_Tax::calc_shipping_tax( '10', $tax_rates );
@@ -333,7 +333,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '1',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -358,7 +358,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '1',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -383,7 +383,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '1',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -408,7 +408,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '1',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_rate );
@@ -462,7 +462,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
// Run function
@@ -501,7 +501,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
// Run function
@@ -509,7 +509,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
// Update a rate
$tax_rate = array(
- 'tax_rate_country' => 'US'
+ 'tax_rate_country' => 'US',
);
// Run function
@@ -536,7 +536,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
// Run function
@@ -566,7 +566,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
// Run function
@@ -597,7 +597,7 @@ class WC_Tests_Tax extends WC_Unit_Test_Case {
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
- 'tax_rate_class' => ''
+ 'tax_rate_class' => '',
);
// Run function
diff --git a/tests/unit-tests/util/conditional-functions.php b/tests/unit-tests/util/conditional-functions.php
index 2c347d25f8d..89845f54956 100644
--- a/tests/unit-tests/util/conditional-functions.php
+++ b/tests/unit-tests/util/conditional-functions.php
@@ -61,7 +61,7 @@ class WC_Tests_Conditional_Functions extends WC_Unit_Test_Case {
array( false, wc_is_webhook_valid_topic( 'coupon.upgraded' ) ),
array( false, wc_is_webhook_valid_topic( 'wc.product.updated' ) ),
array( false, wc_is_webhook_valid_topic( 'missingdot' ) ),
- array( false, wc_is_webhook_valid_topic( 'with space' ) )
+ array( false, wc_is_webhook_valid_topic( 'with space' ) ),
);
}
@@ -93,7 +93,7 @@ class WC_Tests_Conditional_Functions extends WC_Unit_Test_Case {
array( true, wc_is_valid_url( 'https://google.com' ) ),
array( true, wc_is_valid_url( 'https://google.com/test%20valid' ) ),
array( true, wc_is_valid_url( 'https://google.com/test-valid/?query=test' ) ),
- array( true, wc_is_valid_url( 'https://google.com/test-valid/#hash' ) )
+ array( true, wc_is_valid_url( 'https://google.com/test-valid/#hash' ) ),
);
}
diff --git a/tests/unit-tests/util/install.php b/tests/unit-tests/util/install.php
index 116ba22c10f..2574b323ab8 100644
--- a/tests/unit-tests/util/install.php
+++ b/tests/unit-tests/util/install.php
@@ -115,5 +115,4 @@ class WC_Tests_Install extends WC_Unit_Test_Case {
$result = ob_get_clean();
$this->assertTrue( is_string( $result ) );
}
-
}
diff --git a/tests/unit-tests/util/notice-functions.php b/tests/unit-tests/util/notice-functions.php
index 3b43e314d85..8fced0aa696 100644
--- a/tests/unit-tests/util/notice-functions.php
+++ b/tests/unit-tests/util/notice-functions.php
@@ -181,5 +181,4 @@ class WC_Tests_Notice_Functions extends WC_Unit_Test_Case {
$this->assertInternalType( 'array', $notices );
$this->assertEmpty( $notices );
}
-
}
diff --git a/tests/unit-tests/util/validation.php b/tests/unit-tests/util/validation.php
index 6c05cff3b68..c4e6127561f 100644
--- a/tests/unit-tests/util/validation.php
+++ b/tests/unit-tests/util/validation.php
@@ -28,7 +28,7 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
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( false, WC_Validation::is_phone( '+00 aaa dd ee fff' ) ),
);
}
@@ -54,32 +54,32 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
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( 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( 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( 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( 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( false, WC_Validation::is_postcode( '99999-ABC', 'BR' ) ),
);
$ca = array(
@@ -89,7 +89,7 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
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( false, WC_Validation::is_postcode( '0A0A0A', 'CA' ) ),
);
return array_merge( $generic, $gb, $us, $ch, $br, $ca );
@@ -122,7 +122,7 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
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( false, WC_Validation::is_GB_postcode( '9A A9A' ) ),
);
}
@@ -148,7 +148,7 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
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( 'AB CDE', WC_Validation::format_postcode( 'abcde', 'CA' ) ),
);
}
diff --git a/woocommerce.php b/woocommerce.php
index bf3e2c721c0..a7a6b7b3e28 100644
--- a/woocommerce.php
+++ b/woocommerce.php
@@ -478,7 +478,7 @@ final class WooCommerce {
'fields' => 'ids',
'post_type' => 'shop_webhook',
'post_status' => 'publish',
- 'posts_per_page' => -1
+ 'posts_per_page' => -1,
) );
set_transient( 'woocommerce_webhook_ids', $webhooks );
}