create unit test

This commit is contained in:
Bilal Catic
2018-09-30 21:21:14 +02:00
parent 925896c469
commit ea9a47fd39

View File

@@ -198,4 +198,28 @@ class Wiaas_Order_Test extends Wiaas_Unit_Test_Case {
$this->assertArrayHasKey('email', $transformed_order_response['commercial_lead']);
$this->assertArrayHasKey('phone', $transformed_order_response['commercial_lead']);
}
/**
* @covers Wiaas_Order::transform_rest_order()
*/
function test_order_rest_response_has_empty_documents_when_package_has_no_documents() {
$order_response = array(
'customer_id' => $this->customer_id,
'status' => 'processing',
'line_items' => array()
);
$request = array( 'id' => $this->order_id);
$order_rest_response = new WP_REST_Response($order_response);
$order_rest_response = Wiaas_Order::transform_rest_order(
$order_rest_response,
wc_get_order($this->order_id),
$request);
$transformed_order_response = $order_rest_response->get_data();
$this->assertNotNull($transformed_order_response['documents']);
$this->assertTrue(is_array($transformed_order_response['documents']));
}
}