-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from route4me/order_v5
Support OrderV5 and field 'order_uuid' in OrderV4.
- Loading branch information
Showing
20 changed files
with
2,149 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,26 +152,24 @@ public function testToArray() | |
], | ||
]); | ||
|
||
$this->assertEquals($orderParameters->toArray(), | ||
[ | ||
'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US', | ||
'cached_lat' => 48.335991, | ||
'cached_lng' => 31.18287, | ||
'address_alias' => 'Auto test address', | ||
'address_city' => 'Philadelphia', | ||
'day_scheduled_for_YYMMDD' => date('Y-m-d'), | ||
'EXT_FIELD_first_name' => 'Igor', | ||
'EXT_FIELD_last_name' => 'Progman', | ||
'EXT_FIELD_email' => '[email protected]', | ||
'EXT_FIELD_phone' => '380380380380', | ||
'EXT_FIELD_custom_data' => [ | ||
0 => [ | ||
'order_id' => '10', | ||
'name' => 'Bill Soul', | ||
], | ||
$this->assertEquals($orderParameters->toArray(), [ | ||
'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US', | ||
'cached_lat' => 48.335991, | ||
'cached_lng' => 31.18287, | ||
'address_alias' => 'Auto test address', | ||
'address_city' => 'Philadelphia', | ||
'day_scheduled_for_YYMMDD' => date('Y-m-d'), | ||
'EXT_FIELD_first_name' => 'Igor', | ||
'EXT_FIELD_last_name' => 'Progman', | ||
'EXT_FIELD_email' => '[email protected]', | ||
'EXT_FIELD_phone' => '380380380380', | ||
'EXT_FIELD_custom_data' => [ | ||
0 => [ | ||
'order_id' => '10', | ||
'name' => 'Bill Soul', | ||
], | ||
] | ||
); | ||
], | ||
]); | ||
} | ||
|
||
public function testGetOrders() | ||
|
@@ -250,6 +248,8 @@ public function testAddOrdersToOptimization() | |
|
||
public function testAddOrdersToRoute() | ||
{ | ||
$this->markTestSkipped('Read old data.'); | ||
|
||
$body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_route_data.json'), true); | ||
|
||
$routeId = self::$createdProblems[0]->routes[0]->route_id; | ||
|
@@ -324,8 +324,8 @@ public function testCreateOrderWithCustomField() | |
|
||
self::assertNotNull($response); | ||
self::assertInstanceOf(Order::class, Order::fromArray($response)); | ||
$this->assertEquals(93,$response['custom_user_fields'][0]['order_custom_field_id']); | ||
$this->assertEquals(false,$response['custom_user_fields'][0]['order_custom_field_value']); | ||
$this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']); | ||
$this->assertEquals(false, $response['custom_user_fields'][0]['order_custom_field_value']); | ||
|
||
self::$createdOrders[] = $response; | ||
} | ||
|
@@ -347,6 +347,23 @@ public function testGetOrderByID() | |
self::assertInstanceOf(Order::class, Order::fromArray($response)); | ||
} | ||
|
||
public function testGetOrderByUUID() | ||
{ | ||
$order = new Order(); | ||
|
||
$orderUUID = self::$createdOrders[0]['order_uuid']; | ||
|
||
// Get an order | ||
$orderParameters = Order::fromArray([ | ||
'order_id' => $orderUUID, | ||
]); | ||
|
||
$response = $order->getOrder($orderParameters); | ||
|
||
self::assertNotNull($response); | ||
self::assertInstanceOf(Order::class, Order::fromArray($response)); | ||
} | ||
|
||
public function testGetOrderByInsertedDate() | ||
{ | ||
$orderParameters = Order::fromArray([ | ||
|
@@ -484,9 +501,8 @@ public function testUpdateOrder() | |
$this->assertInstanceOf(Order::class, Order::fromArray($response)); | ||
$this->assertEquals('Lviv', $response['address_2']); | ||
$this->assertEquals('032268593', $response['EXT_FIELD_phone']); | ||
$this->assertEquals([ | ||
0 => '{"order_id":"10","name":"Bill Soul"}' | ||
], | ||
$this->assertEquals( | ||
[0 => '{"order_id":"10","name":"Bill Soul"}'], | ||
$response['EXT_FIELD_custom_data'] | ||
); | ||
} | ||
|
@@ -513,6 +529,23 @@ public function testUpdateOrderWithCustomFiel() | |
$this->assertEquals(true, $response['custom_user_fields'][0]['order_custom_field_value']); | ||
} | ||
|
||
public function testDeleteOrderByUuid() | ||
{ | ||
$lastOrder = array_pop(self::$createdOrders); | ||
if ($lastOrder != null) { | ||
$order = new Order(); | ||
$ids = [ | ||
"order_ids" => [$lastOrder['order_uuid']] | ||
]; | ||
|
||
$response = $order->removeOrder($ids); | ||
|
||
if (!is_null($response) && isset($response['status']) && $response['status']) { | ||
echo "The test order removed by UUID <br>"; | ||
} | ||
} | ||
} | ||
|
||
public static function tearDownAfterClass() | ||
{ | ||
if (sizeof(self::$createdOrders)) { | ||
|
Oops, something went wrong.