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

@@ -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/groups/groups.php';
require_once '/tmp/wiaas-backend-test/app/plugins/wp-user-groups/wp-user-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'; require_once '/tmp/wiaas-backend-test/app/plugins/wiaas/wiaas.php';

View File

@@ -13,11 +13,12 @@ class Wiaas_Order_Test extends Wiaas_Unit_Test_Case {
wp_set_current_user(1); wp_set_current_user(1);
# create customer user $this->customer_id = wp_insert_user(array(
$this->customer_id = wc_create_new_customer( 'user_login' => 'test_customer',
'test_customer@mail.com', 'user_pass' => 'test',
'test_customer', 'user_email' => 'test_customer@mail.com',
'test'); 'role' => 'customer',
));
$this->customer_organization_name = 'test-customer-organization'; $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(); $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() * @covers Wiaas_Order::assign_order_to_organization()
*/ */

View File

@@ -35,9 +35,6 @@ class Wiass_REST_Delivery_Process_Api_Test extends Wiaas_Unit_Test_Case {
$this->assertNotNull($next_steps); $this->assertNotNull($next_steps);
$this->assertTrue(is_array($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]; $pending_step = $next_steps[0];
$this->assertTrue(is_array($pending_step)); $this->assertTrue(is_array($pending_step));

View File

@@ -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_id = wp_create_user('test', 'test', 'test@mail.com');
$this->user_organization_name = 'test_organization'; $this->user_organization_name = 'test_organization';
$this->user_department_name = 'test-department'; $this->user_department_name = 'test_department';
# create organization # create organization
$this->user_organization_id = wp_insert_term( $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]); [$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() * @covers Wiaas_User_Organization::get_user_organization()
*/ */

View File

@@ -16,4 +16,8 @@ class Wiaas_Unit_Test_Case extends WP_UnitTestCase {
wiaas_db_update_enable_orders_access_management(); wiaas_db_update_enable_orders_access_management();
} }
function tearDown() {
parent::tearDown();
}
} }