Files
old-new-wiaas/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-rest-delivery-process-api.php
Almira Krdzic 5afdde434b Delivery setup
2018-08-06 17:36:57 +02:00

56 lines
1.4 KiB
PHP

<?php
/**
* Wiaas_Delivery_Process_Step_Test
*
* @package Wiaas
*/
class Wiass_REST_Delivery_Process_Api_Test extends Wiaas_Unit_Test_Case {
var $order_id, $api;
function setUp() {
parent::setUp();
$order = wc_create_order();
$this->order_id = $order->get_id();
wp_set_current_user(1);
}
/**
* @covers Wiass_REST_Delivery_Process_API::get_next_actions_for_user
*/
function test_get_next_actions_for_user() {
wp_set_current_user(1);
$response = Wiass_REST_Delivery_Process_API::get_next_actions_for_user();
$this->assertNotNull($response);
$this->assertInstanceOf('WP_REST_Response', $response);
$next_steps = $response->get_data();
$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));
$this->assertArrayHasKey('idOrder', $pending_step);
$this->assertArrayHasKey('orderNumber', $pending_step);
$this->assertArrayHasKey('status', $pending_step);
$this->assertArrayHasKey('stepAction', $pending_step);
$this->assertEquals($pending_step['idOrder'], $this->order_id);
$this->assertEquals($pending_step['orderNumber'], $this->order_id);
$this->assertEquals($pending_step['status'], 'pending');
$this->assertNotEmpty($pending_step['stepAction']);
}
}