Merge branch 'master' into feature/post-system-status-tool-hook

This commit is contained in:
Steve Grunwell 2018-01-18 21:54:47 +00:00
commit 4d6a0ecb82
22 changed files with 258 additions and 40 deletions

View File

@ -1,5 +1,11 @@
language: php
addons:
chrome: stable
apt:
packages:
- nginx
sudo: false
# Test main supported versions of PHP against latest WP.
@ -21,7 +27,7 @@ matrix:
- php: 5.2
dist: precise
- php: 7.2
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1 RUN_E2E=1
- php: 7.2
env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1
allow_failures:
@ -35,6 +41,7 @@ before_script:
script:
- bash tests/bin/phpunit.sh
- bash tests/bin/phpcs.sh
- bash tests/bin/run-e2e-CI.sh
after_script:
- bash tests/bin/travis.sh after

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2285,6 +2285,9 @@ ul.wc_coupon_list_block {
height: auto;
z-index: 1;
position:relative;
max-width: 175px;
overflow: hidden;
text-overflow: ellipsis;
}
.wc-action-button:hover,
.wc-action-button:focus {
@ -2398,14 +2401,6 @@ ul.order_notes {
border-color: #efefef transparent;
}
}
li.customer-note {
.note_content {
background: #a7cedc;
}
.note_content::after {
border-color: #a7cedc transparent;
}
}
li.system-note {
.note_content {
background: #d7cad2;
@ -2414,6 +2409,14 @@ ul.order_notes {
border-color: #d7cad2 transparent;
}
}
li.customer-note {
.note_content {
background: #a7cedc;
}
.note_content::after {
border-color: #a7cedc transparent;
}
}
}
.add_note {

View File

@ -102,7 +102,7 @@ jQuery( function( $ ) {
}
$( '.woocommerce-cart-form' ).replaceWith( $new_form );
$( '.woocommerce-cart-form' ).find( 'input[name="update_cart"]' ).prop( 'disabled', true );
$( '.woocommerce-cart-form' ).find( ':input[name="update_cart"]' ).prop( 'disabled', true );
if ( $notices.length > 0 ) {
show_notice( $notices );
@ -158,7 +158,7 @@ jQuery( function( $ ) {
);
$( document ).on(
'change',
'select.shipping_method, input[name^=shipping_method]',
'select.shipping_method, :input[name^=shipping_method]',
this.shipping_method_selected
);
$( document ).on(
@ -185,7 +185,7 @@ jQuery( function( $ ) {
shipping_method_selected: function() {
var shipping_methods = {};
$( 'select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]' ).each( function() {
$( '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();
} );
@ -271,11 +271,11 @@ jQuery( function( $ ) {
function() { cart.update_cart.apply( cart, [].slice.call( arguments, 1 ) ); } );
$( document ).on(
'click',
'.woocommerce-cart-form input[type=submit]',
'.woocommerce-cart-form :input[type=submit]',
this.submit_click );
$( document ).on(
'keypress',
'.woocommerce-cart-form input[type=number]',
'.woocommerce-cart-form :input[type=number]',
this.input_keypress );
$( document ).on(
'submit',
@ -298,14 +298,14 @@ jQuery( function( $ ) {
'.woocommerce-cart-form .cart_item :input',
this.input_changed );
$( '.woocommerce-cart-form input[name="update_cart"]' ).prop( 'disabled', true );
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', true );
},
/**
* After an input is changed, enable the update cart button.
*/
input_changed: function() {
$( '.woocommerce-cart-form input[name="update_cart"]' ).prop( 'disabled', false );
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', false );
},
/**
@ -376,9 +376,9 @@ jQuery( function( $ ) {
* @param {Object} evt The JQuery event
*/
cart_submit: function( evt ) {
var $submit = $( document.activeElement );
var $clicked = $( 'input[type=submit][clicked=true]' );
var $form = $( evt.currentTarget );
var $submit = $( document.activeElement ),
$clicked = $( ':input[type=submit][clicked=true]' ),
$form = $( evt.currentTarget );
// For submit events, currentTarget is form.
// For keypress events, currentTarget is input.
@ -394,11 +394,11 @@ jQuery( function( $ ) {
return false;
}
if ( $clicked.is( 'input[name="update_cart"]' ) || $submit.is( 'input.qty' ) ) {
if ( $clicked.is( ':input[name="update_cart"]' ) || $submit.is( 'input.qty' ) ) {
evt.preventDefault();
this.quantity_update( $form );
} else if ( $clicked.is( 'input[name="apply_coupon"]' ) || $submit.is( '#coupon_code' ) ) {
} else if ( $clicked.is( ':input[name="apply_coupon"]' ) || $submit.is( '#coupon_code' ) ) {
evt.preventDefault();
this.apply_coupon( $form );
}
@ -410,7 +410,7 @@ jQuery( function( $ ) {
* @param {Object} evt The JQuery event
*/
submit_click: function( evt ) {
$( 'input[type=submit]', $( evt.target ).parents( 'form' ) ).removeAttr( 'clicked' );
$( ':input[type=submit]', $( evt.target ).parents( 'form' ) ).removeAttr( 'clicked' );
$( evt.target ).attr( 'clicked', 'true' );
},

File diff suppressed because one or more lines are too long

View File

@ -459,9 +459,11 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table {
<tbody>';
foreach ( $line_items as $item_id => $item ) {
$product_object = is_callable( array( $item, 'get_product' ) ) ? $item->get_product() : null;
$html .= '<tr class="wc-order-preview-table__item wc-order-preview-table__item--' . esc_attr( $item_id ) . '">';
$product_object = is_callable( array( $item, 'get_product' ) ) ? $item->get_product() : null;
$row_class = apply_filters( 'woocommerce_admin_html_order_preview_item_class', '', $item, $order );
$html .= '<tr class="wc-order-preview-table__item wc-order-preview-table__item--' . esc_attr( $item_id ) . ( $row_class ? ' ' . esc_attr( $row_class ) : '' ) . '">';
foreach ( $columns as $column => $label ) {
$html .= '<td class="wc-order-preview-table__column--' . esc_attr( $column ) . '">';

View File

@ -390,7 +390,7 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
protected function query_filters( $query_vars ) {
if ( isset( $query_vars['orderby'] ) ) {
if ( 'price' === $vars['orderby'] ) {
if ( 'price' === $query_vars['orderby'] ) {
// @codingStandardsIgnoreStart
$query_vars = array_merge( $query_vars, array(
'meta_key' => '_price',

View File

@ -186,7 +186,7 @@ class WC_Settings_Shipping extends WC_Settings_Page {
break;
}
// Increments the transient version to invalidate cache
// Increments the transient version to invalidate cache.
WC_Cache_Helper::get_transient_version( 'shipping', true );
}

View File

@ -118,7 +118,9 @@ class WC_Settings_Tax extends WC_Settings_Page {
$this->save_tax_rates();
}
// Invalidate caches.
WC_Cache_Helper::incr_cache_prefix( 'taxes' );
WC_Cache_Helper::get_transient_version( 'shipping', true );
}
/**

View File

@ -153,7 +153,7 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
'desc' => sprintf(
'<strong class="red">%1$s</strong> %2$s',
__( 'Note:', 'woocommerce' ),
__( 'This tool will delete all customer session data from the database, including any current live carts.', 'woocommerce' )
__( 'This tool will delete all customer session data from the database, including current carts and saved carts in the database.', 'woocommerce' )
),
),
'install_pages' => array(
@ -445,8 +445,9 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller {
case 'clear_sessions':
$wpdb->query( "TRUNCATE {$wpdb->prefix}woocommerce_sessions" );
$result = absint( $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key='_woocommerce_persistent_cart_" . get_current_blog_id() . "';" ) );
wp_cache_flush();
$message = __( 'Sessions successfully cleared', 'woocommerce' );
$message = sprintf( __( 'Deleted all active sessions, and %d saved carts.', 'woocommerce' ), absint( $result ) );
break;
case 'install_pages':

View File

@ -2347,6 +2347,9 @@ class WC_AJAX {
}
}
WC_Cache_Helper::incr_cache_prefix( 'taxes' );
WC_Cache_Helper::get_transient_version( 'shipping', true );
wp_send_json_success( array(
'rates' => WC_Tax::get_rates_for_tax_class( $current_class ),
) );

View File

@ -118,14 +118,14 @@ class WC_Cache_Helper {
/**
* Get transient version.
*
* When using transients with unpredictable names, e.g. those containing an md5.
* When using transients with unpredictable names, e.g. those containing an md5
* hash in the name, we need a way to invalidate them all at once.
*
* When using default WP transients we're able to do this with a DB query to.
* When using default WP transients we're able to do this with a DB query to
* delete transients manually.
*
* With external cache however, this isn't possible. Instead, this function is used.
* to append a unique string (based on time()) to each transient. When transients.
* With external cache however, this isn't possible. Instead, this function is used
* to append a unique string (based on time()) to each transient. When transients
* are invalidated, the transient version will increment and data will be regenerated.
*
* Raised in issue https://github.com/woocommerce/woocommerce/issues/5777.

View File

@ -277,7 +277,6 @@ class WC_Post_types {
'edit' => __( 'Edit', 'woocommerce' ),
'edit_item' => __( 'Edit product', 'woocommerce' ),
'new_item' => __( 'New product', 'woocommerce' ),
'view' => __( 'View product', 'woocommerce' ),
'view_item' => __( 'View product', 'woocommerce' ),
'view_items' => __( 'View products', 'woocommerce' ),
'search_items' => __( 'Search products', 'woocommerce' ),
@ -337,7 +336,6 @@ class WC_Post_types {
'edit' => __( 'Edit', 'woocommerce' ),
'edit_item' => __( 'Edit order', 'woocommerce' ),
'new_item' => __( 'New order', 'woocommerce' ),
'view' => __( 'View order', 'woocommerce' ),
'view_item' => __( 'View order', 'woocommerce' ),
'search_items' => __( 'Search orders', 'woocommerce' ),
'not_found' => __( 'No orders found', 'woocommerce' ),
@ -400,7 +398,6 @@ class WC_Post_types {
'edit' => __( 'Edit', 'woocommerce' ),
'edit_item' => __( 'Edit coupon', 'woocommerce' ),
'new_item' => __( 'New coupon', 'woocommerce' ),
'view' => __( 'View coupons', 'woocommerce' ),
'view_item' => __( 'View coupon', 'woocommerce' ),
'search_items' => __( 'Search coupons', 'woocommerce' ),
'not_found' => __( 'No coupons found', 'woocommerce' ),

View File

@ -47,7 +47,7 @@
"istanbul": "^1.0.0-alpha",
"mocha": "^3.0.2",
"stylelint": "~8.2.0",
"wc-e2e-page-objects": "0.6.0"
"wc-e2e-page-objects": "0.9.0"
},
"engines": {
"node": ">=8.9.3",

View File

@ -123,6 +123,69 @@ install_db() {
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
}
install_e2e_site() {
if [[ ${RUN_E2E} == 1 ]]; then
# Script Variables
CONFIG_DIR="./tests/e2e-tests/config/travis"
WP_CORE_DIR="$HOME/wordpress"
NGINX_DIR="$HOME/nginx"
PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm"
PHP_FPM_CONF="$NGINX_DIR/php-fpm.conf"
WP_SITE_URL="http://localhost:8080"
WP_DB_DATA="$HOME/build/$TRAVIS_REPO_SLUG/tests/e2e-tests/data/e2e-db.sql"
WORKING_DIR="$PWD"
set -ev
npm install
export NODE_CONFIG_DIR="./tests/e2e-tests/config"
BRANCH=$TRAVIS_BRANCH
if [ "$TRAVIS_PULL_REQUEST_BRANCH" != "" ]; then
BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
fi
# Set up nginx to run the server
mkdir -p "$WP_CORE_DIR"
mkdir -p "$NGINX_DIR"
mkdir -p "$NGINX_DIR/sites-enabled"
mkdir -p "$NGINX_DIR/var"
cp "$CONFIG_DIR/travis_php-fpm.conf" "$PHP_FPM_CONF"
# Start php-fpm
"$PHP_FPM_BIN" --fpm-config "$PHP_FPM_CONF"
# Copy the default nginx config files.
cp "$CONFIG_DIR/travis_nginx.conf" "$NGINX_DIR/nginx.conf"
cp "$CONFIG_DIR/travis_fastcgi.conf" "$NGINX_DIR/fastcgi.conf"
cp "$CONFIG_DIR/travis_default-site.conf" "$NGINX_DIR/sites-enabled/default-site.conf"
# Start nginx.
nginx -c "$NGINX_DIR/nginx.conf"
# Set up WordPress using wp-cli
cd "$WP_CORE_DIR"
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar core download --version=$WP_VERSION
php wp-cli.phar core config --dbname=$DB_NAME --dbuser=$DB_USER --dbpass=$DB_PASS --dbhost=$DB_HOST --dbprefix=wp_ --extra-php <<PHP
/* Change WP_MEMORY_LIMIT to increase the memory limit for public pages. */
define('WP_MEMORY_LIMIT', '256M');
PHP
php wp-cli.phar core install --url="$WP_SITE_URL" --title="Example" --admin_user=admin --admin_password=password --admin_email=info@example.com --path=$WP_CORE_DIR --skip-email
php wp-cli.phar db import $WP_DB_DATA
php wp-cli.phar search-replace "http://local.wordpress.test" "$WP_SITE_URL"
php wp-cli.phar theme install twentytwelve --activate
php wp-cli.phar plugin install https://github.com/$TRAVIS_REPO_SLUG/archive/$BRANCH.zip --activate
cd "$WORKING_DIR"
fi
}
install_wp
install_test_suite
install_db
install_e2e_site

14
tests/bin/run-e2e-CI.sh Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
if [[ ${RUN_E2E} == 1 ]]; then
WP_SITE_URL="http://localhost:8080"
# Start xvfb to run the tests
export BASE_URL="$WP_SITE_URL"
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sleep 3
# Run the tests
npm test
fi

View File

@ -0,0 +1,3 @@
{
"url": "BASE_URL"
}

View File

@ -0,0 +1,23 @@
server {
listen 8080 default_server;
listen [::]:8080 default_server ipv6only=on;
root /home/travis/wordpress;
access_log /tmp/access.log;
error_log /tmp/error.log;
## This should be in your http block and if it is, it's not needed here.
index index.php;
location ~* "\.php(/|$)" {
include fastcgi.conf;
fastcgi_pass php;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
}

View File

@ -0,0 +1,39 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_keep_conn on;

View File

@ -0,0 +1,52 @@
error_log /tmp/error.log;
pid /tmp/nginx.pid;
worker_processes 1;
events {
worker_connections 1024;
}
http {
# Set an array of temp and cache file options that will otherwise default to restricted locations accessible only to root.
client_body_temp_path /tmp/client_body;
fastcgi_temp_path /tmp/fastcgi_temp;
proxy_temp_path /tmp/proxy_temp;
scgi_temp_path /tmp/scgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /tmp/access.log;
error_log /tmp/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
##
# Virtual Host Configs
##
# include /tmp/nginx/conf.d/*.conf;
include /home/travis/nginx/sites-enabled/*;
upstream php {
server 127.0.0.1:9000;
}
}

View File

@ -0,0 +1,9 @@
[global]
[travis]
user = $USER
listen = 9000
listen.mode = 0666
pm = static
pm.max_children = 5
php_admin_value[memory_limit] = 32M