improved structured data - branch update
This commit is contained in:
commit
8bd46f81fb
|
@ -255,6 +255,7 @@ module.exports = function( grunt ) {
|
|||
]);
|
||||
|
||||
grunt.registerTask( 'css', [
|
||||
'stylelint',
|
||||
'sass',
|
||||
'cssmin'
|
||||
]);
|
||||
|
|
|
@ -10,7 +10,7 @@ extensions: [php]
|
|||
# directories and files matching this file mask will not be parsed
|
||||
exclude:
|
||||
- includes/libraries/
|
||||
- includes/api/
|
||||
- includes/api/legacy/
|
||||
- i18n/
|
||||
- node_modules/
|
||||
- wc-apidocs/
|
||||
|
|
|
@ -175,7 +175,7 @@ class WC_Settings_Products extends WC_Settings_Page {
|
|||
array(
|
||||
'title' => __( 'Product Images', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'desc' => sprintf( __( 'These settings affect the display and dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to <a href="%s">regenerate your thumbnails</a>.', 'woocommerce' ), 'https://wordpress.org/extend/plugins/regenerate-thumbnails/' ),
|
||||
'desc' => sprintf( __( 'These settings affect the display and dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to <a target="_blank" href="%s">regenerate your thumbnails</a>.', 'woocommerce' ), 'https://wordpress.org/extend/plugins/regenerate-thumbnails/' ),
|
||||
'id' => 'image_options'
|
||||
),
|
||||
|
||||
|
|
|
@ -434,6 +434,7 @@ class WC_Countries {
|
|||
'NZ' => "{name}\n{company}\n{address_1}\n{address_2}\n{city} {postcode}\n{country}",
|
||||
'NO' => $postcode_before_city,
|
||||
'PL' => $postcode_before_city,
|
||||
'PT' => $postcode_before_city,
|
||||
'SK' => $postcode_before_city,
|
||||
'SI' => $postcode_before_city,
|
||||
'ES' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{state}\n{country}",
|
||||
|
|
|
@ -26,10 +26,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'role' => 'customer',
|
||||
'last_order_id' => null, // read only
|
||||
'last_order_date' => null, // read only
|
||||
'orders_count' => 0, // read only
|
||||
'total_spent' => 0, // read only
|
||||
'username' => '', // read only on existing users
|
||||
'password' => '', // write only
|
||||
'date_created' => '', // read only
|
||||
|
@ -178,6 +174,94 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the customers last order.
|
||||
* @return WC_Order|false
|
||||
*/
|
||||
public function get_last_order() {
|
||||
global $wpdb;
|
||||
|
||||
$last_order = $wpdb->get_var( "SELECT posts.ID
|
||||
FROM $wpdb->posts AS posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = '" . esc_sql( $this->get_id() ) . "'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' )
|
||||
ORDER BY posts.ID DESC
|
||||
" );
|
||||
|
||||
if ( $last_order ) {
|
||||
return wc_get_order( absint( $last_order ) );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of orders this customer has.
|
||||
* @since 2.7.0
|
||||
* @return integer
|
||||
*/
|
||||
public function get_order_count() {
|
||||
global $wpdb;
|
||||
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*)
|
||||
FROM $wpdb->posts as posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' )
|
||||
AND meta_value = '" . esc_sql( $this->get_id() ) . "'
|
||||
" );
|
||||
|
||||
return absint( $count );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how much money this customer has spent.
|
||||
* @since 2.7.0
|
||||
* @return float
|
||||
*/
|
||||
public function get_total_spent() {
|
||||
global $wpdb;
|
||||
|
||||
$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
|
||||
FROM $wpdb->posts as posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = '" . esc_sql( $this->get_id() ) . "'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( 'wc-completed', 'wc-processing' )
|
||||
AND meta2.meta_key = '_order_total'
|
||||
" );
|
||||
|
||||
if ( ! $spent ) {
|
||||
$spent = 0;
|
||||
}
|
||||
|
||||
return wc_format_decimal( $spent );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is customer outside base country (for tax purposes)?
|
||||
* @return bool
|
||||
*/
|
||||
public function is_customer_outside_base() {
|
||||
list( $country, $state ) = $this->get_taxable_address();
|
||||
if ( $country ) {
|
||||
$default = wc_get_base_location();
|
||||
if ( $default['country'] !== $country ) {
|
||||
return true;
|
||||
}
|
||||
if ( $default['state'] && $default['state'] !== $state ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Getters
|
||||
|
@ -239,42 +323,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
return $this->_data['role'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return customer's last order ID.
|
||||
* @since 2.7.0
|
||||
* @return integer|null
|
||||
*/
|
||||
public function get_last_order_id() {
|
||||
return ( is_null( $this->_data['last_order_id'] ) ? null : intval( $this->_data['last_order_id'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the date of the customer's last order.
|
||||
* @since 2.7.0
|
||||
* @return integer|null
|
||||
*/
|
||||
public function get_last_order_date() {
|
||||
return ( is_null( $this->_data['last_order_date'] ) ? null : intval( $this->_data['last_order_date'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of orders this customer has.
|
||||
* @since 2.7.0
|
||||
* @return integer
|
||||
*/
|
||||
public function get_orders_count() {
|
||||
return intval( $this->_data['orders_count'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how much money this customer has spent.
|
||||
* @since 2.7.0
|
||||
* @return float
|
||||
*/
|
||||
public function get_total_spent() {
|
||||
return wc_format_decimal( $this->_data['total_spent'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this customer's avatar.
|
||||
* @since 2.7.0
|
||||
|
@ -566,6 +614,15 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
| object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set customer ID.
|
||||
* @since 2.7.0
|
||||
* @param int $value
|
||||
*/
|
||||
protected function set_id( $value ) {
|
||||
$this->_data['id'] = absint( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer's username.
|
||||
* @since 2.7.0
|
||||
|
@ -611,42 +668,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
$this->_data['role'] = $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer's last order ID.
|
||||
* @since 2.7.0
|
||||
* @param integer|null $last_order_id
|
||||
*/
|
||||
public function set_last_order_id( $last_order_id ) {
|
||||
$this->_data['last_order_id'] = $last_order_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the date of the customer's last order.
|
||||
* @since 2.7.0
|
||||
* @param string|null $last_order_date
|
||||
*/
|
||||
public function set_last_order_date( $last_order_date ) {
|
||||
$this->_data['last_order_date'] = $last_order_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of orders this customer has.
|
||||
* @since 2.7.0
|
||||
* @param integer $order_count
|
||||
*/
|
||||
public function set_orders_count( $orders_count ) {
|
||||
$this->_data['orders_count'] = $orders_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return how much money this customer has spent.
|
||||
* @since 2.7.0
|
||||
* @param float $total_spent
|
||||
*/
|
||||
public function set_total_spent( $total_spent ) {
|
||||
$this->_data['total_spent'] = $total_spent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer's password.
|
||||
* @since 2.7.0
|
||||
|
@ -927,31 +948,6 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
$this->_data['is_paying_customer'] = (bool) $is_paying_customer;
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Other methods
|
||||
|--------------------------------------------------------------------------
|
||||
| Other functions for interacting with customers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Is customer outside base country (for tax purposes)?
|
||||
* @return bool
|
||||
*/
|
||||
public function is_customer_outside_base() {
|
||||
list( $country, $state ) = $this->get_taxable_address();
|
||||
if ( $country ) {
|
||||
$default = wc_get_base_location();
|
||||
if ( $default['country'] !== $country ) {
|
||||
return true;
|
||||
}
|
||||
if ( $default['state'] && $default['state'] !== $state ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CRUD methods
|
||||
|
@ -995,10 +991,10 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
update_user_meta( $this->get_id(), 'last_update', $this->get_date_modified() );
|
||||
update_user_meta( $this->get_id(), 'first_name', $this->get_first_name() );
|
||||
update_user_meta( $this->get_id(), 'last_name', $this->get_last_name() );
|
||||
$this->set_date_modified( time() );
|
||||
wp_update_user( array( 'ID' => $this->get_id(), 'role' => $this->get_role() ) );
|
||||
$wp_user = new WP_User( $this->get_id() );
|
||||
$this->set_date_created( strtotime( $wp_user->user_registered ) );
|
||||
$this->set_date_modified( get_user_meta( $this->get_id(), 'last_update', true ) );
|
||||
$this->read_meta_data();
|
||||
}
|
||||
}
|
||||
|
@ -1011,80 +1007,35 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
public function read( $id ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( $id ) {
|
||||
// Only continue reading if the customer exists.
|
||||
$user_object = get_userdata( $id );
|
||||
|
||||
if ( empty( $user_object ) || empty( $user_object->ID ) ) {
|
||||
$this->_data['id'] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
foreach ( array_keys( $this->_data ) as $key ) {
|
||||
$meta_value = get_user_meta( $id, $key, true );
|
||||
if ( $meta_value && is_callable( array( $this, "set_{$key}" ) ) ) {
|
||||
$this->{"set_{$key}"}( $meta_value );
|
||||
}
|
||||
}
|
||||
|
||||
$this->set_is_paying_customer( get_user_meta( $id, 'paying_customer', true ) );
|
||||
$wp_user = new WP_User( $id );
|
||||
$this->set_email( $wp_user->user_email );
|
||||
$this->set_username( $wp_user->user_login );
|
||||
$this->set_date_created( strtotime( $wp_user->user_registered ) );
|
||||
$this->set_date_modified( get_user_meta( $id, 'last_update', true ) );
|
||||
$this->set_role( ( ! empty ( $wp_user->roles[0] ) ? $wp_user->roles[0] : 'customer' ) );
|
||||
|
||||
// Get info about user's last order
|
||||
$last_order = $wpdb->get_row( "SELECT id, post_date_gmt
|
||||
FROM $wpdb->posts AS posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = {$id}
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( '" . implode( "','", array_keys( wc_get_order_statuses() ) ) . "' )
|
||||
ORDER BY posts.ID DESC
|
||||
" );
|
||||
|
||||
$this->set_last_order_id( is_object( $last_order ) ? $last_order->id : null );
|
||||
$this->set_last_order_date( is_object( $last_order ) ? strtotime( $last_order->post_date_gmt ) : null );
|
||||
|
||||
// WC_Customer can't use wc_get_customer_order_count because get_order_types might not be loaded by the time a customer/session is
|
||||
|
||||
$count = $wpdb->get_var( "SELECT COUNT(*)
|
||||
FROM $wpdb->posts as posts
|
||||
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ('" . implode( "','", array_keys( wc_get_order_statuses() ) ) . "')
|
||||
AND meta_value = $id
|
||||
" );
|
||||
|
||||
$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
|
||||
FROM $wpdb->posts as posts
|
||||
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id
|
||||
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = $id
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( 'wc-completed', 'wc-processing' )
|
||||
AND meta2.meta_key = '_order_total'
|
||||
" );
|
||||
if ( ! $spent ) {
|
||||
$spent = 0;
|
||||
}
|
||||
|
||||
$this->set_orders_count( $count );
|
||||
$this->set_total_spent( $spent );
|
||||
$this->read_meta_data();
|
||||
// User object is required.
|
||||
if ( ! $id || ! ( $user_object = get_user_by( 'id', $id ) ) || empty( $user_object->ID ) ) {
|
||||
$this->set_id( 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
// Only users on this site should be read.
|
||||
if ( is_multisite() && ! is_user_member_of_blog( $id ) ) {
|
||||
$this->set_id( 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
$this->set_id( $user_object->ID );
|
||||
|
||||
foreach ( array_keys( $this->_data ) as $key ) {
|
||||
$meta_value = get_user_meta( $id, $key, true );
|
||||
if ( $meta_value && is_callable( array( $this, "set_{$key}" ) ) ) {
|
||||
$this->{"set_{$key}"}( $meta_value );
|
||||
}
|
||||
}
|
||||
|
||||
$this->set_is_paying_customer( get_user_meta( $id, 'paying_customer', true ) );
|
||||
$this->set_email( $user_object->user_email );
|
||||
$this->set_username( $user_object->user_login );
|
||||
$this->set_date_created( strtotime( $user_object->user_registered ) );
|
||||
$this->set_date_modified( get_user_meta( $id, 'last_update', true ) );
|
||||
$this->set_role( ( ! empty ( $user_object->roles[0] ) ? $user_object->roles[0] : 'customer' ) );
|
||||
$this->read_meta_data();
|
||||
|
||||
unset( $this->_data['password'] ); // password is write only, never ever read it
|
||||
}
|
||||
|
||||
|
@ -1123,11 +1074,10 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
update_user_meta( $this->get_id(), 'shipping_state', $this->get_shipping_state() );
|
||||
update_user_meta( $this->get_id(), 'shipping_country', $this->get_shipping_country() );
|
||||
update_user_meta( $this->get_id(), 'paying_customer', $this->get_is_paying_customer() );
|
||||
$this->set_date_modified( time() );
|
||||
update_user_meta( $this->get_id(), 'last_update', $this->get_date_modified() );
|
||||
update_user_meta( $this->get_id(), 'first_name', $this->get_first_name() );
|
||||
update_user_meta( $this->get_id(), 'last_name', $this->get_last_name() );
|
||||
wp_update_user( array( 'ID' => $this->get_id(), 'role' => $this->get_role() ) );
|
||||
$this->set_date_modified( get_user_meta( $this->get_id(), 'last_update', true ) );
|
||||
$this->save_meta_data();
|
||||
}
|
||||
|
||||
|
|
|
@ -663,14 +663,12 @@ function wc_format_postcode( $postcode, $country ) {
|
|||
$postcode = trim( substr_replace( $postcode, ' ', -3, 0 ) );
|
||||
break;
|
||||
case 'BR' :
|
||||
case 'PL' :
|
||||
$postcode = trim( substr_replace( $postcode, '-', -3, 0 ) );
|
||||
break;
|
||||
case 'JP' :
|
||||
$postcode = trim( substr_replace( $postcode, '-', 3, 0 ) );
|
||||
break;
|
||||
case 'PL' :
|
||||
$postcode = trim( substr_replace( $postcode, '-', -3, 0 ) );
|
||||
break;
|
||||
case 'PT' :
|
||||
$postcode = trim( substr_replace( $postcode, '-', 4, 0 ) );
|
||||
break;
|
||||
|
|
|
@ -88,7 +88,6 @@ And, finally, consider joining or spearheading a WooCommerce Meetup locally, mor
|
|||
|
||||
= Minimum Requirements =
|
||||
|
||||
* WordPress 3.8 or greater
|
||||
* PHP version 5.2.4 or greater (PHP 5.6 or greater is recommended)
|
||||
* MySQL version 5.0 or greater (MySQL 5.6 or greater is recommended)
|
||||
* Some payment gateways require fsockopen support (for IPN access)
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
<?php
|
||||
namespace WooCommerce\Tests\API;
|
||||
|
||||
/**
|
||||
* Coupon API Tests
|
||||
* @package WooCommerce\Tests\API
|
||||
* @since 2.7.0
|
||||
*/
|
||||
class Coupons extends \WC_API_Unit_Test_Case {
|
||||
class WC_Tests_API_Coupons extends WC_API_Unit_Test_Case {
|
||||
|
||||
/** @var \WC_API_Coupons instance */
|
||||
/** @var WC_API_Coupons instance */
|
||||
protected $endpoint;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +17,7 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->endpoint = WC()->api->WC_API_Coupons;
|
||||
$this->coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$this->coupon = WC_Helper_Coupon::create_coupon();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -196,7 +194,7 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
$response = $this->endpoint->create_coupon( $this->get_defaults() );
|
||||
$this->assertNotWPError( $response );
|
||||
$this->assertArrayHasKey( 'coupon', $response );
|
||||
$this->check_get_coupon_response( $response['coupon'], new \WC_Coupon( $response['coupon']['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupon'], new WC_Coupon( $response['coupon']['code'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +259,7 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
|
||||
$this->assertNotWPError( $response );
|
||||
$this->assertArrayHasKey( 'coupon', $response );
|
||||
$this->check_get_coupon_response( $response['coupon'], new \WC_Coupon( $response['coupon']['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupon'], new WC_Coupon( $response['coupon']['code'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -301,8 +299,8 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
$this->assertNotWPError( $response );
|
||||
$this->assertArrayHasKey( 'coupons', $response );
|
||||
$this->assertCount( 2, $response['coupons'] );
|
||||
$this->check_get_coupon_response( $response['coupons'][0], new \WC_Coupon( $response['coupons'][0]['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupons'][1], new \WC_Coupon( $response['coupons'][1]['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupons'][0], new WC_Coupon( $response['coupons'][0]['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupons'][1], new WC_Coupon( $response['coupons'][1]['code'] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -310,14 +308,14 @@ class Coupons extends \WC_API_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_edit_coupon_bulk() {
|
||||
$coupon_1 = \WC_Helper_Coupon::create_coupon( 'dummycoupon-1-' . time() );
|
||||
$coupon_1 = WC_Helper_Coupon::create_coupon( 'dummycoupon-1-' . time() );
|
||||
$test_coupon_data = $this->get_defaults( array( 'description' => rand_str() ) );
|
||||
$test_coupon_data['coupon']['id'] = $coupon_1->get_id();
|
||||
$coupons = array( 'coupons' => array( $test_coupon_data['coupon'] ) );
|
||||
$response = $this->endpoint->bulk( $coupons );
|
||||
$this->assertNotWPError( $response );
|
||||
$this->assertArrayHasKey( 'coupons', $response );
|
||||
$this->check_get_coupon_response( $response['coupons'][0], new \WC_Coupon( $response['coupons'][0]['code'] ) );
|
||||
$this->check_get_coupon_response( $response['coupons'][0], new WC_Coupon( $response['coupons'][0]['code'] ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace WooCommerce\Tests\Coupon;
|
||||
|
||||
/**
|
||||
* Class CRUD
|
||||
* @package WooCommerce\Tests\Coupon
|
||||
*/
|
||||
class CouponCRUD extends \WC_Unit_Test_Case {
|
||||
class WC_Tests_CouponCRUD extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Some of our get/setters were renamed. This will return the function
|
||||
|
@ -33,7 +31,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
function test_coupon_create() {
|
||||
$code = 'coupon-' . time();
|
||||
$coupon = new \WC_Coupon;
|
||||
$coupon = new WC_Coupon;
|
||||
$coupon->set_code( $code );
|
||||
$coupon->set_description( 'This is a test comment.' );
|
||||
$coupon->create();
|
||||
|
@ -47,7 +45,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
function test_coupon_delete() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$this->assertNotEquals( 0, $coupon_id );
|
||||
$coupon->delete();
|
||||
|
@ -60,7 +58,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
function test_coupon_update() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$this->assertEquals( 'dummycoupon', $coupon->get_code() );
|
||||
$coupon->set_code( 'dummycoupon2' );
|
||||
|
@ -75,14 +73,14 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
function test_coupon_read() {
|
||||
$code = 'coupon-' . time();
|
||||
$coupon = new \WC_Coupon;
|
||||
$coupon = new WC_Coupon;
|
||||
$coupon->set_code( $code );
|
||||
$coupon->set_description( 'This is a test coupon.' );
|
||||
$coupon->set_usage_count( 5 );
|
||||
$coupon->create();
|
||||
$coupon_id = $coupon->get_id();
|
||||
|
||||
$coupon_read = new \WC_Coupon;
|
||||
$coupon_read = new WC_Coupon;
|
||||
$coupon_read->read( $coupon_id );
|
||||
|
||||
$this->assertEquals( 5, $coupon_read->get_usage_count() );
|
||||
|
@ -95,7 +93,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
function test_coupon_save() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$coupon->set_code( 'dummycoupon2' );
|
||||
$coupon->save();
|
||||
|
@ -103,7 +101,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
$this->assertEquals( 'dummycoupon2', $coupon->get_code() );
|
||||
$this->assertEquals( $coupon_id, $coupon->get_id() );
|
||||
|
||||
$new_coupon = new \WC_Coupon;
|
||||
$new_coupon = new WC_Coupon;
|
||||
$new_coupon->set_code( 'dummycoupon3' );
|
||||
$new_coupon->save();
|
||||
$new_coupon_id = $new_coupon->get_id();
|
||||
|
@ -127,7 +125,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
);
|
||||
$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $legacy_keys );
|
||||
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
add_post_meta( $coupon->get_id(), 'test_coupon_field', 'testing', true );
|
||||
$coupon->read( $coupon->get_id() );
|
||||
|
||||
|
@ -161,7 +159,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_read_manual_coupon() {
|
||||
$code = 'manual_coupon_' . time();
|
||||
$coupon = new \WC_Coupon( $code );
|
||||
$coupon = new WC_Coupon( $code );
|
||||
$coupon->read_manual_coupon( $code, array(
|
||||
'id' => true,
|
||||
'type' => 'fixed_cart',
|
||||
|
@ -193,7 +191,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
$legacy_keys = array( 'product_ids', 'exclude_product_ids', 'individual_use', 'free_shipping', 'exclude_sale_items' );
|
||||
$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $legacy_keys );
|
||||
$code = 'bc_manual_coupon_' . time();
|
||||
$coupon = new \WC_Coupon( $code );
|
||||
$coupon = new WC_Coupon( $code );
|
||||
$coupon->read_manual_coupon( $code, array(
|
||||
'id' => true,
|
||||
'type' => 'fixed_cart',
|
||||
|
@ -236,7 +234,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
'customer_email' => array( 'test@woo.local' ), 'used_by' => array( 1 ),
|
||||
);
|
||||
|
||||
$coupon = new \WC_Coupon;
|
||||
$coupon = new WC_Coupon;
|
||||
foreach ( $standard_getters_and_setters as $function => $value ) {
|
||||
$function = $this->get_function_name( $function );
|
||||
$coupon->{"set_{$function}"}( $value );
|
||||
|
@ -249,7 +247,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_custom_fields() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$meta_value = time() . '-custom-value';
|
||||
add_post_meta( $coupon_id, 'test_coupon_field', $meta_value, true );
|
||||
|
@ -264,7 +262,7 @@ class CouponCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_set_custom_fields() {
|
||||
$coupon = \WC_Helper_Coupon::create_coupon();
|
||||
$coupon = WC_Helper_Coupon::create_coupon();
|
||||
$coupon_id = $coupon->get_id();
|
||||
$meta_value = time() . '-custom-value';
|
||||
$coupon->add_meta_data( 'my-custom-field', $meta_value, true );
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
namespace WooCommerce\Tests\Customer;
|
||||
|
||||
/**
|
||||
* Class CustomerCRUD.
|
||||
* @package WooCommerce\Tests\Customer
|
||||
*/
|
||||
class CustomerCRUD extends \WC_Unit_Test_Case {
|
||||
class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Test creating a new customer.
|
||||
|
@ -13,12 +12,12 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_create_customer() {
|
||||
$username = 'testusername-' . time();
|
||||
$customer = new \WC_Customer();
|
||||
$customer = new WC_Customer();
|
||||
$customer->set_username( 'testusername-' . time() );
|
||||
$customer->set_password( 'test123' );
|
||||
$customer->set_email( 'test@woo.local' );
|
||||
$customer->create();
|
||||
$wp_user = new \WP_User( $customer->get_id() );
|
||||
$wp_user = new WP_User( $customer->get_id() );
|
||||
|
||||
$this->assertEquals( $username, $customer->get_username() );
|
||||
$this->assertNotEquals( 0, $customer->get_id() );
|
||||
|
@ -30,7 +29,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_update_customer() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$this->assertEquals( 'test@woo.local', $customer->get_email() );
|
||||
$this->assertEquals( 'Apt 1', $customer->get_billing_address_2() );
|
||||
|
@ -39,7 +38,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$customer->set_billing_address_2( 'Apt 5' );
|
||||
$customer->update();
|
||||
|
||||
$customer = new \WC_Customer( $customer_id ); // so we can read fresh copies from the DB
|
||||
$customer = new WC_Customer( $customer_id ); // so we can read fresh copies from the DB
|
||||
$this->assertEquals( 'test@wc.local', $customer->get_email() );
|
||||
$this->assertEquals( 'Justin', $customer->get_first_name() );
|
||||
$this->assertEquals( 'Apt 5', $customer->get_billing_address_2() );
|
||||
|
@ -52,14 +51,14 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_save_customer() {
|
||||
// test save() -> Create
|
||||
$customer = new \WC_Customer();
|
||||
$customer = new WC_Customer();
|
||||
$customer->set_username( 'testusername-' . time() );
|
||||
$customer->set_password( 'test123' );
|
||||
$customer->set_email( 'test@woo.local' );
|
||||
$this->assertEquals( 0, $customer->get_id() );
|
||||
$customer->save();
|
||||
$customer_id = $customer->get_id();
|
||||
$wp_user = new \WP_User( $customer->get_id() );
|
||||
$wp_user = new WP_User( $customer->get_id() );
|
||||
|
||||
$this->assertNotEquals( 0, $customer->get_id() );
|
||||
|
||||
|
@ -68,7 +67,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$customer->set_email( 'test@wc.local' );
|
||||
$customer->save();
|
||||
|
||||
$customer = new \WC_Customer( $customer_id );
|
||||
$customer = new WC_Customer( $customer_id );
|
||||
$this->assertEquals( 'test@wc.local', $customer->get_email() );
|
||||
}
|
||||
|
||||
|
@ -77,7 +76,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_delete_customer() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$this->assertNotEquals( 0, $customer->get_id() );
|
||||
$customer->delete();
|
||||
|
@ -91,7 +90,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_read_customer() {
|
||||
$username = 'user-' . time();
|
||||
$customer = new \WC_Customer();
|
||||
$customer = new WC_Customer();
|
||||
$customer->set_username( $username );
|
||||
$customer->set_email( 'test@woo.local' );
|
||||
$customer->set_password( 'hunter2' );
|
||||
|
@ -99,7 +98,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$customer->set_last_name( 'Bob' );
|
||||
$customer->create();
|
||||
$customer_id = $customer->get_id();
|
||||
$customer_read = new \WC_Customer();
|
||||
$customer_read = new WC_Customer();
|
||||
$customer_read->read( $customer_id );
|
||||
|
||||
$this->assertEquals( $customer_id, $customer_read->get_id() );
|
||||
|
@ -132,7 +131,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
|
||||
$this->expected_doing_it_wrong = array_merge( $this->expected_doing_it_wrong, $legacy_keys );
|
||||
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
|
||||
$this->assertEquals( $customer->get_id(), $customer->id );
|
||||
$this->assertEquals( $customer->get_billing_country(), $customer->country );
|
||||
|
@ -172,8 +171,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$time = time();
|
||||
$standard_getters_and_setters = array(
|
||||
'username' => 'test', 'email' => 'test@woo.local', 'first_name' => 'Bob', 'last_name' => 'tester',
|
||||
'role' => 'customer', 'last_order_id' => 5, 'last_order_date' => $time, 'orders_count' => 2,
|
||||
'total_spent' => 10.57, 'date_created' => $time, 'date_modified' => $time, 'billing_postcode' => 11010,
|
||||
'role' => 'customer', 'date_created' => $time, 'date_modified' => $time, 'billing_postcode' => 11010,
|
||||
'billing_city' => 'New York', 'billing_address' => '123 Main St.', 'billing_address_1' => '123 Main St.', 'billing_address_2' => 'Apt 2', 'billing_state' => 'NY',
|
||||
'billing_country' => 'US', 'shipping_state' => 'NY', 'shipping_postcode' => 11011, 'shipping_city' =>
|
||||
'New York', 'shipping_address' => '123 Main St.', 'shipping_address_1' => '123 Main St.',
|
||||
|
@ -181,7 +179,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
'is_paying_customer' => true
|
||||
);
|
||||
|
||||
$customer = new \WC_Customer;
|
||||
$customer = new WC_Customer;
|
||||
foreach ( $standard_getters_and_setters as $function => $value ) {
|
||||
$customer->{"set_{$function}"}( $value );
|
||||
$this->assertEquals( $value, $customer->{"get_{$function}"}(), $function );
|
||||
|
@ -193,12 +191,13 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_last_order_info() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$order = \WC_Helper_Order::create_order( $customer_id );
|
||||
$order = WC_Helper_Order::create_order( $customer_id );
|
||||
$customer->read( $customer_id );
|
||||
$this->assertEquals( $order->get_id(), $customer->get_last_order_id() );
|
||||
$this->assertEquals( $order->get_date_created(), $customer->get_last_order_date() );
|
||||
$last_order = $customer->get_last_order();
|
||||
$this->assertEquals( $order->get_id(), $last_order ? $last_order->get_id() : 0 );
|
||||
$this->assertEquals( $order->get_date_created(), $last_order ? $last_order->get_date_created() : 0 );
|
||||
$order->delete();
|
||||
}
|
||||
|
||||
|
@ -206,14 +205,14 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* Test getting a customer's order count from DB.
|
||||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_orders_count_read() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
public function test_customer_get_order_count_read() {
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
\WC_Helper_Order::create_order( $customer_id );
|
||||
\WC_Helper_Order::create_order( $customer_id );
|
||||
\WC_Helper_Order::create_order( $customer_id );
|
||||
WC_Helper_Order::create_order( $customer_id );
|
||||
WC_Helper_Order::create_order( $customer_id );
|
||||
WC_Helper_Order::create_order( $customer_id );
|
||||
$customer->read( $customer_id );
|
||||
$this->assertEquals( 3, $customer->get_orders_count() );
|
||||
$this->assertEquals( 3, $customer->get_order_count() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,9 +220,9 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_total_spent_read() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$order = \WC_Helper_Order::create_order( $customer_id );
|
||||
$order = WC_Helper_Order::create_order( $customer_id );
|
||||
$customer->read( $customer_id );
|
||||
$this->assertEquals( 0, $customer->get_total_spent() );
|
||||
$order->update_status( 'wc-completed' );
|
||||
|
@ -237,7 +236,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_avatar_url() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$this->assertContains( 'gravatar.com/avatar', $customer->get_avatar_url() );
|
||||
$this->assertContains( md5( 'test@woo.local' ), $customer->get_avatar_url() );
|
||||
}
|
||||
|
@ -247,9 +246,9 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_date_created_read() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$user = new \WP_User( $customer_id );
|
||||
$user = new WP_User( $customer_id );
|
||||
$this->assertEquals( strtotime( $user->data->user_registered ), $customer->get_date_created() );
|
||||
}
|
||||
|
||||
|
@ -258,7 +257,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_date_modified_read() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$last = get_user_meta( $customer_id, 'last_update', true );
|
||||
sleep(1);
|
||||
|
@ -275,7 +274,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_taxable_address() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$customer->set_shipping_postcode( '11111' );
|
||||
$customer->set_shipping_city( 'Test' );
|
||||
|
@ -309,7 +308,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_get_downloadable_products() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$this->assertEquals( wc_get_customer_available_downloads( $customer_id ), $customer->get_downloadable_products() );
|
||||
}
|
||||
|
@ -319,7 +318,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_password() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
|
||||
$user = get_user_by( 'id', $customer_id );
|
||||
|
@ -337,7 +336,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_set_address_to_base() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer->set_billing_address_to_base();
|
||||
$base = wc_get_customer_default_location();
|
||||
$this->assertEquals( $base['country'], $customer->get_billing_country() );
|
||||
|
@ -351,7 +350,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_set_shipping_address_to_base() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer->set_shipping_address_to_base();
|
||||
$base = wc_get_customer_default_location();
|
||||
$this->assertEquals( $base['country'], $customer->get_shipping_country() );
|
||||
|
@ -365,7 +364,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_set_location() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer->set_billing_location( 'US', 'OH', '12345', 'Cleveland' );
|
||||
$this->assertEquals( 'US', $customer->get_billing_country() );
|
||||
$this->assertEquals( 'OH', $customer->get_billing_state() );
|
||||
|
@ -378,7 +377,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_set_shipping_location() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer->set_shipping_location( 'US', 'OH', '12345', 'Cleveland' );
|
||||
$this->assertEquals( 'US', $customer->get_shipping_country() );
|
||||
$this->assertEquals( 'OH', $customer->get_shipping_state() );
|
||||
|
@ -391,7 +390,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_is_customer_outside_base() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$this->assertTrue( $customer->is_customer_outside_base() );
|
||||
update_option( 'woocommerce_tax_based_on', 'base' );
|
||||
$customer->set_billing_address_to_base();
|
||||
|
@ -403,8 +402,8 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_customer_sessions() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$session = \WC_Helper_Customer::create_mock_customer(); // set into session....
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$session = WC_Helper_Customer::create_mock_customer(); // set into session....
|
||||
|
||||
$this->assertEquals( '19123', $session->get_billing_postcode() );
|
||||
$this->assertEquals( '123 South Street', $session->get_billing_address() );
|
||||
|
@ -413,11 +412,11 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
$session->set_billing_address( '124 South Street' );
|
||||
$session->save_to_session();
|
||||
|
||||
$session = new \WC_Customer( 0, true );
|
||||
$session = new WC_Customer( 0, true );
|
||||
$session->load_session();
|
||||
$this->assertEquals( '124 South Street', $session->get_billing_address() );
|
||||
|
||||
$session = new \WC_Customer( 0, true );
|
||||
$session = new WC_Customer( 0, true );
|
||||
$session->load_session();
|
||||
$session->set_billing_postcode( '32191' );
|
||||
$session->save();
|
||||
|
@ -432,7 +431,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_get_meta() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$meta_value = time() . '-custom-value';
|
||||
add_user_meta( $customer_id, 'test_field', $meta_value, true );
|
||||
|
@ -446,7 +445,7 @@ class CustomerCRUD extends \WC_Unit_Test_Case {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
public function test_set_meta() {
|
||||
$customer = \WC_Helper_Customer::create_customer();
|
||||
$customer = WC_Helper_Customer::create_customer();
|
||||
$customer_id = $customer->get_id();
|
||||
$meta_value = time() . '-custom-value';
|
||||
$customer->add_meta_data( 'my-field', $meta_value, true );
|
||||
|
|
Loading…
Reference in New Issue