diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 07172a9bfb1..00000000000
--- a/.jshintrc
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "boss": true,
- "curly": true,
- "eqeqeq": true,
- "eqnull": true,
- "es3": true,
- "expr": true,
- "immed": true,
- "noarg": true,
- "onevar": true,
- "quotmark": "single",
- "trailing": true,
- "undef": true,
- "unused": true,
- "multistr": true,
-
- "browser": true,
-
- "globals": {
- "_": false,
- "Backbone": false,
- "jQuery": false,
- "JSON": false,
- "wp": false
- }
-}
diff --git a/Dockerfile b/Dockerfile
index ef53cc1b22a..69aad6c6a65 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1 +1 @@
-FROM wordpress:5.4.0
+FROM wordpress:5.4.1
diff --git a/Gruntfile.js b/Gruntfile.js
index bb38d5151fc..0a8316eb8c9 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,4 +1,3 @@
-/* jshint node:true */
module.exports = function( grunt ) {
'use strict';
var sass = require( 'node-sass' );
@@ -14,12 +13,9 @@ module.exports = function( grunt ) {
php: 'includes'
},
- // JavaScript linting with JSHint.
- jshint: {
- options: {
- jshintrc: '.jshintrc'
- },
- all: [
+ // JavaScript linting with ESLint.
+ eslint: {
+ src: [
'<%= dirs.js %>/admin/*.js',
'!<%= dirs.js %>/admin/*.min.js',
'<%= dirs.js %>/frontend/*.js',
@@ -192,12 +188,13 @@ module.exports = function( grunt ) {
},
js: {
files: [
+ 'GruntFile.js',
'<%= dirs.js %>/admin/*js',
'<%= dirs.js %>/frontend/*js',
'!<%= dirs.js %>/admin/*.min.js',
'!<%= dirs.js %>/frontend/*.min.js'
],
- tasks: ['jshint', 'uglify']
+ tasks: ['eslint','uglify']
}
},
@@ -291,7 +288,7 @@ module.exports = function( grunt ) {
grunt.loadNpmTasks( 'grunt-rtlcss' );
grunt.loadNpmTasks( 'grunt-postcss' );
grunt.loadNpmTasks( 'grunt-stylelint' );
- grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+ grunt.loadNpmTasks( 'gruntify-eslint' );
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-concat' );
@@ -307,7 +304,7 @@ module.exports = function( grunt ) {
]);
grunt.registerTask( 'js', [
- 'jshint',
+ 'eslint',
'uglify:admin',
'uglify:frontend'
]);
diff --git a/assets/js/admin/api-keys.js b/assets/js/admin/api-keys.js
index 760e883be27..4a5c0dd7ceb 100644
--- a/assets/js/admin/api-keys.js
+++ b/assets/js/admin/api-keys.js
@@ -142,7 +142,9 @@
$( '#key_permissions', self.el ).val( data.permissions );
}
} else {
- $( 'h2, h3', self.el ).first().append( '
' + response.data.message + '
' );
+ $( 'h2, h3', self.el )
+ .first()
+ .append( '' + response.data.message + '
' );
}
self.unblock();
diff --git a/assets/js/admin/backbone-modal.js b/assets/js/admin/backbone-modal.js
index 7aa02f8a90f..63cca56422a 100644
--- a/assets/js/admin/backbone-modal.js
+++ b/assets/js/admin/backbone-modal.js
@@ -130,7 +130,10 @@
var button = e.keyCode || e.which;
// Enter key
- if ( 13 === button && ! ( e.target.tagName && ( e.target.tagName.toLowerCase() === 'input' || e.target.tagName.toLowerCase() === 'textarea' ) ) ) {
+ if (
+ 13 === button &&
+ ! ( e.target.tagName && ( e.target.tagName.toLowerCase() === 'input' || e.target.tagName.toLowerCase() === 'textarea' ) )
+ ) {
this.addButton( e );
}
diff --git a/assets/js/admin/meta-boxes-order.js b/assets/js/admin/meta-boxes-order.js
index 603ba14733f..3175beb5760 100644
--- a/assets/js/admin/meta-boxes-order.js
+++ b/assets/js/admin/meta-boxes-order.js
@@ -1,3 +1,4 @@
+// eslint-disable-next-line max-len
/*global woocommerce_admin_meta_boxes, woocommerce_admin, accounting, woocommerce_admin_meta_boxes_order, wcSetClipboard, wcClearClipboard */
jQuery( function ( $ ) {
@@ -11,7 +12,12 @@ jQuery( function ( $ ) {
var wc_meta_boxes_order = {
states: null,
init: function() {
- if ( ! ( typeof woocommerce_admin_meta_boxes_order === 'undefined' || typeof woocommerce_admin_meta_boxes_order.countries === 'undefined' ) ) {
+ if (
+ ! (
+ typeof woocommerce_admin_meta_boxes_order === 'undefined' ||
+ typeof woocommerce_admin_meta_boxes_order.countries === 'undefined'
+ )
+ ) {
/* State/Country select boxes */
this.states = $.parseJSON( woocommerce_admin_meta_boxes_order.countries.replace( /"/g, '"' ) );
}
@@ -380,11 +386,19 @@ jQuery( function ( $ ) {
$( 'input.line_tax', $row ).each( function() {
var $line_total_tax = $( this );
var tax_id = $line_total_tax.data( 'tax_id' );
- var unit_total_tax = accounting.unformat( $line_total_tax.attr( 'data-total_tax' ), woocommerce_admin.mon_decimal_point ) / o_qty;
+ var unit_total_tax = accounting.unformat(
+ $line_total_tax.attr( 'data-total_tax' ),
+ woocommerce_admin.mon_decimal_point
+ ) / o_qty;
var $line_subtotal_tax = $( 'input.line_subtotal_tax[data-tax_id="' + tax_id + '"]', $row );
- var unit_subtotal_tax = accounting.unformat( $line_subtotal_tax.attr( 'data-subtotal_tax' ), woocommerce_admin.mon_decimal_point ) / o_qty;
+ var unit_subtotal_tax = accounting.unformat(
+ $line_subtotal_tax.attr( 'data-subtotal_tax' ),
+ woocommerce_admin.mon_decimal_point
+ ) / o_qty;
var round_at_subtotal = 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal;
- var precision = woocommerce_admin_meta_boxes[ round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals' ];
+ var precision = woocommerce_admin_meta_boxes[
+ round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals'
+ ];
if ( 0 < unit_total_tax ) {
$line_total_tax.val(
@@ -877,7 +891,10 @@ jQuery( function ( $ ) {
$( '.refund input.refund_line_total' ).each(function( index, item ) {
if ( $( item ).closest( 'tr' ).data( 'order_item_id' ) ) {
- line_item_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = accounting.unformat( item.value, woocommerce_admin.mon_decimal_point );
+ line_item_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = accounting.unformat(
+ item.value,
+ woocommerce_admin.mon_decimal_point
+ );
}
});
@@ -889,7 +906,10 @@ jQuery( function ( $ ) {
line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ] = {};
}
- line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ][ tax_id ] = accounting.unformat( item.value, woocommerce_admin.mon_decimal_point );
+ line_item_tax_totals[ $( item ).closest( 'tr' ).data( 'order_item_id' ) ][ tax_id ] = accounting.unformat(
+ item.value,
+ woocommerce_admin.mon_decimal_point
+ );
}
});
@@ -1018,11 +1038,16 @@ jQuery( function ( $ ) {
var $refund_line_total_tax = $( this );
var tax_id = $refund_line_total_tax.data( 'tax_id' );
var line_total_tax = $( 'input.line_tax[data-tax_id="' + tax_id + '"]', $row );
- var unit_total_tax = accounting.unformat( line_total_tax.data( 'total_tax' ), woocommerce_admin.mon_decimal_point ) / qty;
+ var unit_total_tax = accounting.unformat(
+ line_total_tax.data( 'total_tax' ),
+ woocommerce_admin.mon_decimal_point
+ ) / qty;
if ( 0 < unit_total_tax ) {
var round_at_subtotal = 'yes' === woocommerce_admin_meta_boxes.round_at_subtotal;
- var precision = woocommerce_admin_meta_boxes[ round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals' ];
+ var precision = woocommerce_admin_meta_boxes[
+ round_at_subtotal ? 'rounding_precision' : 'currency_format_num_decimals'
+ ];
$refund_line_total_tax.val(
parseFloat( accounting.formatNumber( unit_total_tax * refund_qty, precision, '' ) )
@@ -1059,8 +1084,17 @@ jQuery( function ( $ ) {
var index = $items.find('tr').length + 1;
var $row = '' +
'' +
- '' +
- '' +
+ '' +
+ '' +
' | ' +
' | ' +
'
';
diff --git a/assets/js/admin/meta-boxes-product.js b/assets/js/admin/meta-boxes-product.js
index f21e2cc9ceb..efbae1dbf4d 100644
--- a/assets/js/admin/meta-boxes-product.js
+++ b/assets/js/admin/meta-boxes-product.js
@@ -476,7 +476,9 @@ jQuery( function( $ ) {
$( '.product_attributes .woocommerce_attribute' ).each( function( index, el ) {
if ( $( el ).css( 'display' ) !== 'none' && $( el ).is( '.taxonomy' ) ) {
- $( 'select.attribute_taxonomy' ).find( 'option[value="' + $( el ).data( 'taxonomy' ) + '"]' ).prop( 'disabled', true );
+ $( 'select.attribute_taxonomy' )
+ .find( 'option[value="' + $( el ).data( 'taxonomy' ) + '"]' )
+ .prop( 'disabled', true );
}
});
diff --git a/assets/js/admin/product-ordering.js b/assets/js/admin/product-ordering.js
index 9c2075eb5cd..c030871a48b 100644
--- a/assets/js/admin/product-ordering.js
+++ b/assets/js/admin/product-ordering.js
@@ -38,17 +38,24 @@ jQuery( function( $ ) {
var nextpostid = ui.item.next().find( '.check-column input' ).val();
// Show Spinner
- ui.item.find( '.check-column input' ).hide().after( '' );
+ ui.item
+ .find( '.check-column input' )
+ .hide()
+ .after( '' );
// Go do the sorting stuff via ajax
- $.post( ajaxurl, { action: 'woocommerce_product_ordering', id: postid, previd: prevpostid, nextid: nextpostid }, function( response ) {
- $.each( response, function( key, value ) {
- $( '#inline_' + key + ' .menu_order' ).html( value );
- });
- ui.item.find( '.check-column input' ).show().siblings( 'img' ).remove();
- $( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'move' );
- $( 'table.widefat tbody' ).sortable( 'enable' );
- });
+ $.post(
+ ajaxurl,
+ { action: 'woocommerce_product_ordering', id: postid, previd: prevpostid, nextid: nextpostid },
+ function( response ) {
+ $.each( response, function( key, value ) {
+ $( '#inline_' + key + ' .menu_order' ).html( value );
+ });
+ ui.item.find( '.check-column input' ).show().siblings( 'img' ).remove();
+ $( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'move' );
+ $( 'table.widefat tbody' ).sortable( 'enable' );
+ }
+ );
// fix cell colors
$( 'table.widefat tbody tr' ).each( function() {
diff --git a/assets/js/admin/quick-edit.js b/assets/js/admin/quick-edit.js
index 74f2f94c866..56bd651779d 100644
--- a/assets/js/admin/quick-edit.js
+++ b/assets/js/admin/quick-edit.js
@@ -45,6 +45,7 @@ jQuery(function( $ ) {
$( 'input[name="_stock"]', '.inline-edit-row' ).val( stock );
$( 'input[name="menu_order"]', '.inline-edit-row' ).val( menu_order );
+ // eslint-disable-next-line max-len
$( 'select[name="_tax_status"] option, select[name="_tax_class"] option, select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option' ).removeAttr( 'selected' );
$( 'select[name="_tax_status"] option[value="' + tax_status + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' );
diff --git a/assets/js/admin/reports.js b/assets/js/admin/reports.js
index 3173462e470..f419f16fc03 100644
--- a/assets/js/admin/reports.js
+++ b/assets/js/admin/reports.js
@@ -222,7 +222,13 @@ jQuery(function( $ ) {
csv_data += '"' + index + '",';
} else {
if ( groupby === 'day' ) {
- csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '-' + date.getUTCDate() + '",';
+ csv_data += '"' +
+ date.getUTCFullYear() +
+ '-' +
+ parseInt( date.getUTCMonth() + 1, 10 ) +
+ '-' +
+ date.getUTCDate() +
+ '",';
} else {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",';
}
diff --git a/assets/js/admin/settings-views-html-settings-tax.js b/assets/js/admin/settings-views-html-settings-tax.js
index 9d6793aa173..061c2bd1af7 100644
--- a/assets/js/admin/settings-views-html-settings-tax.js
+++ b/assets/js/admin/settings-views-html-settings-tax.js
@@ -165,7 +165,8 @@
minLength: 3
});
- // Postcode and city don't have `name` values by default. They're only created if the contents changes, to save on database queries (I think)
+ // Postcode and city don't have `name` values by default.
+ // They're only created if the contents changes, to save on database queries (I think)
this.$el.find( 'td.postcode input, td.city input' ).change( function() {
$( this ).attr( 'name', $( this ).data( 'name' ) );
});
@@ -232,7 +233,9 @@
reordered_rates = _.map( rates_to_reorder, function( rate ) {
rate.tax_rate_order++;
- changes[ rate.tax_rate_id ] = _.extend( changes[ rate.tax_rate_id ] || {}, { tax_rate_order : rate.tax_rate_order } );
+ changes[ rate.tax_rate_id ] = _.extend(
+ changes[ rate.tax_rate_id ] || {}, { tax_rate_order : rate.tax_rate_order }
+ );
return rate;
} );
} else {
diff --git a/assets/js/admin/term-ordering.js b/assets/js/admin/term-ordering.js
index 302f6854d6e..1a1a99d8d97 100644
--- a/assets/js/admin/term-ordering.js
+++ b/assets/js/admin/term-ordering.js
@@ -30,7 +30,13 @@ jQuery( function( $ ) {
};
$( document ).ajaxComplete( function( event, request, options ) {
- if ( request && 4 === request.readyState && 200 === request.status && options.data && ( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) ) ) {
+ if (
+ request &&
+ 4 === request.readyState &&
+ 200 === request.status &&
+ options.data &&
+ ( 0 <= options.data.indexOf( '_inline_edit' ) || 0 <= options.data.indexOf( 'add-tag' ) )
+ ) {
$.wc_add_missing_sort_handles();
$( document.body ).trigger( 'init_tooltips' );
}
@@ -80,25 +86,41 @@ jQuery( function( $ ) {
}
}
- // If previous and next not at same tree level, or next not at same tree level and the previous is the parent of the next, or just moved item beneath its own children
- if ( ( prevtermid === undefined && nexttermid === undefined ) || ( nexttermid === undefined && nexttermparent === prevtermid ) || ( nexttermid !== undefined && prevtermparent === termid ) ) {
+ // If previous and next not at same tree level, or next not at same tree level and
+ // the previous is the parent of the next, or just moved item beneath its own children.
+ if (
+ ( prevtermid === undefined && nexttermid === undefined ) ||
+ ( nexttermid === undefined && nexttermparent === prevtermid ) ||
+ ( nexttermid !== undefined && prevtermparent === termid )
+ ) {
$( table_selector ).sortable( 'cancel' );
return;
}
// Show Spinner
ui.item.find( '.check-column input' ).hide();
- ui.item.find( '.check-column' ).append( '' );
+ ui.item
+ .find( '.check-column' )
+ .append( '' );
- // Go do the sorting stuff via ajax
- $.post( ajaxurl, { action: 'woocommerce_term_ordering', id: termid, nextid: nexttermid, thetaxonomy: woocommerce_term_ordering_params.taxonomy }, function(response){
- if ( response === 'children' ) {
- window.location.reload();
- } else {
- ui.item.find( '.check-column input' ).show();
- ui.item.find( '.check-column' ).find( 'img' ).remove();
+ // Go do the sorting stuff via ajax.
+ $.post(
+ ajaxurl,
+ {
+ action: 'woocommerce_term_ordering',
+ id: termid,
+ nextid: nexttermid,
+ thetaxonomy: woocommerce_term_ordering_params.taxonomy
+ },
+ function(response) {
+ if ( response === 'children' ) {
+ window.location.reload();
+ } else {
+ ui.item.find( '.check-column input' ).show();
+ ui.item.find( '.check-column' ).find( 'img' ).remove();
+ }
}
- });
+ );
// Fix cell colors
$( 'table.widefat tbody tr' ).each( function() {
diff --git a/assets/js/admin/wc-product-import.js b/assets/js/admin/wc-product-import.js
index 0af872bcd8a..7ba790ed5e6 100644
--- a/assets/js/admin/wc-product-import.js
+++ b/assets/js/admin/wc-product-import.js
@@ -58,7 +58,15 @@
$this.$form.find('.woocommerce-importer-progress').val( response.data.percentage );
if ( 'done' === response.data.position ) {
- window.location = response.data.url + '&products-imported=' + parseInt( $this.imported, 10 ) + '&products-failed=' + parseInt( $this.failed, 10 ) + '&products-updated=' + parseInt( $this.updated, 10 ) + '&products-skipped=' + parseInt( $this.skipped, 10 );
+ window.location = response.data.url +
+ '&products-imported=' +
+ parseInt( $this.imported, 10 ) +
+ '&products-failed=' +
+ parseInt( $this.failed, 10 ) +
+ '&products-updated=' +
+ parseInt( $this.updated, 10 ) +
+ '&products-skipped=' +
+ parseInt( $this.skipped, 10 );
} else {
$this.run_import();
}
diff --git a/assets/js/admin/wc-shipping-zone-methods.js b/assets/js/admin/wc-shipping-zone-methods.js
index 813b7ebda9a..17289866132 100644
--- a/assets/js/admin/wc-shipping-zone-methods.js
+++ b/assets/js/admin/wc-shipping-zone-methods.js
@@ -34,11 +34,16 @@
this.trigger( 'change:methods' );
},
save: function() {
- $.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes', {
- wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
- changes : this.changes,
- zone_id : data.zone_id
- }, this.onSaveResponse, 'json' );
+ $.post(
+ ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_changes',
+ {
+ wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
+ changes : this.changes,
+ zone_id : data.zone_id
+ },
+ this.onSaveResponse,
+ 'json'
+ );
},
onSaveResponse: function( response, textStatus ) {
if ( 'success' === textStatus ) {
@@ -46,7 +51,11 @@
if ( response.data.zone_id !== data.zone_id ) {
data.zone_id = response.data.zone_id;
if ( window.history.pushState ) {
- window.history.pushState({}, '', 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id );
+ window.history.pushState(
+ {},
+ '',
+ 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id
+ );
}
}
shippingMethod.set( 'methods', response.data.methods );
@@ -72,7 +81,12 @@
$( window ).on( 'beforeunload', { view: this }, this.unloadConfirmation );
$save_button.on( 'click', { view: this }, this.onSubmit );
- $( document.body ).on( 'input change', '#zone_name, #zone_locations, #zone_postcodes', { view: this }, this.onUpdateZone );
+ $( document.body ).on(
+ 'input change',
+ '#zone_name, #zone_locations, #zone_postcodes',
+ { view: this },
+ this.onUpdateZone
+ );
$( document.body ).on( 'click', '.wc-shipping-zone-method-settings', { view: this }, this.onConfigureShippingMethod );
$( document.body ).on( 'click', '.wc-shipping-zone-add-method', { view: this }, this.onAddShippingMethod );
$( document.body ).on( 'wc_backbone_modal_response', this.onConfigureShippingMethodSubmitted );
@@ -128,9 +142,13 @@
// Populate $tbody with the current methods
$.each( methods, function( id, rowData ) {
if ( 'yes' === rowData.enabled ) {
- rowData.enabled_icon = '' + data.strings.yes + '';
+ rowData.enabled_icon = '' +
+ data.strings.yes +
+ '';
} else {
- rowData.enabled_icon = '' + data.strings.no + '';
+ rowData.enabled_icon = '' +
+ data.strings.no +
+ '';
}
view.$el.append( view.rowTemplate( rowData ) );
@@ -138,7 +156,9 @@
var $tr = view.$el.find( 'tr[data-id="' + rowData.instance_id + '"]');
if ( ! rowData.has_settings ) {
- $tr.find( '.wc-shipping-zone-method-title > a' ).replaceWith('' + $tr.find( '.wc-shipping-zone-method-title > a' ).text() + '' );
+ $tr
+ .find( '.wc-shipping-zone-method-title > a' )
+ .replaceWith('' + $tr.find( '.wc-shipping-zone-method-title > a' ).text() + '' );
var $del = $tr.find( '.wc-shipping-zone-method-delete' );
$tr.find( '.wc-shipping-zone-method-title .row-actions' ).empty().html($del);
}
@@ -241,7 +261,9 @@
if ( old_position !== new_position ) {
methods[ method.instance_id ].method_order = new_position;
changes.methods = changes.methods || { methods : {} };
- changes.methods[ method.instance_id ] = _.extend( changes.methods[ method.instance_id ] || {}, { method_order : new_position } );
+ changes.methods[ method.instance_id ] = _.extend(
+ changes.methods[ method.instance_id ] || {}, { method_order : new_position }
+ );
}
} );
@@ -281,30 +303,35 @@
shippingMethodView.block();
// Save method settings via ajax call
- $.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_settings', {
- wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
- instance_id : posted_data.instance_id,
- data : posted_data
- }, function( response, textStatus ) {
- if ( 'success' === textStatus && response.success ) {
- $( 'table.wc-shipping-zone-methods' ).parent().find( '#woocommerce_errors' ).remove();
+ $.post(
+ ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_methods_save_settings',
+ {
+ wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
+ instance_id : posted_data.instance_id,
+ data : posted_data
+ },
+ function( response, textStatus ) {
+ if ( 'success' === textStatus && response.success ) {
+ $( 'table.wc-shipping-zone-methods' ).parent().find( '#woocommerce_errors' ).remove();
- // If there were errors, prepend the form.
- if ( response.data.errors.length > 0 ) {
- shippingMethodView.showErrors( response.data.errors );
- }
+ // If there were errors, prepend the form.
+ if ( response.data.errors.length > 0 ) {
+ shippingMethodView.showErrors( response.data.errors );
+ }
- // Method was saved. Re-render.
- if ( _.size( shippingMethodView.model.changes ) ) {
- shippingMethodView.model.save();
+ // Method was saved. Re-render.
+ if ( _.size( shippingMethodView.model.changes ) ) {
+ shippingMethodView.model.save();
+ } else {
+ shippingMethodView.model.onSaveResponse( response, textStatus );
+ }
} else {
- shippingMethodView.model.onSaveResponse( response, textStatus );
+ window.alert( data.strings.save_failed );
+ shippingMethodView.unblock();
}
- } else {
- window.alert( data.strings.save_failed );
- shippingMethodView.unblock();
- }
- }, 'json' );
+ },
+ 'json'
+ );
}
},
showErrors: function( errors ) {
@@ -343,7 +370,11 @@
if ( response.data.zone_id !== data.zone_id ) {
data.zone_id = response.data.zone_id;
if ( window.history.pushState ) {
- window.history.pushState({}, '', 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id );
+ window.history.pushState(
+ {},
+ '',
+ 'admin.php?page=wc-settings&tab=shipping&zone_id=' + response.data.zone_id
+ );
}
}
// Trigger save if there are changes, or just re-render
diff --git a/assets/js/admin/wc-shipping-zones.js b/assets/js/admin/wc-shipping-zones.js
index 79026f2d964..093170a1ca9 100644
--- a/assets/js/admin/wc-shipping-zones.js
+++ b/assets/js/admin/wc-shipping-zones.js
@@ -161,7 +161,9 @@
class_name = 'method_enabled';
}
- $method_list.append( '' + shipping_method.title + '' );
+ $method_list.append(
+ '' + shipping_method.title + ''
+ );
} );
} else {
$method_list.append( '' + data.strings.no_shipping_methods_offered + '' );
diff --git a/assets/js/admin/woocommerce_admin.js b/assets/js/admin/woocommerce_admin.js
index 51351a52839..5070f3f5508 100644
--- a/assets/js/admin/woocommerce_admin.js
+++ b/assets/js/admin/woocommerce_admin.js
@@ -12,10 +12,22 @@
if ( 0 === $blankslate.length ) {
if ( woocommerce_admin.urls.export_products ) {
- $title_action.after('' + woocommerce_admin.strings.export_products + '');
+ $title_action.after(
+ '' +
+ woocommerce_admin.strings.export_products +
+ ''
+ );
}
if ( woocommerce_admin.urls.import_products ) {
- $title_action.after( '' + woocommerce_admin.strings.import_products + '' );
+ $title_action.after(
+ '' +
+ woocommerce_admin.strings.import_products +
+ ''
+ );
}
} else {
$title_action.hide();
@@ -60,70 +72,85 @@
$( '.wc_error_tip' ).fadeOut( '100', function() { $( this ).remove(); } );
})
- .on( 'change', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]', function() {
- var regex, decimalRegex,
- decimailPoint = woocommerce_admin.decimal_point;
+ .on(
+ 'change',
+ '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]',
+ function() {
+ var regex, decimalRegex,
+ decimailPoint = woocommerce_admin.decimal_point;
- if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
- decimailPoint = woocommerce_admin.mon_decimal_point;
+ if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
+ decimailPoint = woocommerce_admin.mon_decimal_point;
+ }
+
+ regex = new RegExp( '[^\-0-9\%\\' + decimailPoint + ']+', 'gi' );
+ decimalRegex = new RegExp( '\\' + decimailPoint + '+', 'gi' );
+
+ var value = $( this ).val();
+ var newvalue = value.replace( regex, '' ).replace( decimalRegex, decimailPoint );
+
+ if ( value !== newvalue ) {
+ $( this ).val( newvalue );
+ }
}
+ )
- regex = new RegExp( '[^\-0-9\%\\' + decimailPoint + ']+', 'gi' );
- decimalRegex = new RegExp( '\\' + decimailPoint + '+', 'gi' );
+ .on(
+ 'keyup',
+ // eslint-disable-next-line max-len
+ '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]',
+ function() {
+ var regex, error, decimalRegex;
+ var checkDecimalNumbers = false;
- var value = $( this ).val();
- var newvalue = value.replace( regex, '' ).replace( decimalRegex, decimailPoint );
+ if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
+ checkDecimalNumbers = true;
+ regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
+ decimalRegex = new RegExp( '[^\\' + woocommerce_admin.mon_decimal_point + ']', 'gi' );
+ error = 'i18n_mon_decimal_error';
+ } else if ( $( this ).is( '.wc_input_country_iso' ) ) {
+ regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
+ error = 'i18n_country_iso_error';
+ } else {
+ checkDecimalNumbers = true;
+ regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
+ decimalRegex = new RegExp( '[^\\' + woocommerce_admin.decimal_point + ']', 'gi' );
+ error = 'i18n_decimal_error';
+ }
- if ( value !== newvalue ) {
- $( this ).val( newvalue );
+ var value = $( this ).val();
+ var newvalue = value.replace( regex, '' );
+
+ // Check if newvalue have more than one decimal point.
+ if ( checkDecimalNumbers && 1 < newvalue.replace( decimalRegex, '' ).length ) {
+ newvalue = newvalue.replace( decimalRegex, '' );
+ }
+
+ if ( value !== newvalue ) {
+ $( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
+ } else {
+ $( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
+ }
}
- })
-
- .on( 'keyup', '.wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]', function() {
- var regex, error, decimalRegex;
- var checkDecimalNumbers = false;
-
- if ( $( this ).is( '.wc_input_price' ) || $( this ).is( '#refund_amount' ) ) {
- checkDecimalNumbers = true;
- regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.mon_decimal_point + ']+', 'gi' );
- decimalRegex = new RegExp( '[^\\' + woocommerce_admin.mon_decimal_point + ']', 'gi' );
- error = 'i18n_mon_decimal_error';
- } else if ( $( this ).is( '.wc_input_country_iso' ) ) {
- regex = new RegExp( '([^A-Z])+|(.){3,}', 'im' );
- error = 'i18n_country_iso_error';
- } else {
- checkDecimalNumbers = true;
- regex = new RegExp( '[^\-0-9\%\\' + woocommerce_admin.decimal_point + ']+', 'gi' );
- decimalRegex = new RegExp( '[^\\' + woocommerce_admin.decimal_point + ']', 'gi' );
- error = 'i18n_decimal_error';
- }
-
- var value = $( this ).val();
- var newvalue = value.replace( regex, '' );
-
- // Check if newvalue have more than one decimal point.
- if ( checkDecimalNumbers && 1 < newvalue.replace( decimalRegex, '' ).length ) {
- newvalue = newvalue.replace( decimalRegex, '' );
- }
-
- if ( value !== newvalue ) {
- $( document.body ).triggerHandler( 'wc_add_error_tip', [ $( this ), error ] );
- } else {
- $( document.body ).triggerHandler( 'wc_remove_error_tip', [ $( this ), error ] );
- }
- })
+ )
.on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() {
var sale_price_field = $( this ), regular_price_field;
if ( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
- regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' );
+ regular_price_field = sale_price_field
+ .parents( '.variable_pricing' )
+ .find( '.wc_input_price[name^=variable_regular_price]' );
} else {
regular_price_field = $( '#_regular_price' );
}
- var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) );
- var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
+ var sale_price = parseFloat(
+ window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point )
+ );
+ var regular_price = parseFloat(
+ window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point )
+ );
if ( sale_price >= regular_price ) {
$( this ).val( '' );
@@ -134,13 +161,19 @@
var sale_price_field = $( this ), regular_price_field;
if ( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) {
- regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' );
+ regular_price_field = sale_price_field
+ .parents( '.variable_pricing' )
+ .find( '.wc_input_price[name^=variable_regular_price]' );
} else {
regular_price_field = $( '#_regular_price' );
}
- var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) );
- var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) );
+ var sale_price = parseFloat(
+ window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point )
+ );
+ var regular_price = parseFloat(
+ window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point )
+ );
if ( sale_price >= regular_price ) {
$( document.body ).triggerHandler( 'wc_add_error_tip', [ $(this), 'i18n_sale_less_than_regular_error' ] );
@@ -236,9 +269,13 @@
if ( $( 'tr.last_selected', $this_table ).length > 0 ) {
if ( $this_row.index() > $( 'tr.last_selected', $this_table ).index() ) {
- $( 'tr', $this_table ).slice( $( 'tr.last_selected', $this_table ).index(), $this_row.index() ).addClass( 'current' );
+ $( 'tr', $this_table )
+ .slice( $( 'tr.last_selected', $this_table ).index(), $this_row.index() )
+ .addClass( 'current' );
} else {
- $( 'tr', $this_table ).slice( $this_row.index(), $( 'tr.last_selected', $this_table ).index() + 1 ).addClass( 'current' );
+ $( 'tr', $this_table )
+ .slice( $this_row.index(), $( 'tr.last_selected', $this_table ).index() + 1 )
+ .addClass( 'current' );
}
}
@@ -260,7 +297,8 @@
});
// Additional cost and Attribute term tables
- $( '.woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' );
+ $( '.woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)' )
+ .addClass( 'alternate' );
// Show order items on orders page
$( document.body ).on( 'click', '.show_order_items', function() {
@@ -281,9 +319,15 @@
$( '.hide_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) {
- $( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide();
+ $( this )
+ .closest( 'fieldset, tr' )
+ .nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
+ .hide();
} else {
- $( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show();
+ $( this )
+ .closest( 'fieldset, tr' )
+ .nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
+ .show();
}
}).change();
});
@@ -291,9 +335,15 @@
$( '.show_options_if_checked' ).each( function() {
$( this ).find( 'input:eq(0)' ).change( function() {
if ( $( this ).is( ':checked' ) ) {
- $( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).show();
+ $( this )
+ .closest( 'fieldset, tr' )
+ .nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
+ .show();
} else {
- $( this ).closest( 'fieldset, tr' ).nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' ).hide();
+ $( this )
+ .closest( 'fieldset, tr' )
+ .nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
+ .hide();
}
}).change();
});
diff --git a/assets/js/frontend/add-to-cart-variation.js b/assets/js/frontend/add-to-cart-variation.js
index ffc851b544f..9c0a7b77e5e 100644
--- a/assets/js/frontend/add-to-cart-variation.js
+++ b/assets/js/frontend/add-to-cart-variation.js
@@ -72,8 +72,14 @@
*/
VariationForm.prototype.onHide = function( event ) {
event.preventDefault();
- event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'wc-variation-is-unavailable' ).addClass( 'disabled wc-variation-selection-needed' );
- event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-enabled' ).addClass( 'woocommerce-variation-add-to-cart-disabled' );
+ event.data.variationForm.$form
+ .find( '.single_add_to_cart_button' )
+ .removeClass( 'wc-variation-is-unavailable' )
+ .addClass( 'disabled wc-variation-selection-needed' );
+ event.data.variationForm.$form
+ .find( '.woocommerce-variation-add-to-cart' )
+ .removeClass( 'woocommerce-variation-add-to-cart-enabled' )
+ .addClass( 'woocommerce-variation-add-to-cart-disabled' );
};
/**
@@ -82,11 +88,22 @@
VariationForm.prototype.onShow = function( event, variation, purchasable ) {
event.preventDefault();
if ( purchasable ) {
- event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'disabled wc-variation-selection-needed wc-variation-is-unavailable' );
- event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-disabled' ).addClass( 'woocommerce-variation-add-to-cart-enabled' );
+ event.data.variationForm.$form
+ .find( '.single_add_to_cart_button' )
+ .removeClass( 'disabled wc-variation-selection-needed wc-variation-is-unavailable' );
+ event.data.variationForm.$form
+ .find( '.woocommerce-variation-add-to-cart' )
+ .removeClass( 'woocommerce-variation-add-to-cart-disabled' )
+ .addClass( 'woocommerce-variation-add-to-cart-enabled' );
} else {
- event.data.variationForm.$form.find( '.single_add_to_cart_button' ).removeClass( 'wc-variation-selection-needed' ).addClass( 'disabled wc-variation-is-unavailable' );
- event.data.variationForm.$form.find( '.woocommerce-variation-add-to-cart' ).removeClass( 'woocommerce-variation-add-to-cart-enabled' ).addClass( 'woocommerce-variation-add-to-cart-disabled' );
+ event.data.variationForm.$form
+ .find( '.single_add_to_cart_button' )
+ .removeClass( 'wc-variation-selection-needed' )
+ .addClass( 'disabled wc-variation-is-unavailable' );
+ event.data.variationForm.$form
+ .find( '.woocommerce-variation-add-to-cart' )
+ .removeClass( 'woocommerce-variation-add-to-cart-enabled' )
+ .addClass( 'woocommerce-variation-add-to-cart-disabled' );
}
// If present, the media element library needs initialized on the variation description.
@@ -123,8 +140,12 @@
VariationForm.prototype.onResetDisplayedVariation = function( event ) {
var form = event.data.variationForm;
form.$product.find( '.product_meta' ).find( '.sku' ).wc_reset_content();
- form.$product.find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' ).wc_reset_content();
- form.$product.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' ).wc_reset_content();
+ form.$product
+ .find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' )
+ .wc_reset_content();
+ form.$product
+ .find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' )
+ .wc_reset_content();
form.$form.trigger( 'reset_image' );
form.$singleVariation.slideUp( 200 ).trigger( 'hide_variation' );
};
@@ -164,7 +185,13 @@
attributes.chosenCount = 0;
if ( ! form.loading ) {
- form.$form.find( '.single_variation' ).after( '' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '
' );
+ form.$form
+ .find( '.single_variation' )
+ .after(
+ '' +
+ wc_add_to_cart_variation_params.i18n_no_matching_variations_text +
+ '
'
+ );
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
}
}
@@ -186,7 +213,13 @@
attributes.chosenCount = 0;
if ( ! form.loading ) {
- form.$form.find( '.single_variation' ).after( '' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '
' );
+ form.$form
+ .find( '.single_variation' )
+ .after(
+ '' +
+ wc_add_to_cart_variation_params.i18n_no_matching_variations_text +
+ '
'
+ );
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
}
}
@@ -206,8 +239,12 @@
VariationForm.prototype.onFoundVariation = function( event, variation ) {
var form = event.data.variationForm,
$sku = form.$product.find( '.product_meta' ).find( '.sku' ),
- $weight = form.$product.find( '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value' ),
- $dimensions = form.$product.find( '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value' ),
+ $weight = form.$product.find(
+ '.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value'
+ ),
+ $dimensions = form.$product.find(
+ '.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value'
+ ),
$qty = form.$singleVariationWrap.find( '.quantity' ),
purchasable = true,
variation_id = '',
@@ -333,7 +370,11 @@
refSelect.find( 'option' ).removeAttr( 'disabled attached' ).removeAttr( 'selected' );
- current_attr_select.data( 'attribute_options', refSelect.find( 'option' + option_gt_filter ).get() ); // Legacy data attribute.
+ // Legacy data attribute.
+ current_attr_select.data(
+ 'attribute_options',
+ refSelect.find( 'option' + option_gt_filter ).get()
+ );
current_attr_select.data( 'attribute_html', refSelect.html() );
}
@@ -597,7 +638,9 @@
$product_gallery = $product.find( '.images' ),
$gallery_nav = $product.find( '.flex-control-nav' ),
$gallery_img = $gallery_nav.find( 'li:eq(0) img' ),
- $product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ),
+ $product_img_wrap = $product_gallery
+ .find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' )
+ .eq( 0 ),
$product_img = $product_img_wrap.find( '.wp-post-image' ),
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );
@@ -658,7 +701,9 @@
$product_gallery = $product.find( '.images' ),
$gallery_nav = $product.find( '.flex-control-nav' ),
$gallery_img = $gallery_nav.find( 'li:eq(0) img' ),
- $product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ),
+ $product_img_wrap = $product_gallery
+ .find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' )
+ .eq( 0 ),
$product_img = $product_img_wrap.find( '.wp-post-image' ),
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );
diff --git a/assets/js/frontend/cart.js b/assets/js/frontend/cart.js
index 816863ed454..ec1d843d31d 100644
--- a/assets/js/frontend/cart.js
+++ b/assets/js/frontend/cart.js
@@ -134,7 +134,9 @@ jQuery( function( $ ) {
*/
var show_notice = function( html_element, $target ) {
if ( ! $target ) {
- $target = $( '.woocommerce-notices-wrapper:first' ) || $( '.cart-empty' ).closest( '.woocommerce' ) || $( '.woocommerce-cart-form' );
+ $target = $( '.woocommerce-notices-wrapper:first' ) ||
+ $( '.cart-empty' ).closest( '.woocommerce' ) ||
+ $( '.woocommerce-cart-form' );
}
$target.prepend( html_element );
};
@@ -188,6 +190,7 @@ jQuery( function( $ ) {
shipping_method_selected: function() {
var shipping_methods = {};
+ // eslint-disable-next-line max-len
$( 'select.shipping_method, :input[name^=shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]' ).each( function() {
shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
} );
diff --git a/assets/js/frontend/tokenization-form.js b/assets/js/frontend/tokenization-form.js
index 15e9054b7c4..3a5a8bffbad 100644
--- a/assets/js/frontend/tokenization-form.js
+++ b/assets/js/frontend/tokenization-form.js
@@ -22,7 +22,12 @@ jQuery( function( $ ) {
this.hideSaveNewCheckbox = this.hideSaveNewCheckbox.bind( this );
// When a radio button is changed, make sure to show/hide our new CC info area.
- this.$target.on( 'click change', ':input.woocommerce-SavedPaymentMethods-tokenInput', { tokenizationForm: this }, this.onTokenChange );
+ this.$target.on(
+ 'click change',
+ ':input.woocommerce-SavedPaymentMethods-tokenInput',
+ { tokenizationForm: this },
+ this.onTokenChange
+ );
// OR if create account is checked.
$( 'input#createaccount' ).change( { tokenizationForm: this }, this.onCreateAccountChange );
diff --git a/composer.json b/composer.json
index 524a1c25785..302aa695b70 100644
--- a/composer.json
+++ b/composer.json
@@ -43,6 +43,11 @@
"Automattic\\WooCommerce\\": "src/"
}
},
+ "autoload-dev": {
+ "psr-4": {
+ "Automattic\\WooCommerce\\Tests\\": "tests/php/"
+ }
+ },
"scripts": {
"post-install-cmd": [
"sh ./bin/package-update.sh"
diff --git a/includes/admin/helper/class-wc-helper-api.php b/includes/admin/helper/class-wc-helper-api.php
index d47b64395c9..e1baf489000 100644
--- a/includes/admin/helper/class-wc-helper-api.php
+++ b/includes/admin/helper/class-wc-helper-api.php
@@ -97,10 +97,11 @@ class WC_Helper_API {
$args['headers'] = array();
}
- $args['headers'] = array(
+ $headers = array(
'Authorization' => 'Bearer ' . $auth['access_token'],
'X-Woo-Signature' => $signature,
);
+ $args['headers'] = wp_parse_args( $headers, $args['headers'] );
$url = add_query_arg(
array(
@@ -139,6 +140,19 @@ class WC_Helper_API {
return self::request( $endpoint, $args );
}
+ /**
+ * Wrapper for self::request().
+ *
+ * @param string $endpoint The helper API endpoint to request.
+ * @param array $args Arguments passed to wp_remote_request().
+ *
+ * @return array The response object from wp_safe_remote_request().
+ */
+ public static function put( $endpoint, $args = array() ) {
+ $args['method'] = 'PUT';
+ return self::request( $endpoint, $args );
+ }
+
/**
* Using the API base, form a request URL from a given endpoint.
*
diff --git a/package-lock.json b/package-lock.json
index b9814a8ead2..3b8dea73e41 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7216,16 +7216,6 @@
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==",
"dev": true
},
- "cli": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz",
- "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=",
- "dev": true,
- "requires": {
- "exit": "0.1.2",
- "glob": "^7.1.1"
- }
- },
"cli-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
@@ -7494,9 +7484,9 @@
"dev": true
},
"compare-versions": {
- "version": "3.5.1",
- "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.5.1.tgz",
- "integrity": "sha512-9fGPIB7C6AyM18CJJBHt5EnCZDG3oiTJYy0NjfIAGjKpzv0tkxWko7TNQHF5ymqm7IH03tqmeuBxtvD+Izh6mg==",
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz",
+ "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==",
"dev": true
},
"component-emitter": {
@@ -7533,13 +7523,10 @@
}
},
"console-browserify": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
- "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=",
- "dev": true,
- "requires": {
- "date-now": "^0.1.4"
- }
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz",
+ "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==",
+ "dev": true
},
"console-control-strings": {
"version": "1.1.0",
@@ -7865,12 +7852,6 @@
"integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==",
"dev": true
},
- "date-now": {
- "version": "0.1.4",
- "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
- "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=",
- "dev": true
- },
"dateformat": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz",
@@ -8368,12 +8349,6 @@
}
}
},
- "entities": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz",
- "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=",
- "dev": true
- },
"errno": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
@@ -10571,17 +10546,6 @@
"maxmin": "^2.1.0"
}
},
- "grunt-contrib-jshint": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/grunt-contrib-jshint/-/grunt-contrib-jshint-2.1.0.tgz",
- "integrity": "sha512-65S2/C/6RfjY/umTxfwXXn+wVvaYmykHkHSsW6Q6rhkbv3oudTEgqnFFZvWzWCoHUb+3GMZLbP3oSrNyvshmIQ==",
- "dev": true,
- "requires": {
- "chalk": "^2.4.2",
- "hooker": "^0.2.3",
- "jshint": "~2.10.2"
- }
- },
"grunt-contrib-uglify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-4.0.1.tgz",
@@ -10949,6 +10913,190 @@
"chalk": "^2.4.2"
}
},
+ "gruntify-eslint": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/gruntify-eslint/-/gruntify-eslint-5.0.0.tgz",
+ "integrity": "sha512-pa2sXHK9+U4dCGdGSIMkpJARNwRStdLBsddNxmSHSSWROUdhWMrXvFWm6pj48zJhyV3Qy068VIuF1seYIvc0cw==",
+ "dev": true,
+ "requires": {
+ "eslint": "^5.0.0"
+ },
+ "dependencies": {
+ "acorn": {
+ "version": "6.4.1",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
+ "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==",
+ "dev": true
+ },
+ "ansi-regex": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
+ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
+ "dev": true
+ },
+ "cli-cursor": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
+ "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",
+ "dev": true,
+ "requires": {
+ "restore-cursor": "^2.0.0"
+ }
+ },
+ "debug": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+ "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
+ "dev": true,
+ "requires": {
+ "ms": "^2.1.1"
+ }
+ },
+ "eslint": {
+ "version": "5.16.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz",
+ "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.0.0",
+ "ajv": "^6.9.1",
+ "chalk": "^2.1.0",
+ "cross-spawn": "^6.0.5",
+ "debug": "^4.0.1",
+ "doctrine": "^3.0.0",
+ "eslint-scope": "^4.0.3",
+ "eslint-utils": "^1.3.1",
+ "eslint-visitor-keys": "^1.0.0",
+ "espree": "^5.0.1",
+ "esquery": "^1.0.1",
+ "esutils": "^2.0.2",
+ "file-entry-cache": "^5.0.1",
+ "functional-red-black-tree": "^1.0.1",
+ "glob": "^7.1.2",
+ "globals": "^11.7.0",
+ "ignore": "^4.0.6",
+ "import-fresh": "^3.0.0",
+ "imurmurhash": "^0.1.4",
+ "inquirer": "^6.2.2",
+ "js-yaml": "^3.13.0",
+ "json-stable-stringify-without-jsonify": "^1.0.1",
+ "levn": "^0.3.0",
+ "lodash": "^4.17.11",
+ "minimatch": "^3.0.4",
+ "mkdirp": "^0.5.1",
+ "natural-compare": "^1.4.0",
+ "optionator": "^0.8.2",
+ "path-is-inside": "^1.0.2",
+ "progress": "^2.0.0",
+ "regexpp": "^2.0.1",
+ "semver": "^5.5.1",
+ "strip-ansi": "^4.0.0",
+ "strip-json-comments": "^2.0.1",
+ "table": "^5.2.3",
+ "text-table": "^0.2.0"
+ }
+ },
+ "eslint-scope": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz",
+ "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==",
+ "dev": true,
+ "requires": {
+ "esrecurse": "^4.1.0",
+ "estraverse": "^4.1.1"
+ }
+ },
+ "espree": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz",
+ "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==",
+ "dev": true,
+ "requires": {
+ "acorn": "^6.0.7",
+ "acorn-jsx": "^5.0.0",
+ "eslint-visitor-keys": "^1.0.0"
+ }
+ },
+ "figures": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
+ "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",
+ "dev": true,
+ "requires": {
+ "escape-string-regexp": "^1.0.5"
+ }
+ },
+ "globals": {
+ "version": "11.12.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
+ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==",
+ "dev": true
+ },
+ "inquirer": {
+ "version": "6.5.2",
+ "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz",
+ "integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==",
+ "dev": true,
+ "requires": {
+ "ansi-escapes": "^3.2.0",
+ "chalk": "^2.4.2",
+ "cli-cursor": "^2.1.0",
+ "cli-width": "^2.0.0",
+ "external-editor": "^3.0.3",
+ "figures": "^2.0.0",
+ "lodash": "^4.17.12",
+ "mute-stream": "0.0.7",
+ "run-async": "^2.2.0",
+ "rxjs": "^6.4.0",
+ "string-width": "^2.1.0",
+ "strip-ansi": "^5.1.0",
+ "through": "^2.3.6"
+ },
+ "dependencies": {
+ "strip-ansi": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
+ "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^4.1.0"
+ }
+ }
+ }
+ },
+ "ms": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
+ "dev": true
+ },
+ "mute-stream": {
+ "version": "0.0.7",
+ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
+ "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=",
+ "dev": true
+ },
+ "onetime": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
+ "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",
+ "dev": true,
+ "requires": {
+ "mimic-fn": "^1.0.0"
+ }
+ },
+ "restore-cursor": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
+ "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",
+ "dev": true,
+ "requires": {
+ "onetime": "^2.0.0",
+ "signal-exit": "^3.0.2"
+ }
+ }
+ }
+ },
"gzip-size": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz",
@@ -11169,39 +11317,6 @@
"integrity": "sha512-1qYz89hW3lFDEazhjW0yVAV87lw8lVkrJocr72XmBkMKsoSVJCQx3W8BXsC7hO2qAt8BoVjYjtAcZ9perqGnNg==",
"dev": true
},
- "htmlparser2": {
- "version": "3.8.3",
- "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz",
- "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=",
- "dev": true,
- "requires": {
- "domelementtype": "1",
- "domhandler": "2.3",
- "domutils": "1.5",
- "entities": "1.0",
- "readable-stream": "1.1"
- },
- "dependencies": {
- "readable-stream": {
- "version": "1.1.14",
- "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
- "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
- "dev": true,
- "requires": {
- "core-util-is": "~1.0.0",
- "inherits": "~2.0.1",
- "isarray": "0.0.1",
- "string_decoder": "~0.10.x"
- }
- },
- "string_decoder": {
- "version": "0.10.31",
- "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
- "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
- "dev": true
- }
- }
- },
"http-parser-js": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.0.tgz",
@@ -11259,14 +11374,14 @@
"dev": true
},
"husky": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.1.tgz",
- "integrity": "sha512-Qa0lRreeIf4Tl92sSs42ER6qc3hzoyQPPorzOrFWfPEVbdi6LuvJEqWKPk905fOWIR76iBpp7ECZNIwk+a8xuQ==",
+ "version": "4.2.5",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.5.tgz",
+ "integrity": "sha512-SYZ95AjKcX7goYVZtVZF2i6XiZcHknw50iXvY7b0MiGoj5RwdgRQNEHdb+gPDPCXKlzwrybjFjkL6FOj8uRhZQ==",
"dev": true,
"requires": {
- "chalk": "^3.0.0",
+ "chalk": "^4.0.0",
"ci-info": "^2.0.0",
- "compare-versions": "^3.5.1",
+ "compare-versions": "^3.6.0",
"cosmiconfig": "^6.0.0",
"find-versions": "^3.2.0",
"opencollective-postinstall": "^2.0.2",
@@ -11287,9 +11402,9 @@
}
},
"chalk": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
- "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz",
+ "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==",
"dev": true,
"requires": {
"ansi-styles": "^4.1.0",
@@ -11879,12 +11994,6 @@
"dev": true,
"optional": true
},
- "isarray": {
- "version": "0.0.1",
- "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
- "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
- "dev": true
- },
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@@ -14082,30 +14191,6 @@
"integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=",
"dev": true
},
- "jshint": {
- "version": "2.10.2",
- "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz",
- "integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==",
- "dev": true,
- "requires": {
- "cli": "~1.0.0",
- "console-browserify": "1.1.x",
- "exit": "0.1.x",
- "htmlparser2": "3.8.x",
- "lodash": "~4.17.11",
- "minimatch": "~3.0.2",
- "shelljs": "0.3.x",
- "strip-json-comments": "1.0.x"
- },
- "dependencies": {
- "strip-json-comments": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz",
- "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=",
- "dev": true
- }
- }
- },
"json-parse-better-errors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
@@ -16092,6 +16177,12 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
+ "path-is-inside": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz",
+ "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=",
+ "dev": true
+ },
"path-key": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
@@ -19511,12 +19602,6 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
- "shelljs": {
- "version": "0.3.0",
- "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz",
- "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=",
- "dev": true
- },
"shellwords": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
diff --git a/package.json b/package.json
index 52817a25465..5493bdc08c7 100644
--- a/package.json
+++ b/package.json
@@ -46,7 +46,6 @@
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-cssmin": "3.0.0",
- "grunt-contrib-jshint": "2.1.0",
"grunt-contrib-uglify": "4.0.1",
"grunt-contrib-watch": "1.1.0",
"grunt-phpcs": "0.4.0",
@@ -56,7 +55,8 @@
"grunt-sass": "3.1.0",
"grunt-shell": "3.0.1",
"grunt-stylelint": "0.14.0",
- "husky": "4.2.1",
+ "gruntify-eslint": "5.0.0",
+ "husky": "4.2.5",
"istanbul": "1.0.0-alpha.2",
"jest": "25.1.0",
"jest-puppeteer": "4.4.0",
diff --git a/phpcs.xml b/phpcs.xml
index c8196e3167e..f437ec8b333 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -6,6 +6,7 @@
tests/cli/
+ tests/legacy/
includes/libraries/
includes/legacy/
includes/api/legacy/
diff --git a/phpunit.xml b/phpunit.xml
index d8b796394e8..75b6a007d51 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,6 +1,6 @@
- ./tests/unit-tests
+ ./tests/legacy/unit-tests
+ ./tests/php
@@ -46,6 +47,6 @@
-
+
diff --git a/src/Admin/.gitignore b/src/Admin/.gitignore
new file mode 100644
index 00000000000..ee8d4ea0dd0
--- /dev/null
+++ b/src/Admin/.gitignore
@@ -0,0 +1,5 @@
+# Prevent anyone from accidentally adding code to these directories.
+# This will break any PRs that do, revealing ths mistake they made.
+*
+!.gitignore
+!README.md
diff --git a/src/Admin/README.md b/src/Admin/README.md
new file mode 100644
index 00000000000..3251e1f9956
--- /dev/null
+++ b/src/Admin/README.md
@@ -0,0 +1,3 @@
+# WARNING
+
+The namespace of this folder belongs to the [WC-Admin Plugin](https://github.com/woocommerce/woocommerce-admin) that is included in Core via composer. Any contributions to this namespace should be made in the corresponding repository to prevent conflicts.
diff --git a/src/Blocks/.gitignore b/src/Blocks/.gitignore
new file mode 100644
index 00000000000..ee8d4ea0dd0
--- /dev/null
+++ b/src/Blocks/.gitignore
@@ -0,0 +1,5 @@
+# Prevent anyone from accidentally adding code to these directories.
+# This will break any PRs that do, revealing ths mistake they made.
+*
+!.gitignore
+!README.md
diff --git a/src/Blocks/README.md b/src/Blocks/README.md
new file mode 100644
index 00000000000..95e6021eb15
--- /dev/null
+++ b/src/Blocks/README.md
@@ -0,0 +1,3 @@
+# WARNING
+
+The namespace of this folder belongs to the [Product Blocks Plugin](https://github.com/woocommerce/woocommerce-gutenberg-products-block) that is included in Core via composer. Any contributions to this namespace should be made in the corresponding repository to prevent conflicts.
diff --git a/tests/README.md b/tests/README.md
index 4c0ec2b0746..e352b11933f 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -46,7 +46,7 @@ The tests will execute and you'll be presented with a summary.
You can run specific tests by providing the path and filename to the test class:
- $ vendor/bin/phpunit tests/unit-tests/importer/product.php
+ $ vendor/bin/phpunit tests/legacy/unit-tests/importer/product.php
A text code coverage summary can be displayed using the `--coverage-text` option:
@@ -54,6 +54,7 @@ A text code coverage summary can be displayed using the `--coverage-text` option
### Writing Tests
+* There are two different PHPUnit directories, `tests/legacy` and `tests/php`. The `tests/legacy` directory contains all of the tests for code in the `includes` directory, and the `tests/php` directory is a PSR-4 namespaced directory for tests of code in the `src` directory.
* Each test file should roughly correspond to an associated source file, e.g. the `formatting/functions.php` test file covers code in the `wc-formatting-functions.php` file
* Each test method should cover a single method or function with one or more assertions
* A single method or function can have multiple associated test methods if it's a large or complex method
diff --git a/tests/bootstrap.php b/tests/legacy/bootstrap.php
similarity index 98%
rename from tests/bootstrap.php
rename to tests/legacy/bootstrap.php
index 0567482dfd8..c0a91df0ec3 100644
--- a/tests/bootstrap.php
+++ b/tests/legacy/bootstrap.php
@@ -41,7 +41,7 @@ class WC_Unit_Tests_Bootstrap {
// phpcs:enable WordPress.VIP.SuperGlobalInputUsage.AccessDetected
$this->tests_dir = dirname( __FILE__ );
- $this->plugin_dir = dirname( $this->tests_dir );
+ $this->plugin_dir = dirname( dirname( $this->tests_dir ) );
$this->wp_tests_dir = getenv( 'WP_TESTS_DIR' ) ? getenv( 'WP_TESTS_DIR' ) : sys_get_temp_dir() . '/wordpress-tests-lib';
// load test function so tests_add_filter() is available.
diff --git a/tests/data/Dr1Bczxq4q.png b/tests/legacy/data/Dr1Bczxq4q.png
similarity index 100%
rename from tests/data/Dr1Bczxq4q.png
rename to tests/legacy/data/Dr1Bczxq4q.png
diff --git a/tests/data/GeoLite2-Country.tar.gz b/tests/legacy/data/GeoLite2-Country.tar.gz
similarity index 100%
rename from tests/data/GeoLite2-Country.tar.gz
rename to tests/legacy/data/GeoLite2-Country.tar.gz
diff --git a/tests/data/file.txt b/tests/legacy/data/file.txt
similarity index 100%
rename from tests/data/file.txt
rename to tests/legacy/data/file.txt
diff --git a/tests/data/sample-email.html b/tests/legacy/data/sample-email.html
similarity index 100%
rename from tests/data/sample-email.html
rename to tests/legacy/data/sample-email.html
diff --git a/tests/framework/class-wc-api-unit-test-case.php b/tests/legacy/framework/class-wc-api-unit-test-case.php
similarity index 100%
rename from tests/framework/class-wc-api-unit-test-case.php
rename to tests/legacy/framework/class-wc-api-unit-test-case.php
diff --git a/tests/framework/class-wc-dummy-data-store.php b/tests/legacy/framework/class-wc-dummy-data-store.php
similarity index 100%
rename from tests/framework/class-wc-dummy-data-store.php
rename to tests/legacy/framework/class-wc-dummy-data-store.php
diff --git a/tests/framework/class-wc-mock-payment-gateway.php b/tests/legacy/framework/class-wc-mock-payment-gateway.php
similarity index 100%
rename from tests/framework/class-wc-mock-payment-gateway.php
rename to tests/legacy/framework/class-wc-mock-payment-gateway.php
diff --git a/tests/framework/class-wc-mock-session-handler.php b/tests/legacy/framework/class-wc-mock-session-handler.php
similarity index 100%
rename from tests/framework/class-wc-mock-session-handler.php
rename to tests/legacy/framework/class-wc-mock-session-handler.php
diff --git a/tests/framework/class-wc-mock-wc-data.php b/tests/legacy/framework/class-wc-mock-wc-data.php
similarity index 100%
rename from tests/framework/class-wc-mock-wc-data.php
rename to tests/legacy/framework/class-wc-mock-wc-data.php
diff --git a/tests/framework/class-wc-mock-wc-object-query.php b/tests/legacy/framework/class-wc-mock-wc-object-query.php
similarity index 100%
rename from tests/framework/class-wc-mock-wc-object-query.php
rename to tests/legacy/framework/class-wc-mock-wc-object-query.php
diff --git a/tests/framework/class-wc-payment-token-stub.php b/tests/legacy/framework/class-wc-payment-token-stub.php
similarity index 100%
rename from tests/framework/class-wc-payment-token-stub.php
rename to tests/legacy/framework/class-wc-payment-token-stub.php
diff --git a/tests/framework/class-wc-rest-unit-test-case.php b/tests/legacy/framework/class-wc-rest-unit-test-case.php
similarity index 100%
rename from tests/framework/class-wc-rest-unit-test-case.php
rename to tests/legacy/framework/class-wc-rest-unit-test-case.php
diff --git a/tests/framework/class-wc-unit-test-case.php b/tests/legacy/framework/class-wc-unit-test-case.php
similarity index 100%
rename from tests/framework/class-wc-unit-test-case.php
rename to tests/legacy/framework/class-wc-unit-test-case.php
diff --git a/tests/framework/class-wc-unit-test-factory.php b/tests/legacy/framework/class-wc-unit-test-factory.php
similarity index 100%
rename from tests/framework/class-wc-unit-test-factory.php
rename to tests/legacy/framework/class-wc-unit-test-factory.php
diff --git a/tests/framework/helpers/class-wc-helper-coupon.php b/tests/legacy/framework/helpers/class-wc-helper-coupon.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-coupon.php
rename to tests/legacy/framework/helpers/class-wc-helper-coupon.php
diff --git a/tests/framework/helpers/class-wc-helper-customer.php b/tests/legacy/framework/helpers/class-wc-helper-customer.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-customer.php
rename to tests/legacy/framework/helpers/class-wc-helper-customer.php
diff --git a/tests/framework/helpers/class-wc-helper-fee.php b/tests/legacy/framework/helpers/class-wc-helper-fee.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-fee.php
rename to tests/legacy/framework/helpers/class-wc-helper-fee.php
diff --git a/tests/framework/helpers/class-wc-helper-order.php b/tests/legacy/framework/helpers/class-wc-helper-order.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-order.php
rename to tests/legacy/framework/helpers/class-wc-helper-order.php
diff --git a/tests/framework/helpers/class-wc-helper-payment-token.php b/tests/legacy/framework/helpers/class-wc-helper-payment-token.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-payment-token.php
rename to tests/legacy/framework/helpers/class-wc-helper-payment-token.php
diff --git a/tests/framework/helpers/class-wc-helper-product.php b/tests/legacy/framework/helpers/class-wc-helper-product.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-product.php
rename to tests/legacy/framework/helpers/class-wc-helper-product.php
diff --git a/tests/framework/helpers/class-wc-helper-settings.php b/tests/legacy/framework/helpers/class-wc-helper-settings.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-settings.php
rename to tests/legacy/framework/helpers/class-wc-helper-settings.php
diff --git a/tests/framework/helpers/class-wc-helper-shipping-zones.php b/tests/legacy/framework/helpers/class-wc-helper-shipping-zones.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-shipping-zones.php
rename to tests/legacy/framework/helpers/class-wc-helper-shipping-zones.php
diff --git a/tests/framework/helpers/class-wc-helper-shipping.php b/tests/legacy/framework/helpers/class-wc-helper-shipping.php
similarity index 100%
rename from tests/framework/helpers/class-wc-helper-shipping.php
rename to tests/legacy/framework/helpers/class-wc-helper-shipping.php
diff --git a/tests/framework/vendor/class-wp-test-spy-rest-server.php b/tests/legacy/framework/vendor/class-wp-test-spy-rest-server.php
similarity index 100%
rename from tests/framework/vendor/class-wp-test-spy-rest-server.php
rename to tests/legacy/framework/vendor/class-wp-test-spy-rest-server.php
diff --git a/tests/includes/listener-loader.php b/tests/legacy/includes/listener-loader.php
similarity index 100%
rename from tests/includes/listener-loader.php
rename to tests/legacy/includes/listener-loader.php
diff --git a/tests/includes/wp-http-testcase.php b/tests/legacy/includes/wp-http-testcase.php
similarity index 100%
rename from tests/includes/wp-http-testcase.php
rename to tests/legacy/includes/wp-http-testcase.php
diff --git a/tests/unit-tests/account/functions.php b/tests/legacy/unit-tests/account/functions.php
similarity index 100%
rename from tests/unit-tests/account/functions.php
rename to tests/legacy/unit-tests/account/functions.php
diff --git a/tests/unit-tests/account/permissions.php b/tests/legacy/unit-tests/account/permissions.php
similarity index 100%
rename from tests/unit-tests/account/permissions.php
rename to tests/legacy/unit-tests/account/permissions.php
diff --git a/tests/unit-tests/admin/class-wc-tests-admin-duplicate-product.php b/tests/legacy/unit-tests/admin/class-wc-tests-admin-duplicate-product.php
similarity index 100%
rename from tests/unit-tests/admin/class-wc-tests-admin-duplicate-product.php
rename to tests/legacy/unit-tests/admin/class-wc-tests-admin-duplicate-product.php
diff --git a/tests/unit-tests/admin/reports/class-wc-tests-admin-report.php b/tests/legacy/unit-tests/admin/reports/class-wc-tests-admin-report.php
similarity index 100%
rename from tests/unit-tests/admin/reports/class-wc-tests-admin-report.php
rename to tests/legacy/unit-tests/admin/reports/class-wc-tests-admin-report.php
diff --git a/tests/unit-tests/admin/reports/class-wc-tests-report-sales-by-date.php b/tests/legacy/unit-tests/admin/reports/class-wc-tests-report-sales-by-date.php
similarity index 100%
rename from tests/unit-tests/admin/reports/class-wc-tests-report-sales-by-date.php
rename to tests/legacy/unit-tests/admin/reports/class-wc-tests-report-sales-by-date.php
diff --git a/tests/unit-tests/attributes/functions.php b/tests/legacy/unit-tests/attributes/functions.php
similarity index 100%
rename from tests/unit-tests/attributes/functions.php
rename to tests/legacy/unit-tests/attributes/functions.php
diff --git a/tests/unit-tests/cart/cart-fees.php b/tests/legacy/unit-tests/cart/cart-fees.php
similarity index 100%
rename from tests/unit-tests/cart/cart-fees.php
rename to tests/legacy/unit-tests/cart/cart-fees.php
diff --git a/tests/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php
similarity index 100%
rename from tests/unit-tests/cart/cart.php
rename to tests/legacy/unit-tests/cart/cart.php
diff --git a/tests/unit-tests/cart/functions.php b/tests/legacy/unit-tests/cart/functions.php
similarity index 100%
rename from tests/unit-tests/cart/functions.php
rename to tests/legacy/unit-tests/cart/functions.php
diff --git a/tests/unit-tests/checkout/checkout.php b/tests/legacy/unit-tests/checkout/checkout.php
similarity index 100%
rename from tests/unit-tests/checkout/checkout.php
rename to tests/legacy/unit-tests/checkout/checkout.php
diff --git a/tests/unit-tests/core/main-class.php b/tests/legacy/unit-tests/core/main-class.php
similarity index 94%
rename from tests/unit-tests/core/main-class.php
rename to tests/legacy/unit-tests/core/main-class.php
index 5e9d92f4223..eb66ed137f0 100644
--- a/tests/unit-tests/core/main-class.php
+++ b/tests/legacy/unit-tests/core/main-class.php
@@ -41,7 +41,7 @@ class WC_Test_WooCommerce extends WC_Unit_Test_Case {
* @since 2.2
*/
public function test_constants() {
- $this->assertEquals( str_replace( 'tests/unit-tests/core/', '', plugin_dir_path( __FILE__ ) ) . 'woocommerce.php', WC_PLUGIN_FILE );
+ $this->assertEquals( str_replace( 'tests/legacy/unit-tests/core/', '', plugin_dir_path( __FILE__ ) ) . 'woocommerce.php', WC_PLUGIN_FILE );
$this->assertEquals( $this->wc->version, Constants::get_constant( 'WC_VERSION' ) );
$this->assertEquals( WC_VERSION, WOOCOMMERCE_VERSION );
$this->assertEquals( 6, WC_ROUNDING_PRECISION );
diff --git a/tests/unit-tests/core/post-types-admin.php b/tests/legacy/unit-tests/core/post-types-admin.php
similarity index 100%
rename from tests/unit-tests/core/post-types-admin.php
rename to tests/legacy/unit-tests/core/post-types-admin.php
diff --git a/tests/unit-tests/core/taxonomies.php b/tests/legacy/unit-tests/core/taxonomies.php
similarity index 100%
rename from tests/unit-tests/core/taxonomies.php
rename to tests/legacy/unit-tests/core/taxonomies.php
diff --git a/tests/unit-tests/countries/countries.php b/tests/legacy/unit-tests/countries/countries.php
similarity index 100%
rename from tests/unit-tests/countries/countries.php
rename to tests/legacy/unit-tests/countries/countries.php
diff --git a/tests/unit-tests/coupon/coupon.php b/tests/legacy/unit-tests/coupon/coupon.php
similarity index 100%
rename from tests/unit-tests/coupon/coupon.php
rename to tests/legacy/unit-tests/coupon/coupon.php
diff --git a/tests/unit-tests/coupon/data-store.php b/tests/legacy/unit-tests/coupon/data-store.php
similarity index 100%
rename from tests/unit-tests/coupon/data-store.php
rename to tests/legacy/unit-tests/coupon/data-store.php
diff --git a/tests/unit-tests/coupon/data.php b/tests/legacy/unit-tests/coupon/data.php
similarity index 100%
rename from tests/unit-tests/coupon/data.php
rename to tests/legacy/unit-tests/coupon/data.php
diff --git a/tests/unit-tests/coupon/functions.php b/tests/legacy/unit-tests/coupon/functions.php
similarity index 100%
rename from tests/unit-tests/coupon/functions.php
rename to tests/legacy/unit-tests/coupon/functions.php
diff --git a/tests/unit-tests/crud/data-store.php b/tests/legacy/unit-tests/crud/data-store.php
similarity index 100%
rename from tests/unit-tests/crud/data-store.php
rename to tests/legacy/unit-tests/crud/data-store.php
diff --git a/tests/unit-tests/crud/data.php b/tests/legacy/unit-tests/crud/data.php
similarity index 100%
rename from tests/unit-tests/crud/data.php
rename to tests/legacy/unit-tests/crud/data.php
diff --git a/tests/unit-tests/crud/meta.php b/tests/legacy/unit-tests/crud/meta.php
similarity index 100%
rename from tests/unit-tests/crud/meta.php
rename to tests/legacy/unit-tests/crud/meta.php
diff --git a/tests/unit-tests/crud/query.php b/tests/legacy/unit-tests/crud/query.php
similarity index 100%
rename from tests/unit-tests/crud/query.php
rename to tests/legacy/unit-tests/crud/query.php
diff --git a/tests/unit-tests/crud/refunds.php b/tests/legacy/unit-tests/crud/refunds.php
similarity index 100%
rename from tests/unit-tests/crud/refunds.php
rename to tests/legacy/unit-tests/crud/refunds.php
diff --git a/tests/unit-tests/customer/class-wc-customer-download-log-data-store.php b/tests/legacy/unit-tests/customer/class-wc-customer-download-log-data-store.php
similarity index 100%
rename from tests/unit-tests/customer/class-wc-customer-download-log-data-store.php
rename to tests/legacy/unit-tests/customer/class-wc-customer-download-log-data-store.php
diff --git a/tests/unit-tests/customer/class-wc-tests-customer-download.php b/tests/legacy/unit-tests/customer/class-wc-tests-customer-download.php
similarity index 100%
rename from tests/unit-tests/customer/class-wc-tests-customer-download.php
rename to tests/legacy/unit-tests/customer/class-wc-tests-customer-download.php
diff --git a/tests/unit-tests/customer/crud.php b/tests/legacy/unit-tests/customer/crud.php
similarity index 100%
rename from tests/unit-tests/customer/crud.php
rename to tests/legacy/unit-tests/customer/crud.php
diff --git a/tests/unit-tests/customer/customer-download-log.php b/tests/legacy/unit-tests/customer/customer-download-log.php
similarity index 100%
rename from tests/unit-tests/customer/customer-download-log.php
rename to tests/legacy/unit-tests/customer/customer-download-log.php
diff --git a/tests/unit-tests/customer/customer.php b/tests/legacy/unit-tests/customer/customer.php
similarity index 100%
rename from tests/unit-tests/customer/customer.php
rename to tests/legacy/unit-tests/customer/customer.php
diff --git a/tests/unit-tests/customer/functions.php b/tests/legacy/unit-tests/customer/functions.php
similarity index 100%
rename from tests/unit-tests/customer/functions.php
rename to tests/legacy/unit-tests/customer/functions.php
diff --git a/tests/unit-tests/discounts/discounts.php b/tests/legacy/unit-tests/discounts/discounts.php
similarity index 100%
rename from tests/unit-tests/discounts/discounts.php
rename to tests/legacy/unit-tests/discounts/discounts.php
diff --git a/tests/unit-tests/email/emails.php b/tests/legacy/unit-tests/email/emails.php
similarity index 100%
rename from tests/unit-tests/email/emails.php
rename to tests/legacy/unit-tests/email/emails.php
diff --git a/tests/unit-tests/exporter/product.php b/tests/legacy/unit-tests/exporter/product.php
similarity index 100%
rename from tests/unit-tests/exporter/product.php
rename to tests/legacy/unit-tests/exporter/product.php
diff --git a/tests/unit-tests/formatting/functions.php b/tests/legacy/unit-tests/formatting/functions.php
similarity index 100%
rename from tests/unit-tests/formatting/functions.php
rename to tests/legacy/unit-tests/formatting/functions.php
diff --git a/tests/unit-tests/gateways/gateways.php b/tests/legacy/unit-tests/gateways/gateways.php
similarity index 100%
rename from tests/unit-tests/gateways/gateways.php
rename to tests/legacy/unit-tests/gateways/gateways.php
diff --git a/tests/unit-tests/gateways/paypal/request.php b/tests/legacy/unit-tests/gateways/paypal/request.php
similarity index 100%
rename from tests/unit-tests/gateways/paypal/request.php
rename to tests/legacy/unit-tests/gateways/paypal/request.php
diff --git a/tests/unit-tests/geolocation/class-wc-test-gelocation.php b/tests/legacy/unit-tests/geolocation/class-wc-test-gelocation.php
similarity index 100%
rename from tests/unit-tests/geolocation/class-wc-test-gelocation.php
rename to tests/legacy/unit-tests/geolocation/class-wc-test-gelocation.php
diff --git a/tests/unit-tests/importer/product.php b/tests/legacy/unit-tests/importer/product.php
similarity index 100%
rename from tests/unit-tests/importer/product.php
rename to tests/legacy/unit-tests/importer/product.php
diff --git a/tests/unit-tests/importer/sample.csv b/tests/legacy/unit-tests/importer/sample.csv
similarity index 100%
rename from tests/unit-tests/importer/sample.csv
rename to tests/legacy/unit-tests/importer/sample.csv
diff --git a/tests/unit-tests/importer/sample_tax_rates.csv b/tests/legacy/unit-tests/importer/sample_tax_rates.csv
similarity index 100%
rename from tests/unit-tests/importer/sample_tax_rates.csv
rename to tests/legacy/unit-tests/importer/sample_tax_rates.csv
diff --git a/tests/unit-tests/importer/sample_update_product.csv b/tests/legacy/unit-tests/importer/sample_update_product.csv
similarity index 100%
rename from tests/unit-tests/importer/sample_update_product.csv
rename to tests/legacy/unit-tests/importer/sample_update_product.csv
diff --git a/tests/unit-tests/importer/tax.php b/tests/legacy/unit-tests/importer/tax.php
similarity index 100%
rename from tests/unit-tests/importer/tax.php
rename to tests/legacy/unit-tests/importer/tax.php
diff --git a/tests/unit-tests/integrations/class-dummy-integration.php b/tests/legacy/unit-tests/integrations/class-dummy-integration.php
similarity index 100%
rename from tests/unit-tests/integrations/class-dummy-integration.php
rename to tests/legacy/unit-tests/integrations/class-dummy-integration.php
diff --git a/tests/unit-tests/integrations/class-wc-tests-integrations.php b/tests/legacy/unit-tests/integrations/class-wc-tests-integrations.php
similarity index 100%
rename from tests/unit-tests/integrations/class-wc-tests-integrations.php
rename to tests/legacy/unit-tests/integrations/class-wc-tests-integrations.php
diff --git a/tests/unit-tests/integrations/maxmind-geolocation/class-wc-tests-maxmind-database.php b/tests/legacy/unit-tests/integrations/maxmind-geolocation/class-wc-tests-maxmind-database.php
similarity index 100%
rename from tests/unit-tests/integrations/maxmind-geolocation/class-wc-tests-maxmind-database.php
rename to tests/legacy/unit-tests/integrations/maxmind-geolocation/class-wc-tests-maxmind-database.php
diff --git a/tests/unit-tests/integrations/maxmind-geolocation/class-wc-tests-maxmind-integration.php b/tests/legacy/unit-tests/integrations/maxmind-geolocation/class-wc-tests-maxmind-integration.php
similarity index 100%
rename from tests/unit-tests/integrations/maxmind-geolocation/class-wc-tests-maxmind-integration.php
rename to tests/legacy/unit-tests/integrations/maxmind-geolocation/class-wc-tests-maxmind-integration.php
diff --git a/tests/unit-tests/libraries/class-wc-mock-background-process.php b/tests/legacy/unit-tests/libraries/class-wc-mock-background-process.php
similarity index 100%
rename from tests/unit-tests/libraries/class-wc-mock-background-process.php
rename to tests/legacy/unit-tests/libraries/class-wc-mock-background-process.php
diff --git a/tests/unit-tests/libraries/wp-background-process.php b/tests/legacy/unit-tests/libraries/wp-background-process.php
similarity index 100%
rename from tests/unit-tests/libraries/wp-background-process.php
rename to tests/legacy/unit-tests/libraries/wp-background-process.php
diff --git a/tests/unit-tests/log/log-handler-db.php b/tests/legacy/unit-tests/log/log-handler-db.php
similarity index 100%
rename from tests/unit-tests/log/log-handler-db.php
rename to tests/legacy/unit-tests/log/log-handler-db.php
diff --git a/tests/unit-tests/log/log-handler-email.php b/tests/legacy/unit-tests/log/log-handler-email.php
similarity index 100%
rename from tests/unit-tests/log/log-handler-email.php
rename to tests/legacy/unit-tests/log/log-handler-email.php
diff --git a/tests/unit-tests/log/log-handler-file.php b/tests/legacy/unit-tests/log/log-handler-file.php
similarity index 100%
rename from tests/unit-tests/log/log-handler-file.php
rename to tests/legacy/unit-tests/log/log-handler-file.php
diff --git a/tests/unit-tests/log/log-levels.php b/tests/legacy/unit-tests/log/log-levels.php
similarity index 100%
rename from tests/unit-tests/log/log-levels.php
rename to tests/legacy/unit-tests/log/log-levels.php
diff --git a/tests/unit-tests/log/logger.php b/tests/legacy/unit-tests/log/logger.php
similarity index 100%
rename from tests/unit-tests/log/logger.php
rename to tests/legacy/unit-tests/log/logger.php
diff --git a/tests/unit-tests/log/test_log_expected.txt b/tests/legacy/unit-tests/log/test_log_expected.txt
similarity index 100%
rename from tests/unit-tests/log/test_log_expected.txt
rename to tests/legacy/unit-tests/log/test_log_expected.txt
diff --git a/tests/unit-tests/order-items/class-wc-tests-order-item-data-store.php b/tests/legacy/unit-tests/order-items/class-wc-tests-order-item-data-store.php
similarity index 100%
rename from tests/unit-tests/order-items/class-wc-tests-order-item-data-store.php
rename to tests/legacy/unit-tests/order-items/class-wc-tests-order-item-data-store.php
diff --git a/tests/unit-tests/order-items/class-wc-tests-order-item-product.php b/tests/legacy/unit-tests/order-items/class-wc-tests-order-item-product.php
similarity index 100%
rename from tests/unit-tests/order-items/class-wc-tests-order-item-product.php
rename to tests/legacy/unit-tests/order-items/class-wc-tests-order-item-product.php
diff --git a/tests/unit-tests/order-items/functions.php b/tests/legacy/unit-tests/order-items/functions.php
similarity index 100%
rename from tests/unit-tests/order-items/functions.php
rename to tests/legacy/unit-tests/order-items/functions.php
diff --git a/tests/unit-tests/order-items/order-item-coupon.php b/tests/legacy/unit-tests/order-items/order-item-coupon.php
similarity index 100%
rename from tests/unit-tests/order-items/order-item-coupon.php
rename to tests/legacy/unit-tests/order-items/order-item-coupon.php
diff --git a/tests/unit-tests/order-items/order-item-fee.php b/tests/legacy/unit-tests/order-items/order-item-fee.php
similarity index 100%
rename from tests/unit-tests/order-items/order-item-fee.php
rename to tests/legacy/unit-tests/order-items/order-item-fee.php
diff --git a/tests/unit-tests/order-items/order-item-meta.php b/tests/legacy/unit-tests/order-items/order-item-meta.php
similarity index 100%
rename from tests/unit-tests/order-items/order-item-meta.php
rename to tests/legacy/unit-tests/order-items/order-item-meta.php
diff --git a/tests/unit-tests/order-items/order-item-tax.php b/tests/legacy/unit-tests/order-items/order-item-tax.php
similarity index 100%
rename from tests/unit-tests/order-items/order-item-tax.php
rename to tests/legacy/unit-tests/order-items/order-item-tax.php
diff --git a/tests/unit-tests/order/class-wc-tests-crud-orders.php b/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
similarity index 100%
rename from tests/unit-tests/order/class-wc-tests-crud-orders.php
rename to tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
diff --git a/tests/unit-tests/order/class-wc-tests-order-functions.php b/tests/legacy/unit-tests/order/class-wc-tests-order-functions.php
similarity index 100%
rename from tests/unit-tests/order/class-wc-tests-order-functions.php
rename to tests/legacy/unit-tests/order/class-wc-tests-order-functions.php
diff --git a/tests/unit-tests/order/class-wc-tests-orders.php b/tests/legacy/unit-tests/order/class-wc-tests-orders.php
similarity index 100%
rename from tests/unit-tests/order/class-wc-tests-orders.php
rename to tests/legacy/unit-tests/order/class-wc-tests-orders.php
diff --git a/tests/unit-tests/order/coupons.php b/tests/legacy/unit-tests/order/coupons.php
similarity index 100%
rename from tests/unit-tests/order/coupons.php
rename to tests/legacy/unit-tests/order/coupons.php
diff --git a/tests/unit-tests/order/query.php b/tests/legacy/unit-tests/order/query.php
similarity index 100%
rename from tests/unit-tests/order/query.php
rename to tests/legacy/unit-tests/order/query.php
diff --git a/tests/unit-tests/packages/packages.php b/tests/legacy/unit-tests/packages/packages.php
similarity index 100%
rename from tests/unit-tests/packages/packages.php
rename to tests/legacy/unit-tests/packages/packages.php
diff --git a/tests/unit-tests/page-functions/class-wc-tests-page-functions.php b/tests/legacy/unit-tests/page-functions/class-wc-tests-page-functions.php
similarity index 100%
rename from tests/unit-tests/page-functions/class-wc-tests-page-functions.php
rename to tests/legacy/unit-tests/page-functions/class-wc-tests-page-functions.php
diff --git a/tests/unit-tests/payment-gateways/cod.php b/tests/legacy/unit-tests/payment-gateways/cod.php
similarity index 100%
rename from tests/unit-tests/payment-gateways/cod.php
rename to tests/legacy/unit-tests/payment-gateways/cod.php
diff --git a/tests/unit-tests/payment-gateways/payment-gateways.php b/tests/legacy/unit-tests/payment-gateways/payment-gateways.php
similarity index 100%
rename from tests/unit-tests/payment-gateways/payment-gateways.php
rename to tests/legacy/unit-tests/payment-gateways/payment-gateways.php
diff --git a/tests/unit-tests/payment-tokens/cc.php b/tests/legacy/unit-tests/payment-tokens/cc.php
similarity index 100%
rename from tests/unit-tests/payment-tokens/cc.php
rename to tests/legacy/unit-tests/payment-tokens/cc.php
diff --git a/tests/unit-tests/payment-tokens/echeck.php b/tests/legacy/unit-tests/payment-tokens/echeck.php
similarity index 100%
rename from tests/unit-tests/payment-tokens/echeck.php
rename to tests/legacy/unit-tests/payment-tokens/echeck.php
diff --git a/tests/unit-tests/payment-tokens/payment-token.php b/tests/legacy/unit-tests/payment-tokens/payment-token.php
similarity index 100%
rename from tests/unit-tests/payment-tokens/payment-token.php
rename to tests/legacy/unit-tests/payment-tokens/payment-token.php
diff --git a/tests/unit-tests/payment-tokens/payment-tokens.php b/tests/legacy/unit-tests/payment-tokens/payment-tokens.php
similarity index 100%
rename from tests/unit-tests/payment-tokens/payment-tokens.php
rename to tests/legacy/unit-tests/payment-tokens/payment-tokens.php
diff --git a/tests/unit-tests/privacy/export.php b/tests/legacy/unit-tests/privacy/export.php
similarity index 100%
rename from tests/unit-tests/privacy/export.php
rename to tests/legacy/unit-tests/privacy/export.php
diff --git a/tests/unit-tests/product/class-wc-tests-product-download.php b/tests/legacy/unit-tests/product/class-wc-tests-product-download.php
similarity index 100%
rename from tests/unit-tests/product/class-wc-tests-product-download.php
rename to tests/legacy/unit-tests/product/class-wc-tests-product-download.php
diff --git a/tests/unit-tests/product/data-store.php b/tests/legacy/unit-tests/product/data-store.php
similarity index 100%
rename from tests/unit-tests/product/data-store.php
rename to tests/legacy/unit-tests/product/data-store.php
diff --git a/tests/unit-tests/product/data.php b/tests/legacy/unit-tests/product/data.php
similarity index 100%
rename from tests/unit-tests/product/data.php
rename to tests/legacy/unit-tests/product/data.php
diff --git a/tests/unit-tests/product/factory.php b/tests/legacy/unit-tests/product/factory.php
similarity index 100%
rename from tests/unit-tests/product/factory.php
rename to tests/legacy/unit-tests/product/factory.php
diff --git a/tests/unit-tests/product/functions.php b/tests/legacy/unit-tests/product/functions.php
similarity index 100%
rename from tests/unit-tests/product/functions.php
rename to tests/legacy/unit-tests/product/functions.php
diff --git a/tests/unit-tests/product/product-simple.php b/tests/legacy/unit-tests/product/product-simple.php
similarity index 100%
rename from tests/unit-tests/product/product-simple.php
rename to tests/legacy/unit-tests/product/product-simple.php
diff --git a/tests/unit-tests/product/product-variable.php b/tests/legacy/unit-tests/product/product-variable.php
similarity index 100%
rename from tests/unit-tests/product/product-variable.php
rename to tests/legacy/unit-tests/product/product-variable.php
diff --git a/tests/unit-tests/product/product-variation.php b/tests/legacy/unit-tests/product/product-variation.php
similarity index 100%
rename from tests/unit-tests/product/product-variation.php
rename to tests/legacy/unit-tests/product/product-variation.php
diff --git a/tests/unit-tests/product/query.php b/tests/legacy/unit-tests/product/query.php
similarity index 100%
rename from tests/unit-tests/product/query.php
rename to tests/legacy/unit-tests/product/query.php
diff --git a/tests/unit-tests/queue/queue.php b/tests/legacy/unit-tests/queue/queue.php
similarity index 100%
rename from tests/unit-tests/queue/queue.php
rename to tests/legacy/unit-tests/queue/queue.php
diff --git a/tests/unit-tests/session/class-wc-tests-session-handler.php b/tests/legacy/unit-tests/session/class-wc-tests-session-handler.php
similarity index 100%
rename from tests/unit-tests/session/class-wc-tests-session-handler.php
rename to tests/legacy/unit-tests/session/class-wc-tests-session-handler.php
diff --git a/tests/unit-tests/settings/register-wp-admin-settings.php b/tests/legacy/unit-tests/settings/register-wp-admin-settings.php
similarity index 100%
rename from tests/unit-tests/settings/register-wp-admin-settings.php
rename to tests/legacy/unit-tests/settings/register-wp-admin-settings.php
diff --git a/tests/unit-tests/setup/functions.php b/tests/legacy/unit-tests/setup/functions.php
similarity index 100%
rename from tests/unit-tests/setup/functions.php
rename to tests/legacy/unit-tests/setup/functions.php
diff --git a/tests/unit-tests/shipping/shipping-zone.php b/tests/legacy/unit-tests/shipping/shipping-zone.php
similarity index 100%
rename from tests/unit-tests/shipping/shipping-zone.php
rename to tests/legacy/unit-tests/shipping/shipping-zone.php
diff --git a/tests/unit-tests/shipping/shipping-zones.php b/tests/legacy/unit-tests/shipping/shipping-zones.php
similarity index 100%
rename from tests/unit-tests/shipping/shipping-zones.php
rename to tests/legacy/unit-tests/shipping/shipping-zones.php
diff --git a/tests/unit-tests/shipping/shipping.php b/tests/legacy/unit-tests/shipping/shipping.php
similarity index 100%
rename from tests/unit-tests/shipping/shipping.php
rename to tests/legacy/unit-tests/shipping/shipping.php
diff --git a/tests/unit-tests/shortcodes/products.php b/tests/legacy/unit-tests/shortcodes/products.php
similarity index 100%
rename from tests/unit-tests/shortcodes/products.php
rename to tests/legacy/unit-tests/shortcodes/products.php
diff --git a/tests/unit-tests/tax/tax.php b/tests/legacy/unit-tests/tax/tax.php
similarity index 100%
rename from tests/unit-tests/tax/tax.php
rename to tests/legacy/unit-tests/tax/tax.php
diff --git a/tests/unit-tests/templates/functions.php b/tests/legacy/unit-tests/templates/functions.php
similarity index 100%
rename from tests/unit-tests/templates/functions.php
rename to tests/legacy/unit-tests/templates/functions.php
diff --git a/tests/unit-tests/totals/totals.php b/tests/legacy/unit-tests/totals/totals.php
similarity index 100%
rename from tests/unit-tests/totals/totals.php
rename to tests/legacy/unit-tests/totals/totals.php
diff --git a/tests/unit-tests/util/api-functions.php b/tests/legacy/unit-tests/util/api-functions.php
similarity index 100%
rename from tests/unit-tests/util/api-functions.php
rename to tests/legacy/unit-tests/util/api-functions.php
diff --git a/tests/unit-tests/util/class-wc-rate-limiter.php b/tests/legacy/unit-tests/util/class-wc-rate-limiter.php
similarity index 100%
rename from tests/unit-tests/util/class-wc-rate-limiter.php
rename to tests/legacy/unit-tests/util/class-wc-rate-limiter.php
diff --git a/tests/unit-tests/util/class-wc-tests-core-functions.php b/tests/legacy/unit-tests/util/class-wc-tests-core-functions.php
similarity index 100%
rename from tests/unit-tests/util/class-wc-tests-core-functions.php
rename to tests/legacy/unit-tests/util/class-wc-tests-core-functions.php
diff --git a/tests/unit-tests/util/class-wc-tests-user-functions.php b/tests/legacy/unit-tests/util/class-wc-tests-user-functions.php
similarity index 100%
rename from tests/unit-tests/util/class-wc-tests-user-functions.php
rename to tests/legacy/unit-tests/util/class-wc-tests-user-functions.php
diff --git a/tests/unit-tests/util/class-wc-tests-wc-query.php b/tests/legacy/unit-tests/util/class-wc-tests-wc-query.php
similarity index 100%
rename from tests/unit-tests/util/class-wc-tests-wc-query.php
rename to tests/legacy/unit-tests/util/class-wc-tests-wc-query.php
diff --git a/tests/unit-tests/util/conditional-functions.php b/tests/legacy/unit-tests/util/conditional-functions.php
similarity index 100%
rename from tests/unit-tests/util/conditional-functions.php
rename to tests/legacy/unit-tests/util/conditional-functions.php
diff --git a/tests/unit-tests/util/deprecated-hooks.php b/tests/legacy/unit-tests/util/deprecated-hooks.php
similarity index 100%
rename from tests/unit-tests/util/deprecated-hooks.php
rename to tests/legacy/unit-tests/util/deprecated-hooks.php
diff --git a/tests/unit-tests/util/dummy-wc-logger.php b/tests/legacy/unit-tests/util/dummy-wc-logger.php
similarity index 100%
rename from tests/unit-tests/util/dummy-wc-logger.php
rename to tests/legacy/unit-tests/util/dummy-wc-logger.php
diff --git a/tests/unit-tests/util/install.php b/tests/legacy/unit-tests/util/install.php
similarity index 96%
rename from tests/unit-tests/util/install.php
rename to tests/legacy/unit-tests/util/install.php
index 8e9835384e8..44b28b7161e 100644
--- a/tests/unit-tests/util/install.php
+++ b/tests/legacy/unit-tests/util/install.php
@@ -45,7 +45,7 @@ class WC_Tests_Install extends WC_Unit_Test_Case {
define( 'WC_REMOVE_ALL_DATA', true );
}
- include dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/uninstall.php';
+ include dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) . '/uninstall.php';
delete_transient( 'wc_installing' );
WC_Install::install();
@@ -99,7 +99,7 @@ class WC_Tests_Install extends WC_Unit_Test_Case {
define( 'WP_UNINSTALL_PLUGIN', true );
define( 'WC_REMOVE_ALL_DATA', true );
}
- include dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/uninstall.php';
+ include dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) . '/uninstall.php';
WC_Install::create_roles();
diff --git a/tests/unit-tests/util/notice-functions.php b/tests/legacy/unit-tests/util/notice-functions.php
similarity index 100%
rename from tests/unit-tests/util/notice-functions.php
rename to tests/legacy/unit-tests/util/notice-functions.php
diff --git a/tests/unit-tests/util/plugin-updates.php b/tests/legacy/unit-tests/util/plugin-updates.php
similarity index 100%
rename from tests/unit-tests/util/plugin-updates.php
rename to tests/legacy/unit-tests/util/plugin-updates.php
diff --git a/tests/unit-tests/util/validation.php b/tests/legacy/unit-tests/util/validation.php
similarity index 100%
rename from tests/unit-tests/util/validation.php
rename to tests/legacy/unit-tests/util/validation.php
diff --git a/tests/unit-tests/webhooks/crud.php b/tests/legacy/unit-tests/webhooks/crud.php
similarity index 100%
rename from tests/unit-tests/webhooks/crud.php
rename to tests/legacy/unit-tests/webhooks/crud.php
diff --git a/tests/unit-tests/webhooks/functions.php b/tests/legacy/unit-tests/webhooks/functions.php
similarity index 100%
rename from tests/unit-tests/webhooks/functions.php
rename to tests/legacy/unit-tests/webhooks/functions.php
diff --git a/tests/unit-tests/widgets/class-dummy-widget.php b/tests/legacy/unit-tests/widgets/class-dummy-widget.php
similarity index 100%
rename from tests/unit-tests/widgets/class-dummy-widget.php
rename to tests/legacy/unit-tests/widgets/class-dummy-widget.php
diff --git a/tests/unit-tests/widgets/class-wc-tests-widget.php b/tests/legacy/unit-tests/widgets/class-wc-tests-widget.php
similarity index 100%
rename from tests/unit-tests/widgets/class-wc-tests-widget.php
rename to tests/legacy/unit-tests/widgets/class-wc-tests-widget.php
diff --git a/tests/php/.gitkeep b/tests/php/.gitkeep
new file mode 100644
index 00000000000..ff96249002a
--- /dev/null
+++ b/tests/php/.gitkeep
@@ -0,0 +1 @@
+# Placeholder to include the folder. Remove once tests have been written!
diff --git a/tests/unit-tests/helper/class-wc-helper-api.php b/tests/unit-tests/helper/class-wc-helper-api.php
new file mode 100644
index 00000000000..d59711770a2
--- /dev/null
+++ b/tests/unit-tests/helper/class-wc-helper-api.php
@@ -0,0 +1,109 @@
+http_responder = array( $this, 'mock_http_responses' );
+ }
+
+ /**
+ * Test that the url method returns the correct WooCommerce.com path.
+ *
+ * @return void
+ */
+ public function test_api_url() {
+ $url = WC_Helper_API::url( '/test-path' );
+ $this->assertEquals( 'https://woocommerce.com/wp-json/helper/1.0/test-path', $url );
+ }
+
+ /**
+ * Test a GET request through the WC_Helper_API.
+ *
+ * @return void
+ */
+ public function test_get_request() {
+ $request = WC_Helper_API::get(
+ 'test-get'
+ );
+
+ $this->assertEquals( '200', $request['response']['code'] );
+ }
+
+ /**
+ * Test a POST request through the WC_Helper_API.
+ *
+ * @return void
+ */
+ public function test_post_request() {
+ $request = WC_Helper_API::post(
+ 'test-post'
+ );
+
+ $this->assertEquals( '200', $request['response']['code'] );
+ }
+
+ /**
+ * Test a PUT request through the WC_Helper_API.
+ *
+ * @return void
+ */
+ public function test_put_request() {
+ $request = WC_Helper_API::put(
+ 'test-put'
+ );
+
+ $this->assertEquals( '200', $request['response']['code'] );
+ }
+
+ /**
+ * Provides a mocked response for various paths and request methods.
+ *
+ * This function is called by WP_HTTP_TestCase::http_request_listner().
+ *
+ * @param array $request Request arguments.
+ * @param string $url URL of the request.
+ *
+ * @return array|false mocked response or false to let WP perform a regular request.
+ */
+ protected function mock_http_responses( $request, $url ) {
+ $mocked_response = false;
+
+ if ( 'GET' === $request['method'] && WC_Helper_API::url( 'test-get' ) === $url ) {
+ $mocked_response = array(
+ 'body' => 'Mocked response',
+ 'response' => array( 'code' => 200 ),
+ );
+ }
+
+ if ( 'POST' === $request['method'] && WC_Helper_API::url( 'test-post' ) === $url ) {
+ $mocked_response = array(
+ 'body' => 'Mocked response',
+ 'response' => array( 'code' => 200 ),
+ );
+ }
+
+ if ( 'PUT' === $request['method'] && WC_Helper_API::url( 'test-put' ) === $url ) {
+ $mocked_response = array(
+ 'body' => 'Mocked response',
+ 'response' => array( 'code' => 200 ),
+ );
+ }
+
+ return $mocked_response;
+ }
+
+}