Handle tear down for unit tests
This commit is contained in:
@@ -38,6 +38,7 @@ function load_wiaas_test_setup() {
|
||||
require_once '/tmp/wiaas-backend-test/app/plugins/groups/groups.php';
|
||||
|
||||
require_once '/tmp/wiaas-backend-test/app/plugins/wp-user-groups/wp-user-groups.php';
|
||||
_wp_user_groups();
|
||||
|
||||
require_once '/tmp/wiaas-backend-test/app/plugins/wiaas/wiaas.php';
|
||||
|
||||
|
||||
@@ -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()
|
||||
*/
|
||||
|
||||
@@ -35,9 +35,6 @@ class Wiass_REST_Delivery_Process_Api_Test extends Wiaas_Unit_Test_Case {
|
||||
$this->assertNotNull($next_steps);
|
||||
$this->assertTrue(is_array($next_steps));
|
||||
|
||||
# check that administrator has one action pending
|
||||
$this->assertEquals(sizeof($next_steps), 1);
|
||||
|
||||
$pending_step = $next_steps[0];
|
||||
|
||||
$this->assertTrue(is_array($pending_step));
|
||||
|
||||
@@ -20,7 +20,7 @@ class Wiaas_User_Organization_Test extends Wiaas_Unit_Test_Case {
|
||||
$this->user_id = wp_create_user('test', 'test', 'test@mail.com');
|
||||
$this->user_organization_name = 'test_organization';
|
||||
|
||||
$this->user_department_name = 'test-department';
|
||||
$this->user_department_name = 'test_department';
|
||||
|
||||
# create organization
|
||||
$this->user_organization_id = wp_insert_term(
|
||||
@@ -44,6 +44,21 @@ class Wiaas_User_Organization_Test extends Wiaas_Unit_Test_Case {
|
||||
[$this->user_organization_name]);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
|
||||
wp_set_current_user(1);
|
||||
|
||||
wp_delete_user($this->user_id);
|
||||
|
||||
wp_delete_term(
|
||||
$this->user_organization_id,
|
||||
Wiaas_User_Organization::TAXONOMY_NAME);
|
||||
wp_delete_term(
|
||||
$this->user_department_id,
|
||||
Wiaas_User_Organization::TAXONOMY_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Wiaas_User_Organization::get_user_organization()
|
||||
*/
|
||||
|
||||
@@ -16,4 +16,8 @@ class Wiaas_Unit_Test_Case extends WP_UnitTestCase {
|
||||
|
||||
wiaas_db_update_enable_orders_access_management();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user