Handle tear down for unit tests

This commit is contained in:
Almira Krdzic
2018-08-14 12:12:54 +02:00
parent bb3fecd811
commit 3cc72d6d84
5 changed files with 39 additions and 9 deletions

View File

@@ -13,11 +13,12 @@ class Wiaas_Order_Test extends Wiaas_Unit_Test_Case {
wp_set_current_user(1);
# create customer user
$this->customer_id = wc_create_new_customer(
'test_customer@mail.com',
'test_customer',
'test');
$this->customer_id = wp_insert_user(array(
'user_login' => 'test_customer',
'user_pass' => 'test',
'user_email' => 'test_customer@mail.com',
'role' => 'customer',
));
$this->customer_organization_name = 'test-customer-organization';
@@ -42,6 +43,18 @@ class Wiaas_Order_Test extends Wiaas_Unit_Test_Case {
$this->order_id = $order->get_id();
}
function tearDown() {
parent::tearDown();
wp_set_current_user(1);
wp_delete_user($this->customer_id);
wp_delete_term(
$this->customer_organization_id,
Wiaas_User_Organization::TAXONOMY_NAME);
}
/**
* @covers Wiaas_Order::assign_order_to_organization()
*/