Finish user func tests
This commit is contained in:
parent
ddd86bcff4
commit
384e8d85f4
|
@ -269,7 +269,32 @@ class WC_Tests_Customer_Functions extends WC_Unit_Test_Case {
|
|||
* @since 3.1
|
||||
*/
|
||||
function test_wc_get_customer_total_spent() {
|
||||
$customer_id_1 = wc_create_new_customer( 'test@example.com', 'testuser', 'testpassword' );
|
||||
$customer_id_2 = wc_create_new_customer( 'test2@example.com', 'testuser2', 'testpassword2' );
|
||||
|
||||
$order_1 = new WC_Order;
|
||||
$order_1->set_status( 'completed' );
|
||||
$order_1->set_total( '100.00' );
|
||||
$order_1->set_customer_id( $customer_id_1 );
|
||||
$order_1->save();
|
||||
$order_2 = new WC_Order;
|
||||
$order_2->set_status( 'completed' );
|
||||
$order_2->set_total( '15.50' );
|
||||
$order_2->set_customer_id( $customer_id_1 );
|
||||
$order_2->save();
|
||||
$order_3 = new WC_Order;
|
||||
$order_3->set_status( 'completed' );
|
||||
$order_3->set_total( '50.01' );
|
||||
$order_3->set_customer_id( $customer_id_2 );
|
||||
$order_3->save();
|
||||
$order_4 = new WC_Order;
|
||||
$order_4->set_status( 'pending' );
|
||||
$order_4->set_total( '1.00' );
|
||||
$order_4->set_customer_id( $customer_id_2 );
|
||||
$order_4->save();
|
||||
|
||||
$this->assertEquals( 115.5, wc_get_customer_total_spent( $customer_id_1 ) );
|
||||
$this->assertEquals( 50.01, wc_get_customer_total_spent( $customer_id_2 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,7 +303,21 @@ class WC_Tests_Customer_Functions extends WC_Unit_Test_Case {
|
|||
* @since 3.1
|
||||
*/
|
||||
function test_wc_get_customer_order_count() {
|
||||
$customer_id_1 = wc_create_new_customer( 'test@example.com', 'testuser', 'testpassword' );
|
||||
$customer_id_2 = wc_create_new_customer( 'test2@example.com', 'testuser2', 'testpassword2' );
|
||||
|
||||
$order_1 = new WC_Order;
|
||||
$order_1->set_customer_id( $customer_id_1 );
|
||||
$order_1->save();
|
||||
$order_2 = new WC_Order;
|
||||
$order_2->set_customer_id( $customer_id_1 );
|
||||
$order_2->save();
|
||||
$order_3 = new WC_Order;
|
||||
$order_3->set_customer_id( $customer_id_2 );
|
||||
$order_3->save();
|
||||
|
||||
$this->assertEquals( 2, wc_get_customer_order_count( $customer_id_1 ) );
|
||||
$this->assertEquals( 1, wc_get_customer_order_count( $customer_id_2 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,16 +326,17 @@ class WC_Tests_Customer_Functions extends WC_Unit_Test_Case {
|
|||
* @since 3.1
|
||||
*/
|
||||
function test_wc_reset_order_customer_id_on_deleted_user() {
|
||||
$customer_id = wc_create_new_customer( 'test@example.com', 'testuser', 'testpassword' );
|
||||
$customer = new WC_Customer( $customer_id );
|
||||
|
||||
}
|
||||
$order = new WC_Order;
|
||||
$order->set_customer_id( $customer_id );
|
||||
$order->save();
|
||||
|
||||
/**
|
||||
* Test wc_review_is_from_verified_owner.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
function test_wc_review_is_from_verified_owner() {
|
||||
$customer->delete();
|
||||
|
||||
$order = new WC_Order( $order->get_id() );
|
||||
$this->assertEquals( 0, $order->get_customer_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -305,15 +345,16 @@ class WC_Tests_Customer_Functions extends WC_Unit_Test_Case {
|
|||
* @since 3.1
|
||||
*/
|
||||
function test_wc_get_customer_last_order() {
|
||||
$customer_id = wc_create_new_customer( 'test@example.com', 'testuser', 'testpassword' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_get_customer_avatar_url.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
function test_wc_get_customer_avatar_url() {
|
||||
$order_1 = new WC_Order;
|
||||
$order_1->set_customer_id( $customer_id );
|
||||
$order_1->save();
|
||||
$order_2 = new WC_Order;
|
||||
$order_2->set_customer_id( $customer_id );
|
||||
$order_2->save();
|
||||
|
||||
$last_order = wc_get_customer_last_order( $customer_id );
|
||||
$this->assertEquals( $order_2->get_id(), $last_order->get_id() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue