GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( d9a634...e591c7 )
by Juan Jose
07:17 queued 16s
created
src/Route4Me/V5/PodWorkflows/ResponsePodWorkflow.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -14,66 +14,66 @@
 block discarded – undo
14 14
  */
15 15
 class ResponsePodWorkflow extends Common
16 16
 {
17
-    /**
18
-     * PodWorkflow GUID
19
-     */
20
-    public ?string $workflow_guid = null;
17
+	/**
18
+	 * PodWorkflow GUID
19
+	 */
20
+	public ?string $workflow_guid = null;
21 21
 
22
-    /**
23
-     * PodWorkflow ID
24
-     */
25
-    public ?string $workflow_id = null;
22
+	/**
23
+	 * PodWorkflow ID
24
+	 */
25
+	public ?string $workflow_id = null;
26 26
 
27
-    /**
28
-     * Member ID
29
-     */
30
-    public ?int $root_member_id = null;
27
+	/**
28
+	 * Member ID
29
+	 */
30
+	public ?int $root_member_id = null;
31 31
 
32
-    /**
33
-     * If true, the PodWorkflow is enabled
34
-     */
35
-    public ?bool $is_enabled = null;
32
+	/**
33
+	 * If true, the PodWorkflow is enabled
34
+	 */
35
+	public ?bool $is_enabled = null;
36 36
 
37
-    /**
38
-     * If true, the PodWorkflow is default
39
-     */
40
-    public ?bool $is_default = null;
37
+	/**
38
+	 * If true, the PodWorkflow is default
39
+	 */
40
+	public ?bool $is_default = null;
41 41
 
42
-    /**
43
-     * The title of PodWorkflow
44
-     */
45
-    public ?string $title = null;
42
+	/**
43
+	 * The title of PodWorkflow
44
+	 */
45
+	public ?string $title = null;
46 46
 
47
-    /**
48
-     * Done actions as array of Actions
49
-     */
50
-    public ?array $done_actions = null;
47
+	/**
48
+	 * Done actions as array of Actions
49
+	 */
50
+	public ?array $done_actions = null;
51 51
 
52
-    /**
53
-     * Failed actions as array of Actions
54
-     */
55
-    public ?array $failed_actions = null;
52
+	/**
53
+	 * Failed actions as array of Actions
54
+	 */
55
+	public ?array $failed_actions = null;
56 56
 
57
-    /**
58
-     * The Timestamp of last update
59
-     */
60
-    public ?int $last_updated_timestamp = null;
57
+	/**
58
+	 * The Timestamp of last update
59
+	 */
60
+	public ?int $last_updated_timestamp = null;
61 61
 
62
-    public function __construct(?array $params = null)
63
-    {
64
-        if ($params !== null) {
65
-            foreach ($this as $key => $value) {
66
-                if (isset($params[$key])) {
67
-                    if ($key === 'done_actions' || $key === 'failed_actions') {
68
-                        $this->{$key} = array();
69
-                        foreach ($params[$key] as $action => $value) {
70
-                            array_push($this->{$key}, new Action($value));
71
-                        }
72
-                    } else {
73
-                        $this->{$key} = $params[$key];
74
-                    }
75
-                }
76
-            }
77
-        }
78
-    }
62
+	public function __construct(?array $params = null)
63
+	{
64
+		if ($params !== null) {
65
+			foreach ($this as $key => $value) {
66
+				if (isset($params[$key])) {
67
+					if ($key === 'done_actions' || $key === 'failed_actions') {
68
+						$this->{$key} = array();
69
+						foreach ($params[$key] as $action => $value) {
70
+							array_push($this->{$key}, new Action($value));
71
+						}
72
+					} else {
73
+						$this->{$key} = $params[$key];
74
+					}
75
+				}
76
+			}
77
+		}
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,10 +61,10 @@
 block discarded – undo
61 61
 
62 62
     public function __construct(?array $params = null)
63 63
     {
64
-        if ($params !== null) {
64
+        if ($params!==null) {
65 65
             foreach ($this as $key => $value) {
66 66
                 if (isset($params[$key])) {
67
-                    if ($key === 'done_actions' || $key === 'failed_actions') {
67
+                    if ($key==='done_actions' || $key==='failed_actions') {
68 68
                         $this->{$key} = array();
69 69
                         foreach ($params[$key] as $action => $value) {
70 70
                             array_push($this->{$key}, new Action($value));
Please login to merge, or discard this patch.
src/Route4Me/V5/PodWorkflows/Option.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
  */
14 14
 class Option extends Common
15 15
 {
16
-    /**
17
-     * Title of action
18
-     */
19
-    public ?string $name = null;
16
+	/**
17
+	 * Title of action
18
+	 */
19
+	public ?string $name = null;
20 20
 
21
-    /**
22
-     * Type of action
23
-     */
24
-    public ?string $value = null;
21
+	/**
22
+	 * Type of action
23
+	 */
24
+	public ?string $value = null;
25 25
 
26
-    public function __construct(?array $params = null)
27
-    {
28
-        if ($params !== null) {
29
-            $this->fillFromArray($params);
30
-        }
31
-    }
26
+	public function __construct(?array $params = null)
27
+	{
28
+		if ($params !== null) {
29
+			$this->fillFromArray($params);
30
+		}
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     public function __construct(?array $params = null)
37 37
     {
38
-        if ($params !== null) {
38
+        if ($params!==null) {
39 39
             $this->fillFromArray($params);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/PodWorkflows/Action.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -14,41 +14,41 @@
 block discarded – undo
14 14
  */
15 15
 class Action extends Common
16 16
 {
17
-    /**
18
-     * Title of action
19
-     */
20
-    public ?string $title = null;
17
+	/**
18
+	 * Title of action
19
+	 */
20
+	public ?string $title = null;
21 21
 
22
-    /**
23
-     * Type of action
24
-     */
25
-    public ?string $type = null;
22
+	/**
23
+	 * Type of action
24
+	 */
25
+	public ?string $type = null;
26 26
 
27
-    /**
28
-     * If true, the action is required
29
-     */
30
-    public ?bool $required = null;
27
+	/**
28
+	 * If true, the action is required
29
+	 */
30
+	public ?bool $required = null;
31 31
 
32
-    /**
33
-     * Options of the action as array of Options
34
-     */
35
-    public ?array $options = null;
32
+	/**
33
+	 * Options of the action as array of Options
34
+	 */
35
+	public ?array $options = null;
36 36
 
37
-    public function __construct(?array $params = null)
38
-    {
39
-        if ($params !== null) {
40
-            foreach ($this as $key => $value) {
41
-                if (isset($params[$key])) {
42
-                    if ($key === 'options') {
43
-                        $this->{$key} = array();
44
-                        foreach ($params[$key] as $option => $value) {
45
-                            array_push($this->{$key}, new Option($value));
46
-                        }
47
-                    } else {
48
-                        $this->{$key} = $params[$key];
49
-                    }
50
-                }
51
-            }
52
-        }
53
-    }
37
+	public function __construct(?array $params = null)
38
+	{
39
+		if ($params !== null) {
40
+			foreach ($this as $key => $value) {
41
+				if (isset($params[$key])) {
42
+					if ($key === 'options') {
43
+						$this->{$key} = array();
44
+						foreach ($params[$key] as $option => $value) {
45
+							array_push($this->{$key}, new Option($value));
46
+						}
47
+					} else {
48
+						$this->{$key} = $params[$key];
49
+					}
50
+				}
51
+			}
52
+		}
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@
 block discarded – undo
36 36
 
37 37
     public function __construct(?array $params = null)
38 38
     {
39
-        if ($params !== null) {
39
+        if ($params!==null) {
40 40
             foreach ($this as $key => $value) {
41 41
                 if (isset($params[$key])) {
42
-                    if ($key === 'options') {
42
+                    if ($key==='options') {
43 43
                         $this->{$key} = array();
44 44
                         foreach ($params[$key] as $option => $value) {
45 45
                             array_push($this->{$key}, new Option($value));
Please login to merge, or discard this patch.
examples/PodWorkflows/FullflowSample.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -20,58 +20,58 @@
 block discarded – undo
20 20
 
21 21
 // new PoD Workflow
22 22
 $params = [
23
-    'workflow_id' => 'workflow_super_ID',
24
-    'is_enabled' => false,
25
-    'is_default' => false,
26
-    'title' => 'Super title from 15',
27
-    'done_actions' => [[
28
-        'title' => 'Signee Name',
29
-        'type' => 'signeeName',
30
-        'required' => true
31
-    ]],
32
-    'failed_actions' => [[
33
-        'title' => 'Signee Name Failed',
34
-        'type' => 'signeeName',
35
-        'required' => false
36
-    ]]
23
+	'workflow_id' => 'workflow_super_ID',
24
+	'is_enabled' => false,
25
+	'is_default' => false,
26
+	'title' => 'Super title from 15',
27
+	'done_actions' => [[
28
+		'title' => 'Signee Name',
29
+		'type' => 'signeeName',
30
+		'required' => true
31
+	]],
32
+	'failed_actions' => [[
33
+		'title' => 'Signee Name Failed',
34
+		'type' => 'signeeName',
35
+		'required' => false
36
+	]]
37 37
 ];
38 38
 
39 39
 $pws = new PodWorkflows();
40 40
 
41 41
 try {
42
-    // create
43
-    $new_pod = $pws->createPodWorkflow($params);
42
+	// create
43
+	$new_pod = $pws->createPodWorkflow($params);
44 44
 
45
-    if (isset($new_pod->workflow_guid)) {
46
-        $created_pod_guid = $new_pod->workflow_guid;
47
-        echo 'Created PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
45
+	if (isset($new_pod->workflow_guid)) {
46
+		$created_pod_guid = $new_pod->workflow_guid;
47
+		echo 'Created PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
48 48
 
49
-        // read
50
-        $read_pod = $pws->getPodWorkflow($created_pod_guid);
51
-        echo 'Read PodWorkflow with GUID: ' . $read_pod->workflow_guid . PHP_EOL;
49
+		// read
50
+		$read_pod = $pws->getPodWorkflow($created_pod_guid);
51
+		echo 'Read PodWorkflow with GUID: ' . $read_pod->workflow_guid . PHP_EOL;
52 52
 
53
-        // update
54
-        $params['title'] = 'A new Super title from 15';
55
-        $updated_pod = $pws->updatePodWorkflow($created_pod_guid, $params);
56
-        echo 'Updated PodWorkflow with GUID: ' . $updated_pod->workflow_guid
57
-            . ', new title is "'. $updated_pod->title . '"' . PHP_EOL;
53
+		// update
54
+		$params['title'] = 'A new Super title from 15';
55
+		$updated_pod = $pws->updatePodWorkflow($created_pod_guid, $params);
56
+		echo 'Updated PodWorkflow with GUID: ' . $updated_pod->workflow_guid
57
+			. ', new title is "'. $updated_pod->title . '"' . PHP_EOL;
58 58
 
59
-        //delete
60
-        $res = $pws->deletePodWorkflow($created_pod_guid);
61
-        echo 'Deleted PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
62
-    } else {
63
-        echo 'Error creating PodWorkflow.' . PHP_EOL;
64
-    }
59
+		//delete
60
+		$res = $pws->deletePodWorkflow($created_pod_guid);
61
+		echo 'Deleted PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
62
+	} else {
63
+		echo 'Error creating PodWorkflow.' . PHP_EOL;
64
+	}
65 65
 } catch (Exception | ApiError $e) {
66
-    echo 'Error, Code: ' . $e->getCode() . PHP_EOL . 'Message: ' . $e->getMessage() . PHP_EOL;
66
+	echo 'Error, Code: ' . $e->getCode() . PHP_EOL . 'Message: ' . $e->getMessage() . PHP_EOL;
67 67
 
68
-    if ($created_pod_guid) {
69
-        echo 'Cleanup PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
70
-        try {
71
-            $pws->deletePodWorkflow($created_pod_guid);
72
-        } catch (Exception | ApiError $e) {
73
-            echo 'Error: Cleanup.' . PHP_EOL;
74
-            echo $e->getMessage() . PHP_EOL;
75
-        }
76
-    }
68
+	if ($created_pod_guid) {
69
+		echo 'Cleanup PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
70
+		try {
71
+			$pws->deletePodWorkflow($created_pod_guid);
72
+		} catch (Exception | ApiError $e) {
73
+			echo 'Error: Cleanup.' . PHP_EOL;
74
+			echo $e->getMessage() . PHP_EOL;
75
+		}
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -44,34 +44,34 @@
 block discarded – undo
44 44
 
45 45
     if (isset($new_pod->workflow_guid)) {
46 46
         $created_pod_guid = $new_pod->workflow_guid;
47
-        echo 'Created PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
47
+        echo 'Created PodWorkflow with GUID: '.$created_pod_guid.PHP_EOL;
48 48
 
49 49
         // read
50 50
         $read_pod = $pws->getPodWorkflow($created_pod_guid);
51
-        echo 'Read PodWorkflow with GUID: ' . $read_pod->workflow_guid . PHP_EOL;
51
+        echo 'Read PodWorkflow with GUID: '.$read_pod->workflow_guid.PHP_EOL;
52 52
 
53 53
         // update
54 54
         $params['title'] = 'A new Super title from 15';
55 55
         $updated_pod = $pws->updatePodWorkflow($created_pod_guid, $params);
56
-        echo 'Updated PodWorkflow with GUID: ' . $updated_pod->workflow_guid
57
-            . ', new title is "'. $updated_pod->title . '"' . PHP_EOL;
56
+        echo 'Updated PodWorkflow with GUID: '.$updated_pod->workflow_guid
57
+            . ', new title is "'.$updated_pod->title.'"'.PHP_EOL;
58 58
 
59 59
         //delete
60 60
         $res = $pws->deletePodWorkflow($created_pod_guid);
61
-        echo 'Deleted PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
61
+        echo 'Deleted PodWorkflow with GUID: '.$created_pod_guid.PHP_EOL;
62 62
     } else {
63
-        echo 'Error creating PodWorkflow.' . PHP_EOL;
63
+        echo 'Error creating PodWorkflow.'.PHP_EOL;
64 64
     }
65 65
 } catch (Exception | ApiError $e) {
66
-    echo 'Error, Code: ' . $e->getCode() . PHP_EOL . 'Message: ' . $e->getMessage() . PHP_EOL;
66
+    echo 'Error, Code: '.$e->getCode().PHP_EOL.'Message: '.$e->getMessage().PHP_EOL;
67 67
 
68 68
     if ($created_pod_guid) {
69
-        echo 'Cleanup PodWorkflow with GUID: ' . $created_pod_guid . PHP_EOL;
69
+        echo 'Cleanup PodWorkflow with GUID: '.$created_pod_guid.PHP_EOL;
70 70
         try {
71 71
             $pws->deletePodWorkflow($created_pod_guid);
72 72
         } catch (Exception | ApiError $e) {
73
-            echo 'Error: Cleanup.' . PHP_EOL;
74
-            echo $e->getMessage() . PHP_EOL;
73
+            echo 'Error: Cleanup.'.PHP_EOL;
74
+            echo $e->getMessage().PHP_EOL;
75 75
         }
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
UnitTestFiles/Test/V5/OrderUnitTests.php 2 patches
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -15,357 +15,357 @@
 block discarded – undo
15 15
 
16 16
 final class OrderUnitTests extends \PHPUnit\Framework\TestCase
17 17
 {
18
-    public static ?string $created_uuid = null;
19
-    public static ?string $created_field_uuid = null;
20
-
21
-    public static function setUpBeforeClass() : void
22
-    {
23
-        Route4Me::setApiKey(Constants::API_KEY);
24
-    }
25
-
26
-    public function testCustomDataCanBeCreateEmpty() : void
27
-    {
28
-        $this->assertInstanceOf(CustomData::class, new CustomData());
29
-    }
30
-
31
-    public function testCustomDataCanBeCreateFromArray() : void
32
-    {
33
-        $this->assertInstanceOf(CustomData::class, new CustomData([
34
-            'barcode' => '1',
35
-            'airbillno' => '2',
36
-            'sorted_on_date' => '3',
37
-            'sorted_on_utc' => 1
38
-        ]));
39
-    }
40
-
41
-    public function testCustomFieldCanBeCreateEmpty() : void
42
-    {
43
-        $this->assertInstanceOf(CustomField::class, new CustomField());
44
-    }
45
-
46
-    public function testCustomFieldCanBeCreateFromArray() : void
47
-    {
48
-        $this->assertInstanceOf(CustomField::class, new CustomField([
49
-            'order_custom_field_uuid' => 'uuid',
50
-            'order_custom_field_value' => 'value'
51
-        ]));
52
-    }
53
-
54
-    public function testGPSCoordsCanBeCreateEmpty() : void
55
-    {
56
-        $this->assertInstanceOf(GPSCoords::class, new GPSCoords());
57
-    }
58
-
59
-    public function testGPSCoordsCanBeCreateByConstructor() : void
60
-    {
61
-        $coords = new GPSCoords(40.5, 90.0);
62
-        $this->assertInstanceOf(GPSCoords::class, $coords);
63
-        $this->assertEquals($coords->lat, 40.5);
64
-        $this->assertEquals($coords->lng, 90.0);
65
-    }
66
-
67
-    public function testGPSCoordsCanBeCreateFromArray() : void
68
-    {
69
-        $coords = new GPSCoords([
70
-            'lat' => 40.5,
71
-            'lng' => 90.0
72
-        ]);
73
-        $this->assertInstanceOf(GPSCoords::class, $coords);
74
-        $this->assertEquals($coords->lat, 40.5);
75
-        $this->assertEquals($coords->lng, 90.0);
76
-    }
77
-
78
-    public function testLocalTimeWindowCanBeCreateEmpty() : void
79
-    {
80
-        $this->assertInstanceOf(LocalTimeWindow::class, new LocalTimeWindow());
81
-    }
82
-
83
-    public function testLocalTimeWindowCanBeCreateByConstructor() : void
84
-    {
85
-        $coords = new LocalTimeWindow(1, 2);
86
-        $this->assertInstanceOf(LocalTimeWindow::class, $coords);
87
-        $this->assertEquals($coords->start, 1);
88
-        $this->assertEquals($coords->end, 2);
89
-    }
90
-
91
-    public function testLocalTimeWindowCanBeCreateFromArray() : void
92
-    {
93
-        $coords = new LocalTimeWindow([
94
-            'start' => 1,
95
-            'end' => 2
96
-        ]);
97
-        $this->assertInstanceOf(LocalTimeWindow::class, $coords);
98
-        $this->assertEquals($coords->start, 1);
99
-        $this->assertEquals($coords->end, 2);
100
-    }
101
-
102
-    public function testOrderCanBeCreateEmpty() : void
103
-    {
104
-        $this->assertInstanceOf(Order::class, new Order());
105
-    }
106
-
107
-    public function testOrderCanBeCreateFromArray() : void
108
-    {
109
-        $order = new Order([
110
-            'first_name' => 'John',
111
-            'last_name' => 'Doe',
112
-            'email' => '[email protected]'
113
-        ]);
114
-        $this->assertInstanceOf(Order::class, $order);
115
-        $this->assertEquals($order->first_name, 'John');
116
-        $this->assertEquals($order->last_name, 'Doe');
117
-    }
118
-
119
-    public function testResponseOrderCanBeCreateEmpty() : void
120
-    {
121
-        $this->assertInstanceOf(Order::class, new Order());
122
-    }
123
-
124
-    public function testResponseOrderCanBeCreateFromArray() : void
125
-    {
126
-        $order = new ResponseOrder([
127
-            'first_name' => 'John',
128
-            'last_name' => 'Doe',
129
-            'email' => '[email protected]'
130
-        ]);
131
-        $this->assertInstanceOf(ResponseOrder::class, $order);
132
-        $this->assertEquals($order->first_name, 'John');
133
-        $this->assertEquals($order->last_name, 'Doe');
134
-    }
135
-
136
-    public function testCreateMustReturnResponseOrder() : void
137
-    {
138
-        $orders = new Orders();
139
-        $order = $orders->create([
140
-            'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
141
-            'address_alias' => 'Auto test address',
142
-            'address_city' => 'Philadelphia',
143
-            'address_geo' => [
144
-                'lat' => 48.335991,
145
-                'lng' => 31.18287
146
-            ],
147
-            'first_name' => 'John',
148
-            'last_name' => 'Doe',
149
-            'email' => '[email protected]'
150
-        ]);
151
-
152
-        $this->assertInstanceOf(ResponseOrder::class, $order);
153
-        $this->assertNotNull($order->first_name);
154
-        $this->assertEquals($order->first_name, 'John');
18
+	public static ?string $created_uuid = null;
19
+	public static ?string $created_field_uuid = null;
20
+
21
+	public static function setUpBeforeClass() : void
22
+	{
23
+		Route4Me::setApiKey(Constants::API_KEY);
24
+	}
25
+
26
+	public function testCustomDataCanBeCreateEmpty() : void
27
+	{
28
+		$this->assertInstanceOf(CustomData::class, new CustomData());
29
+	}
30
+
31
+	public function testCustomDataCanBeCreateFromArray() : void
32
+	{
33
+		$this->assertInstanceOf(CustomData::class, new CustomData([
34
+			'barcode' => '1',
35
+			'airbillno' => '2',
36
+			'sorted_on_date' => '3',
37
+			'sorted_on_utc' => 1
38
+		]));
39
+	}
40
+
41
+	public function testCustomFieldCanBeCreateEmpty() : void
42
+	{
43
+		$this->assertInstanceOf(CustomField::class, new CustomField());
44
+	}
45
+
46
+	public function testCustomFieldCanBeCreateFromArray() : void
47
+	{
48
+		$this->assertInstanceOf(CustomField::class, new CustomField([
49
+			'order_custom_field_uuid' => 'uuid',
50
+			'order_custom_field_value' => 'value'
51
+		]));
52
+	}
53
+
54
+	public function testGPSCoordsCanBeCreateEmpty() : void
55
+	{
56
+		$this->assertInstanceOf(GPSCoords::class, new GPSCoords());
57
+	}
58
+
59
+	public function testGPSCoordsCanBeCreateByConstructor() : void
60
+	{
61
+		$coords = new GPSCoords(40.5, 90.0);
62
+		$this->assertInstanceOf(GPSCoords::class, $coords);
63
+		$this->assertEquals($coords->lat, 40.5);
64
+		$this->assertEquals($coords->lng, 90.0);
65
+	}
66
+
67
+	public function testGPSCoordsCanBeCreateFromArray() : void
68
+	{
69
+		$coords = new GPSCoords([
70
+			'lat' => 40.5,
71
+			'lng' => 90.0
72
+		]);
73
+		$this->assertInstanceOf(GPSCoords::class, $coords);
74
+		$this->assertEquals($coords->lat, 40.5);
75
+		$this->assertEquals($coords->lng, 90.0);
76
+	}
77
+
78
+	public function testLocalTimeWindowCanBeCreateEmpty() : void
79
+	{
80
+		$this->assertInstanceOf(LocalTimeWindow::class, new LocalTimeWindow());
81
+	}
82
+
83
+	public function testLocalTimeWindowCanBeCreateByConstructor() : void
84
+	{
85
+		$coords = new LocalTimeWindow(1, 2);
86
+		$this->assertInstanceOf(LocalTimeWindow::class, $coords);
87
+		$this->assertEquals($coords->start, 1);
88
+		$this->assertEquals($coords->end, 2);
89
+	}
90
+
91
+	public function testLocalTimeWindowCanBeCreateFromArray() : void
92
+	{
93
+		$coords = new LocalTimeWindow([
94
+			'start' => 1,
95
+			'end' => 2
96
+		]);
97
+		$this->assertInstanceOf(LocalTimeWindow::class, $coords);
98
+		$this->assertEquals($coords->start, 1);
99
+		$this->assertEquals($coords->end, 2);
100
+	}
101
+
102
+	public function testOrderCanBeCreateEmpty() : void
103
+	{
104
+		$this->assertInstanceOf(Order::class, new Order());
105
+	}
106
+
107
+	public function testOrderCanBeCreateFromArray() : void
108
+	{
109
+		$order = new Order([
110
+			'first_name' => 'John',
111
+			'last_name' => 'Doe',
112
+			'email' => '[email protected]'
113
+		]);
114
+		$this->assertInstanceOf(Order::class, $order);
115
+		$this->assertEquals($order->first_name, 'John');
116
+		$this->assertEquals($order->last_name, 'Doe');
117
+	}
118
+
119
+	public function testResponseOrderCanBeCreateEmpty() : void
120
+	{
121
+		$this->assertInstanceOf(Order::class, new Order());
122
+	}
123
+
124
+	public function testResponseOrderCanBeCreateFromArray() : void
125
+	{
126
+		$order = new ResponseOrder([
127
+			'first_name' => 'John',
128
+			'last_name' => 'Doe',
129
+			'email' => '[email protected]'
130
+		]);
131
+		$this->assertInstanceOf(ResponseOrder::class, $order);
132
+		$this->assertEquals($order->first_name, 'John');
133
+		$this->assertEquals($order->last_name, 'Doe');
134
+	}
135
+
136
+	public function testCreateMustReturnResponseOrder() : void
137
+	{
138
+		$orders = new Orders();
139
+		$order = $orders->create([
140
+			'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
141
+			'address_alias' => 'Auto test address',
142
+			'address_city' => 'Philadelphia',
143
+			'address_geo' => [
144
+				'lat' => 48.335991,
145
+				'lng' => 31.18287
146
+			],
147
+			'first_name' => 'John',
148
+			'last_name' => 'Doe',
149
+			'email' => '[email protected]'
150
+		]);
151
+
152
+		$this->assertInstanceOf(ResponseOrder::class, $order);
153
+		$this->assertNotNull($order->first_name);
154
+		$this->assertEquals($order->first_name, 'John');
155 155
         
156
-        self::$created_uuid = $order->order_uuid;
157
-    }
158
-
159
-    public function testGetMustReturnResponseOrder() : void
160
-    {
161
-        if (self::$created_uuid !== null) {
162
-            $orders = new Orders();
163
-            $order = $orders->get(self::$created_uuid);
164
-
165
-            $this->assertInstanceOf(ResponseOrder::class, $order);
166
-            $this->assertNotNull($order->first_name);
167
-            $this->assertEquals($order->first_name, 'John');
168
-        }
169
-    }
170
-
171
-    public function testUpdateMustReturnResponseOrder() : void
172
-    {
173
-        if (self::$created_uuid !== null) {
174
-            $orders = new Orders();
175
-            $order = $orders->update(self::$created_uuid, ['first_name' => 'Jane']);
176
-
177
-            $this->assertInstanceOf(ResponseOrder::class, $order);
178
-            $this->assertNotNull($order->first_name);
179
-            $this->assertEquals($order->first_name, 'Jane');
180
-        }
181
-    }
182
-
183
-    public function testSearchMustReturnResponseSearchWithoutParams() : void
184
-    {
185
-        $orders = new Orders();
186
-        $res = $orders->search();
187
-
188
-        $this->assertInstanceOf(ResponseSearch::class, $res);
189
-        $this->assertNotNull($res->total);
190
-    }
191
-
192
-    public function testSearchMustReturnResponseSearchWithParams() : void
193
-    {
194
-        if (self::$created_uuid !== null) {
195
-            $orders = new Orders();
196
-            $params = [
197
-                "filters" => [
198
-                    "order_ids" => [self::$created_uuid]
199
-                ]
200
-            ];
201
-            $res = $orders->search($params);
202
-
203
-            $this->assertInstanceOf(ResponseSearch::class, $res);
204
-            $this->assertNotNull($res->total);
205
-            $this->assertNotNull($res->results);
206
-        }
207
-    }
208
-
209
-    public function testBatchCreateMustReturnTrue() : void
210
-    {
211
-        $this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
212
-
213
-        $orders = new Orders();
214
-        $params = [
215
-            [
216
-                'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
217
-                'address_alias' => 'Address for batch workflow 0',
218
-                'address_city' => 'Philadelphia',
219
-                'address_geo' => [
220
-                    'lat' => 48.335991,
221
-                    'lng' => 31.18287
222
-                ],
223
-                'first_name' => 'John',
224
-                'last_name' => 'Doe',
225
-                'email' => '[email protected]'
226
-            ], [
227
-                'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
228
-                'address_alias' => 'Address for batch workflow 1',
229
-                'address_city' => 'Philadelphia',
230
-                'address_geo' => [
231
-                    'lat' => 48.335991,
232
-                    'lng' => 31.18287
233
-                ],
234
-                'first_name' => 'John',
235
-                'last_name' => 'Doe',
236
-                'email' => '[email protected]'
237
-            ]
238
-        ];
239
-        $res = $orders->batchCreate($params);
240
-
241
-        $this->assertIsBool($res);
242
-        $this->assertTrue($res);
243
-    }
244
-
245
-    public function testBatchUpdateMustReturnArray() : void
246
-    {
247
-        $this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
248
-
249
-        $orders = new Orders();
250
-        $orderIds = ['', ''];
251
-        $data = [
252
-            'first_name' => 'Jane'
253
-        ];
254
-        $res = $orders->batchUpdate($orderIds, $data);
255
-
256
-        $this->assertIsArray($res);
257
-    }
258
-
259
-    public function testBatchUpdateByFiltersMustReturnTrue() : void
260
-    {
261
-        $this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
262
-
263
-        $orders = new Orders();
264
-        $params = [
265
-            'data' => [
266
-                'first_name' => 'John'
267
-            ],
268
-            'filters' => [
269
-                'orderIds' => ['', '']
270
-            ]
271
-        ];
272
-        $res = $orders->batchUpdateByFilters($params);
273
-
274
-        $this->assertIsBool($res);
275
-        $this->assertTrue($res);
276
-    }
277
-
278
-    public function testBatchDeleteMustReturnTrue() : void
279
-    {
280
-        $this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
281
-
282
-        $orders = new Orders();
283
-        $orderIds = ['', ''];
284
-        $res = $orders->batchDelete($orderIds);
285
-
286
-        $this->assertIsBool($res);
287
-        $this->assertTrue($res);
288
-    }
289
-
290
-    public function testGetOrderCustomFieldsReturnArray() : void
291
-    {
292
-        $orders = new Orders();
293
-        $res = $orders->getOrderCustomFields();
294
-
295
-        $this->assertIsArray($res);
296
-    }
297
-
298
-    public function testCreateOrderCustomFieldMustReturnCustomField() : void
299
-    {
300
-        $orders = new Orders();
301
-        $field = $orders->createOrderCustomField([
302
-            'order_custom_field_name' => 'CustomField1',
303
-            'order_custom_field_label' => 'Custom Field 1',
304
-            'order_custom_field_type' => 'checkbox',
305
-            'order_custom_field_type_info' => [
306
-                'short_label' => 'cFl1'
307
-            ]
308
-        ]);
309
-
310
-        $this->assertInstanceOf(CustomField::class, $field);
311
-        $this->assertNotNull($field->order_custom_field_label);
312
-        $this->assertEquals($field->order_custom_field_label, 'Custom Field 1');
156
+		self::$created_uuid = $order->order_uuid;
157
+	}
158
+
159
+	public function testGetMustReturnResponseOrder() : void
160
+	{
161
+		if (self::$created_uuid !== null) {
162
+			$orders = new Orders();
163
+			$order = $orders->get(self::$created_uuid);
164
+
165
+			$this->assertInstanceOf(ResponseOrder::class, $order);
166
+			$this->assertNotNull($order->first_name);
167
+			$this->assertEquals($order->first_name, 'John');
168
+		}
169
+	}
170
+
171
+	public function testUpdateMustReturnResponseOrder() : void
172
+	{
173
+		if (self::$created_uuid !== null) {
174
+			$orders = new Orders();
175
+			$order = $orders->update(self::$created_uuid, ['first_name' => 'Jane']);
176
+
177
+			$this->assertInstanceOf(ResponseOrder::class, $order);
178
+			$this->assertNotNull($order->first_name);
179
+			$this->assertEquals($order->first_name, 'Jane');
180
+		}
181
+	}
182
+
183
+	public function testSearchMustReturnResponseSearchWithoutParams() : void
184
+	{
185
+		$orders = new Orders();
186
+		$res = $orders->search();
187
+
188
+		$this->assertInstanceOf(ResponseSearch::class, $res);
189
+		$this->assertNotNull($res->total);
190
+	}
191
+
192
+	public function testSearchMustReturnResponseSearchWithParams() : void
193
+	{
194
+		if (self::$created_uuid !== null) {
195
+			$orders = new Orders();
196
+			$params = [
197
+				"filters" => [
198
+					"order_ids" => [self::$created_uuid]
199
+				]
200
+			];
201
+			$res = $orders->search($params);
202
+
203
+			$this->assertInstanceOf(ResponseSearch::class, $res);
204
+			$this->assertNotNull($res->total);
205
+			$this->assertNotNull($res->results);
206
+		}
207
+	}
208
+
209
+	public function testBatchCreateMustReturnTrue() : void
210
+	{
211
+		$this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
212
+
213
+		$orders = new Orders();
214
+		$params = [
215
+			[
216
+				'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
217
+				'address_alias' => 'Address for batch workflow 0',
218
+				'address_city' => 'Philadelphia',
219
+				'address_geo' => [
220
+					'lat' => 48.335991,
221
+					'lng' => 31.18287
222
+				],
223
+				'first_name' => 'John',
224
+				'last_name' => 'Doe',
225
+				'email' => '[email protected]'
226
+			], [
227
+				'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
228
+				'address_alias' => 'Address for batch workflow 1',
229
+				'address_city' => 'Philadelphia',
230
+				'address_geo' => [
231
+					'lat' => 48.335991,
232
+					'lng' => 31.18287
233
+				],
234
+				'first_name' => 'John',
235
+				'last_name' => 'Doe',
236
+				'email' => '[email protected]'
237
+			]
238
+		];
239
+		$res = $orders->batchCreate($params);
240
+
241
+		$this->assertIsBool($res);
242
+		$this->assertTrue($res);
243
+	}
244
+
245
+	public function testBatchUpdateMustReturnArray() : void
246
+	{
247
+		$this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
248
+
249
+		$orders = new Orders();
250
+		$orderIds = ['', ''];
251
+		$data = [
252
+			'first_name' => 'Jane'
253
+		];
254
+		$res = $orders->batchUpdate($orderIds, $data);
255
+
256
+		$this->assertIsArray($res);
257
+	}
258
+
259
+	public function testBatchUpdateByFiltersMustReturnTrue() : void
260
+	{
261
+		$this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
262
+
263
+		$orders = new Orders();
264
+		$params = [
265
+			'data' => [
266
+				'first_name' => 'John'
267
+			],
268
+			'filters' => [
269
+				'orderIds' => ['', '']
270
+			]
271
+		];
272
+		$res = $orders->batchUpdateByFilters($params);
273
+
274
+		$this->assertIsBool($res);
275
+		$this->assertTrue($res);
276
+	}
277
+
278
+	public function testBatchDeleteMustReturnTrue() : void
279
+	{
280
+		$this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
281
+
282
+		$orders = new Orders();
283
+		$orderIds = ['', ''];
284
+		$res = $orders->batchDelete($orderIds);
285
+
286
+		$this->assertIsBool($res);
287
+		$this->assertTrue($res);
288
+	}
289
+
290
+	public function testGetOrderCustomFieldsReturnArray() : void
291
+	{
292
+		$orders = new Orders();
293
+		$res = $orders->getOrderCustomFields();
294
+
295
+		$this->assertIsArray($res);
296
+	}
297
+
298
+	public function testCreateOrderCustomFieldMustReturnCustomField() : void
299
+	{
300
+		$orders = new Orders();
301
+		$field = $orders->createOrderCustomField([
302
+			'order_custom_field_name' => 'CustomField1',
303
+			'order_custom_field_label' => 'Custom Field 1',
304
+			'order_custom_field_type' => 'checkbox',
305
+			'order_custom_field_type_info' => [
306
+				'short_label' => 'cFl1'
307
+			]
308
+		]);
309
+
310
+		$this->assertInstanceOf(CustomField::class, $field);
311
+		$this->assertNotNull($field->order_custom_field_label);
312
+		$this->assertEquals($field->order_custom_field_label, 'Custom Field 1');
313 313
         
314
-        self::$created_field_uuid = $field->order_custom_field_uuid;
315
-    }
316
-
317
-    public function testUpdateOrderCustomFieldMustReturnCustomField() : void
318
-    {
319
-        if (self::$created_field_uuid !== null) {
320
-            $orders = new Orders();
321
-            $field = $orders->updateOrderCustomField(self::$created_field_uuid, [
322
-                'order_custom_field_label' => 'Custom Field New',
323
-                'order_custom_field_type' => 'checkbox',
324
-                'order_custom_field_type_info' => [
325
-                    'short_label' => 'cFl1'
326
-                ]
327
-            ]);
328
-
329
-            $this->assertInstanceOf(CustomField::class, $field);
330
-            $this->assertNotNull($field->order_custom_field_label);
331
-            $this->assertEquals($field->order_custom_field_label, 'Custom Field New');
332
-        }
333
-    }
334
-
335
-    public function testDeleteOrderCustomFieldMustReturnCustomField() : void
336
-    {
337
-        if (self::$created_field_uuid !== null) {
338
-            $orders = new Orders();
339
-            $field = $orders->deleteOrderCustomField(self::$created_field_uuid);
340
-
341
-            $this->assertInstanceOf(CustomField::class, $field);
342
-            self::$created_field_uuid = null;
343
-        }
344
-    }
345
-
346
-    public function testDeleteMustReturnTrue() : void
347
-    {
348
-        if (self::$created_uuid !== null) {
349
-            $orders = new Orders();
350
-            $result = $orders->delete(self::$created_uuid);
351
-
352
-            $this->assertTrue($result);
353
-            self::$created_uuid = null;
354
-        }
355
-    }
356
-
357
-    public static function tearDownAfterClass() : void
358
-    {
359
-        sleep(1);
360
-
361
-        if (self::$created_uuid !== null || self::$created_field_uuid !== null) {
362
-            $orders = new Orders();
363
-            if (self::$created_uuid !== null) {
364
-                $orders->delete(self::$created_uuid);
365
-            }
366
-            if (self::$created_field_uuid !== null) {
367
-                $orders->deleteOrderCustomField(self::$created_field_uuid);
368
-            }
369
-        }
370
-    }
314
+		self::$created_field_uuid = $field->order_custom_field_uuid;
315
+	}
316
+
317
+	public function testUpdateOrderCustomFieldMustReturnCustomField() : void
318
+	{
319
+		if (self::$created_field_uuid !== null) {
320
+			$orders = new Orders();
321
+			$field = $orders->updateOrderCustomField(self::$created_field_uuid, [
322
+				'order_custom_field_label' => 'Custom Field New',
323
+				'order_custom_field_type' => 'checkbox',
324
+				'order_custom_field_type_info' => [
325
+					'short_label' => 'cFl1'
326
+				]
327
+			]);
328
+
329
+			$this->assertInstanceOf(CustomField::class, $field);
330
+			$this->assertNotNull($field->order_custom_field_label);
331
+			$this->assertEquals($field->order_custom_field_label, 'Custom Field New');
332
+		}
333
+	}
334
+
335
+	public function testDeleteOrderCustomFieldMustReturnCustomField() : void
336
+	{
337
+		if (self::$created_field_uuid !== null) {
338
+			$orders = new Orders();
339
+			$field = $orders->deleteOrderCustomField(self::$created_field_uuid);
340
+
341
+			$this->assertInstanceOf(CustomField::class, $field);
342
+			self::$created_field_uuid = null;
343
+		}
344
+	}
345
+
346
+	public function testDeleteMustReturnTrue() : void
347
+	{
348
+		if (self::$created_uuid !== null) {
349
+			$orders = new Orders();
350
+			$result = $orders->delete(self::$created_uuid);
351
+
352
+			$this->assertTrue($result);
353
+			self::$created_uuid = null;
354
+		}
355
+	}
356
+
357
+	public static function tearDownAfterClass() : void
358
+	{
359
+		sleep(1);
360
+
361
+		if (self::$created_uuid !== null || self::$created_field_uuid !== null) {
362
+			$orders = new Orders();
363
+			if (self::$created_uuid !== null) {
364
+				$orders->delete(self::$created_uuid);
365
+			}
366
+			if (self::$created_field_uuid !== null) {
367
+				$orders->deleteOrderCustomField(self::$created_field_uuid);
368
+			}
369
+		}
370
+	}
371 371
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
     public function testGetMustReturnResponseOrder() : void
160 160
     {
161
-        if (self::$created_uuid !== null) {
161
+        if (self::$created_uuid!==null) {
162 162
             $orders = new Orders();
163 163
             $order = $orders->get(self::$created_uuid);
164 164
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
     public function testUpdateMustReturnResponseOrder() : void
172 172
     {
173
-        if (self::$created_uuid !== null) {
173
+        if (self::$created_uuid!==null) {
174 174
             $orders = new Orders();
175 175
             $order = $orders->update(self::$created_uuid, ['first_name' => 'Jane']);
176 176
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
     public function testSearchMustReturnResponseSearchWithParams() : void
193 193
     {
194
-        if (self::$created_uuid !== null) {
194
+        if (self::$created_uuid!==null) {
195 195
             $orders = new Orders();
196 196
             $params = [
197 197
                 "filters" => [
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
     public function testUpdateOrderCustomFieldMustReturnCustomField() : void
318 318
     {
319
-        if (self::$created_field_uuid !== null) {
319
+        if (self::$created_field_uuid!==null) {
320 320
             $orders = new Orders();
321 321
             $field = $orders->updateOrderCustomField(self::$created_field_uuid, [
322 322
                 'order_custom_field_label' => 'Custom Field New',
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 
335 335
     public function testDeleteOrderCustomFieldMustReturnCustomField() : void
336 336
     {
337
-        if (self::$created_field_uuid !== null) {
337
+        if (self::$created_field_uuid!==null) {
338 338
             $orders = new Orders();
339 339
             $field = $orders->deleteOrderCustomField(self::$created_field_uuid);
340 340
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
     public function testDeleteMustReturnTrue() : void
347 347
     {
348
-        if (self::$created_uuid !== null) {
348
+        if (self::$created_uuid!==null) {
349 349
             $orders = new Orders();
350 350
             $result = $orders->delete(self::$created_uuid);
351 351
 
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
     {
359 359
         sleep(1);
360 360
 
361
-        if (self::$created_uuid !== null || self::$created_field_uuid !== null) {
361
+        if (self::$created_uuid!==null || self::$created_field_uuid!==null) {
362 362
             $orders = new Orders();
363
-            if (self::$created_uuid !== null) {
363
+            if (self::$created_uuid!==null) {
364 364
                 $orders->delete(self::$created_uuid);
365 365
             }
366
-            if (self::$created_field_uuid !== null) {
366
+            if (self::$created_field_uuid!==null) {
367 367
                 $orders->deleteOrderCustomField(self::$created_field_uuid);
368 368
             }
369 369
         }
Please login to merge, or discard this patch.
UnitTestFiles/Test/OrderTests.php 2 patches
Indentation   +574 added lines, -574 removed lines patch added patch discarded remove patch
@@ -20,578 +20,578 @@
 block discarded – undo
20 20
 
21 21
 class OrderTests extends \PHPUnit\Framework\TestCase
22 22
 {
23
-    public static $createdOrders = [];
24
-    public static $createdProblems = [];
25
-
26
-    public static function setUpBeforeClass()
27
-    {
28
-        Route4Me::setApiKey(Constants::API_KEY);
29
-
30
-        //region -- Create Test Optimization --
31
-
32
-        // Huge list of addresses
33
-        $json = json_decode(file_get_contents(dirname(__FILE__).'/data/addresses.json'), true);
34
-        $json = array_slice($json, 0, 10);
35
-
36
-        $addresses = [];
37
-        foreach ($json as $address) {
38
-            $addresses[] = Address::fromArray($address);
39
-        }
40
-
41
-        $parameters = RouteParameters::fromArray([
42
-            'algorithm_type'    => Algorithmtype::TSP,
43
-            'route_name'        => 'Single Driver Multiple TW 10 Stops '.date('Y-m-d H:i'),
44
-            'route_date'        => time() + 24 * 60 * 60,
45
-            'route_time'        => 5 * 3600 + 30 * 60,
46
-            'distance_unit'     => DistanceUnit::MILES,
47
-            'device_type'       => DeviceType::WEB,
48
-            'optimize'          => OptimizationType::DISTANCE,
49
-            'metric'            => Metric::GEODESIC,
50
-        ]);
51
-
52
-        $optimizationParams = new OptimizationProblemParams();
53
-        $optimizationParams->setAddresses($addresses);
54
-        $optimizationParams->setParameters($parameters);
55
-
56
-        $problem = OptimizationProblem::optimize($optimizationParams);
57
-
58
-        self::$createdProblems[] = $problem;
59
-
60
-        //endregion
61
-
62
-        //region -- Create Test Order --
63
-
64
-        $orderParameters = Order::fromArray([
65
-            'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
66
-            'cached_lat'                => 48.335991,
67
-            'cached_lng'                => 31.18287,
68
-            'address_alias'             => 'Auto test address',
69
-            'address_city'              => 'Philadelphia',
70
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
71
-            'EXT_FIELD_first_name'      => 'Igor',
72
-            'EXT_FIELD_last_name'       => 'Progman',
73
-            'EXT_FIELD_email'           => '[email protected]',
74
-            'EXT_FIELD_phone'           => '380380380380',
75
-            'EXT_FIELD_custom_data'     => [
76
-                0 => [
77
-                    'order_id'  => '10',
78
-                    'name'      => 'Bill Soul',
79
-                ],
80
-            ],
81
-        ]);
82
-
83
-        $order = new Order();
84
-
85
-        $response = $order->addOrder($orderParameters);
86
-
87
-        self::assertNotNull($response);
88
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
89
-
90
-        self::$createdOrders[] = $response;
91
-
92
-        //endregion
93
-    }
94
-
95
-    public function testFromArray()
96
-    {
97
-        $orderParameters = Order::fromArray([
98
-            'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
99
-            'cached_lat'                => 48.335991,
100
-            'cached_lng'                => 31.18287,
101
-            'address_alias'             => 'Auto test address',
102
-            'address_city'              => 'Philadelphia',
103
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
104
-            'EXT_FIELD_first_name'      => 'Igor',
105
-            'EXT_FIELD_last_name'       => 'Progman',
106
-            'EXT_FIELD_email'           => '[email protected]',
107
-            'EXT_FIELD_phone'           => '380380380380',
108
-            'EXT_FIELD_custom_data'     => [
109
-                0 => [
110
-                    'order_id'  => '10',
111
-                    'name'      => 'Bill Soul',
112
-                ],
113
-            ],
114
-        ]);
115
-
116
-        $this->assertEquals('1358 E Luzerne St, Philadelphia, PA 19124, US', $orderParameters->address_1);
117
-        $this->assertEquals(48.335991, $orderParameters->cached_lat);
118
-        $this->assertEquals(31.18287, $orderParameters->cached_lng);
119
-        $this->assertEquals('Auto test address', $orderParameters->address_alias);
120
-        $this->assertEquals('Philadelphia', $orderParameters->address_city);
121
-        $this->assertEquals(date('Y-m-d'), $orderParameters->day_scheduled_for_YYMMDD);
122
-        $this->assertEquals('Igor', $orderParameters->EXT_FIELD_first_name);
123
-        $this->assertEquals('Progman', $orderParameters->EXT_FIELD_last_name);
124
-        $this->assertEquals('[email protected]', $orderParameters->EXT_FIELD_email);
125
-        $this->assertEquals('380380380380', $orderParameters->EXT_FIELD_phone);
126
-        $this->assertEquals([
127
-            0 => [
128
-                'order_id'  => '10',
129
-                'name'      => 'Bill Soul',
130
-            ],
131
-        ], $orderParameters->EXT_FIELD_custom_data);
132
-    }
133
-
134
-    public function testToArray()
135
-    {
136
-        $orderParameters = Order::fromArray([
137
-            'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
138
-            'cached_lat'                => 48.335991,
139
-            'cached_lng'                => 31.18287,
140
-            'address_alias'             => 'Auto test address',
141
-            'address_city'              => 'Philadelphia',
142
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
143
-            'EXT_FIELD_first_name'      => 'Igor',
144
-            'EXT_FIELD_last_name'       => 'Progman',
145
-            'EXT_FIELD_email'           => '[email protected]',
146
-            'EXT_FIELD_phone'           => '380380380380',
147
-            'EXT_FIELD_custom_data'     => [
148
-                0 => [
149
-                    'order_id'  => '10',
150
-                    'name'      => 'Bill Soul',
151
-                ],
152
-            ],
153
-        ]);
154
-
155
-        $this->assertEquals($orderParameters->toArray(), [
156
-            'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
157
-            'cached_lat'                => 48.335991,
158
-            'cached_lng'                => 31.18287,
159
-            'address_alias'             => 'Auto test address',
160
-            'address_city'              => 'Philadelphia',
161
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
162
-            'EXT_FIELD_first_name'      => 'Igor',
163
-            'EXT_FIELD_last_name'       => 'Progman',
164
-            'EXT_FIELD_email'           => '[email protected]',
165
-            'EXT_FIELD_phone'           => '380380380380',
166
-            'EXT_FIELD_custom_data'     => [
167
-                0 => [
168
-                    'order_id'  => '10',
169
-                    'name'      => 'Bill Soul',
170
-                ],
171
-            ],
172
-        ]);
173
-    }
174
-
175
-    public function testGetOrders()
176
-    {
177
-        $order = new Order();
178
-
179
-        $orderParameters = Order::fromArray([
180
-            'offset'    => 0,
181
-            'limit'     => 5,
182
-        ]);
183
-
184
-        $response = $order->getOrders($orderParameters);
185
-
186
-        $this->assertNotNull($response);
187
-        $this->assertTrue(is_array($response));
188
-        $this->assertTrue(isset($response['total']));
189
-        $this->assertTrue(isset($response['results']));
190
-        $this->assertInstanceOf(
191
-            Order::class,
192
-            Order::fromArray($response['results'][0])
193
-        );
194
-    }
195
-
196
-    public function testCreateNewOrder()
197
-    {
198
-        $orderParameters = Order::fromArray([
199
-            'address_1'                 => '106 Liberty St, New York, NY 10006, USA',
200
-            'address_alias'             => 'BK Restaurant #: 2446',
201
-            'cached_lat'                => 40.709637,
202
-            'cached_lng'                => -74.011912,
203
-            'curbside_lat'              => 40.709637,
204
-            'curbside_lng'              => -74.011912,
205
-            'address_city'              => 'New York',
206
-            'EXT_FIELD_first_name'      => 'Lui',
207
-            'EXT_FIELD_last_name'       => 'Carol',
208
-            'EXT_FIELD_email'           => '[email protected]',
209
-            'EXT_FIELD_phone'           => '897946541',
210
-            'local_time_window_end'     => 39000,
211
-            'local_time_window_end_2'   => 46200,
212
-            'local_time_window_start'   => 37800,
213
-            'local_time_window_start_2' => 45000,
214
-            'local_timezone_string'     => 'America/New_York',
215
-            'order_icon'                => 'emoji/emoji-bank',
216
-        ]);
217
-
218
-        $order = new Order();
219
-
220
-        $response = $order->addOrder($orderParameters);
221
-
222
-        self::assertNotNull($response);
223
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
224
-
225
-        self::$createdOrders[] = $response;
226
-    }
227
-
228
-    public function testAddOrdersToOptimization()
229
-    {
230
-        $body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_optimization_data.json'), true);
231
-
232
-        $optimizationProblemId = self::$createdProblems[0]->optimization_problem_id;
233
-
234
-        $orderParameters = [
235
-            'optimization_problem_id'   => $optimizationProblemId,
236
-            'redirect'                  => 0,
237
-            'device_type'               => 'web',
238
-            'addresses'                 => $body['addresses'],
239
-        ];
240
-
241
-        $order = new Order();
242
-
243
-        $response = $order->addOrder2Optimization($orderParameters);
244
-
245
-        self::assertNotNull($response);
246
-        self::assertInstanceOf(OptimizationProblem::class, OptimizationProblem::fromArray($response));
247
-    }
248
-
249
-    public function testAddOrdersToRoute()
250
-    {
251
-        $this->markTestSkipped('Read old data.');
252
-
253
-        $body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_route_data.json'), true);
254
-
255
-        $routeId = self::$createdProblems[0]->routes[0]->route_id;
256
-
257
-        $orderParameters = Order::fromArray([
258
-            'route_id'  => $routeId,
259
-            'redirect'  => 0,
260
-            'addresses' => $body['addresses'],
261
-        ]);
262
-
263
-        $order = new Order();
264
-
265
-        $response = $order->addOrder2Route($orderParameters);
266
-
267
-        self::assertNotNull($response);
268
-        self::assertInstanceOf(Route::class, Route::fromArray($response));
269
-    }
270
-
271
-    public function testAddScheduledOrder()
272
-    {
273
-        $orderParameters = Order::fromArray([
274
-            'address_1'                 => '318 S 39th St, Louisville, KY 40212, USA',
275
-            'cached_lat'                => 38.259326,
276
-            'cached_lng'                => -85.814979,
277
-            'curbside_lat'              => 38.259326,
278
-            'curbside_lng'              => -85.814979,
279
-            'address_alias'             => '318 S 39th St 40212',
280
-            'address_city'              => 'Louisville',
281
-            'EXT_FIELD_first_name'      => 'Lui',
282
-            'EXT_FIELD_last_name'       => 'Carol',
283
-            'EXT_FIELD_email'           => '[email protected]',
284
-            'EXT_FIELD_phone'           => '897946541',
285
-            'EXT_FIELD_custom_data'     => ['order_type' => 'scheduled order'],
286
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
287
-            'local_time_window_end'     => 39000,
288
-            'local_time_window_end_2'   => 46200,
289
-            'local_time_window_start'   => 37800,
290
-            'local_time_window_start_2' => 45000,
291
-            'local_timezone_string'     => 'America/New_York',
292
-            'order_icon'                => 'emoji/emoji-bank',
293
-        ]);
294
-
295
-        $order = new Order();
296
-
297
-        $response = $order->addOrder($orderParameters);
298
-
299
-        self::assertNotNull($response);
300
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
301
-
302
-        self::$createdOrders[] = $response;
303
-    }
304
-
305
-    public function testCreateOrderWithCustomField()
306
-    {
307
-        $orderParameters = Order::fromArray([
308
-            'address_1'                => '1358 E Luzerne St, Philadelphia, PA 19124, US',
309
-            'cached_lat'               => 48.335991,
310
-            'cached_lng'               => 31.18287,
311
-            'day_scheduled_for_YYMMDD' => '2019-10-11',
312
-            'address_alias'            => 'Auto test address',
313
-            'custom_user_fields' => [
314
-                OrderCustomField::fromArray([
315
-                    'order_custom_field_id'    => 93,
316
-                    'order_custom_field_value' => 'false'
317
-                ])
318
-            ]
319
-        ]);
320
-
321
-        $order = new Order();
322
-
323
-        $response = $order->addOrder($orderParameters);
324
-
325
-        self::assertNotNull($response);
326
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
327
-        $this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
328
-        $this->assertEquals(false, $response['custom_user_fields'][0]['order_custom_field_value']);
329
-
330
-        self::$createdOrders[] = $response;
331
-    }
332
-
333
-    public function testGetOrderByID()
334
-    {
335
-        $order = new Order();
336
-
337
-        $orderID = self::$createdOrders[0]['order_id'];
338
-
339
-        // Get an order
340
-        $orderParameters = Order::fromArray([
341
-            'order_id' => $orderID,
342
-        ]);
343
-
344
-        $response = $order->getOrder($orderParameters);
345
-
346
-        self::assertNotNull($response);
347
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
348
-    }
349
-
350
-    public function testGetOrderByUUID()
351
-    {
352
-        $order = new Order();
353
-
354
-        $orderUUID = self::$createdOrders[0]['order_uuid'];
355
-
356
-        // Get an order
357
-        $orderParameters = Order::fromArray([
358
-            'order_id' => $orderUUID,
359
-        ]);
360
-
361
-        $response = $order->getOrder($orderParameters);
362
-
363
-        self::assertNotNull($response);
364
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
365
-    }
366
-
367
-    public function testGetOrderByInsertedDate()
368
-    {
369
-        $orderParameters = Order::fromArray([
370
-            'day_added_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
371
-            'offset'            => 0,
372
-            'limit'             => 5,
373
-        ]);
374
-
375
-        $order = new Order();
376
-
377
-        $response = $order->getOrder($orderParameters);
378
-
379
-        $this->assertNotNull($response);
380
-        $this->assertTrue(is_array($response));
381
-        $this->assertTrue(isset($response['total']));
382
-        $this->assertTrue(isset($response['results']));
383
-        $this->assertInstanceOf(
384
-            Order::class,
385
-            Order::fromArray($response['results'][0])
386
-        );
387
-    }
388
-
389
-    public function testGetOrderByScheduledDate()
390
-    {
391
-        $orderParameters = Order::fromArray([
392
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
393
-            'offset'                    => 0,
394
-            'limit'                     => 5,
395
-        ]);
396
-
397
-        $order = new Order();
398
-
399
-        $response = $order->getOrder($orderParameters);
400
-
401
-        $this->assertNotNull($response);
402
-        $this->assertTrue(is_array($response));
403
-        $this->assertTrue(isset($response['total']));
404
-        $this->assertTrue(isset($response['results']));
405
-        $this->assertInstanceOf(
406
-            Order::class,
407
-            Order::fromArray($response['results'][0])
408
-        );
409
-    }
410
-
411
-    public function testGetOrdersByCustomFields()
412
-    {
413
-        $orderParameters = Order::fromArray([
414
-            'fields'    => 'order_id,member_id',
415
-            'offset'    => 0,
416
-            'limit'     => 5,
417
-        ]);
418
-
419
-        $order = new Order();
420
-
421
-        $response = $order->getOrder($orderParameters);
422
-
423
-        $response = $order->getOrder($orderParameters);
424
-
425
-        $this->assertNotNull($response);
426
-        $this->assertTrue(is_array($response));
427
-        $this->assertTrue(isset($response['total']));
428
-        $this->assertTrue(isset($response['results']));
429
-        $this->assertTrue(isset($response['fields']));
430
-        $this->assertInstanceOf(
431
-            Order::class,
432
-            Order::fromArray($response['results'][0])
433
-        );
434
-    }
435
-
436
-    public function testGetOrdersByScheduleFilter()
437
-    {
438
-        $orderParameters = Order::fromArray([
439
-            'limit'  => 5,
440
-            'filter' => [
441
-                'display'               => 'all',
442
-                'scheduled_for_YYMMDD'  => [
443
-                    date('Y-m-d', strtotime('-1 days')),
444
-                    date('Y-m-d', strtotime('1 days'))
445
-                ]
446
-            ]
447
-        ]);
448
-
449
-        $order = new Order();
450
-
451
-        $response = $order->getOrder($orderParameters);
452
-
453
-        $this->assertNotNull($response);
454
-        $this->assertTrue(is_array($response));
455
-        $this->assertTrue(isset($response['total']));
456
-        $this->assertTrue(isset($response['results']));
457
-        $this->assertInstanceOf(
458
-            Order::class,
459
-            Order::fromArray($response['results'][0])
460
-        );
461
-    }
462
-
463
-    public function testGetOrdersBySpecifiedText()
464
-    {
465
-        $orderParameters = Order::fromArray([
466
-            'query'     => 'Auto test',
467
-            'offset'    => 0,
468
-            'limit'     => 5,
469
-        ]);
470
-
471
-        $order = new Order();
472
-
473
-        $response = $order->getOrder($orderParameters);
474
-
475
-        $this->assertNotNull($response);
476
-        $this->assertTrue(is_array($response));
477
-        $this->assertTrue(isset($response['total']));
478
-        $this->assertTrue(isset($response['results']));
479
-        $this->assertInstanceOf(
480
-            Order::class,
481
-            Order::fromArray($response['results'][0])
482
-        );
483
-    }
484
-
485
-    public function testUpdateOrder()
486
-    {
487
-        $order = new Order();
488
-
489
-        // Update the order
490
-        self::$createdOrders[0]['address_2'] = 'Lviv';
491
-        self::$createdOrders[0]['EXT_FIELD_phone'] = '032268593';
492
-        self::$createdOrders[0]['EXT_FIELD_custom_data'] = [
493
-            0 => [
494
-                'customer_no' => '11',
495
-            ],
496
-        ];
497
-
498
-        $response = $order->updateOrder(self::$createdOrders[0]);
499
-
500
-        $this->assertNotNull($response);
501
-        $this->assertInstanceOf(Order::class, Order::fromArray($response));
502
-        $this->assertEquals('Lviv', $response['address_2']);
503
-        $this->assertEquals('032268593', $response['EXT_FIELD_phone']);
504
-        $this->assertEquals(
505
-            [0 => '{"order_id":"10","name":"Bill Soul"}'],
506
-            $response['EXT_FIELD_custom_data']
507
-        );
508
-    }
509
-
510
-    public function testUpdateOrderWithCustomFiel()
511
-    {
512
-        $orderParameters = Order::fromArray([
513
-            'order_id'              => self::$createdOrders[0]['order_id'],
514
-            'custom_user_fields'    => [
515
-                OrderCustomField::fromArray([
516
-                    'order_custom_field_id'    => 93,
517
-                    'order_custom_field_value' => 'true'
518
-                ])
519
-            ]
520
-        ]);
521
-
522
-        $order = new Order();
523
-
524
-        $response = $order->updateOrder($orderParameters);
525
-
526
-        $this->assertNotNull($response);
527
-        $this->assertInstanceOf(Order::class, Order::fromArray($response));
528
-        $this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
529
-        $this->assertEquals(true, $response['custom_user_fields'][0]['order_custom_field_value']);
530
-    }
531
-
532
-    public function testDeleteOrderByUuid()
533
-    {
534
-        $lastOrder = array_pop(self::$createdOrders);
535
-        if ($lastOrder != null) {
536
-            $order = new Order();
537
-            $ids = [
538
-                "order_ids" => [$lastOrder['order_uuid']]
539
-            ];
540
-
541
-            $response = $order->removeOrder($ids);
542
-
543
-            if (!is_null($response) && isset($response['status']) && $response['status']) {
544
-                echo "The test order removed by UUID <br>";
545
-            }
546
-        }
547
-    }
548
-
549
-    public static function tearDownAfterClass()
550
-    {
551
-        if (sizeof(self::$createdOrders)) {
552
-            $orderIDs = [];
553
-
554
-            foreach (self::$createdOrders as $ord) {
555
-                $orderIDs[] = $ord['order_id'];
556
-            }
557
-
558
-            $orderParameters = Order::fromArray([
559
-                'order_ids' => $orderIDs
560
-            ]);
561
-
562
-            $order = new Order();
563
-
564
-            $response = $order->removeOrder($orderParameters);
565
-
566
-            if (!is_null($response) &&
567
-                isset($response['status']) &&
568
-                $response['status']) {
569
-                echo "The test orders removed <br>";
570
-            }
571
-        }
572
-
573
-        if (sizeof(self::$createdProblems)>0) {
574
-            $optimizationProblemIDs = [];
575
-
576
-            foreach (self::$createdProblems as $problem) {
577
-                $optimizationProblemId = $problem->optimization_problem_id;
578
-
579
-                $optimizationProblemIDs[] = $optimizationProblemId;
580
-            }
581
-
582
-            $params = [
583
-                'optimization_problem_ids' => $optimizationProblemIDs,
584
-                'redirect'                 => 0,
585
-            ];
586
-
587
-            $problem = new OptimizationProblem();
588
-            $result = $problem->removeOptimization($params);
589
-
590
-            if ($result!=null && $result['status']==true) {
591
-                echo "The test optimizations were removed <br>";
592
-            } else {
593
-                echo "Cannot remove the test optimizations <br>";
594
-            }
595
-        }
596
-    }
23
+	public static $createdOrders = [];
24
+	public static $createdProblems = [];
25
+
26
+	public static function setUpBeforeClass()
27
+	{
28
+		Route4Me::setApiKey(Constants::API_KEY);
29
+
30
+		//region -- Create Test Optimization --
31
+
32
+		// Huge list of addresses
33
+		$json = json_decode(file_get_contents(dirname(__FILE__).'/data/addresses.json'), true);
34
+		$json = array_slice($json, 0, 10);
35
+
36
+		$addresses = [];
37
+		foreach ($json as $address) {
38
+			$addresses[] = Address::fromArray($address);
39
+		}
40
+
41
+		$parameters = RouteParameters::fromArray([
42
+			'algorithm_type'    => Algorithmtype::TSP,
43
+			'route_name'        => 'Single Driver Multiple TW 10 Stops '.date('Y-m-d H:i'),
44
+			'route_date'        => time() + 24 * 60 * 60,
45
+			'route_time'        => 5 * 3600 + 30 * 60,
46
+			'distance_unit'     => DistanceUnit::MILES,
47
+			'device_type'       => DeviceType::WEB,
48
+			'optimize'          => OptimizationType::DISTANCE,
49
+			'metric'            => Metric::GEODESIC,
50
+		]);
51
+
52
+		$optimizationParams = new OptimizationProblemParams();
53
+		$optimizationParams->setAddresses($addresses);
54
+		$optimizationParams->setParameters($parameters);
55
+
56
+		$problem = OptimizationProblem::optimize($optimizationParams);
57
+
58
+		self::$createdProblems[] = $problem;
59
+
60
+		//endregion
61
+
62
+		//region -- Create Test Order --
63
+
64
+		$orderParameters = Order::fromArray([
65
+			'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
66
+			'cached_lat'                => 48.335991,
67
+			'cached_lng'                => 31.18287,
68
+			'address_alias'             => 'Auto test address',
69
+			'address_city'              => 'Philadelphia',
70
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
71
+			'EXT_FIELD_first_name'      => 'Igor',
72
+			'EXT_FIELD_last_name'       => 'Progman',
73
+			'EXT_FIELD_email'           => '[email protected]',
74
+			'EXT_FIELD_phone'           => '380380380380',
75
+			'EXT_FIELD_custom_data'     => [
76
+				0 => [
77
+					'order_id'  => '10',
78
+					'name'      => 'Bill Soul',
79
+				],
80
+			],
81
+		]);
82
+
83
+		$order = new Order();
84
+
85
+		$response = $order->addOrder($orderParameters);
86
+
87
+		self::assertNotNull($response);
88
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
89
+
90
+		self::$createdOrders[] = $response;
91
+
92
+		//endregion
93
+	}
94
+
95
+	public function testFromArray()
96
+	{
97
+		$orderParameters = Order::fromArray([
98
+			'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
99
+			'cached_lat'                => 48.335991,
100
+			'cached_lng'                => 31.18287,
101
+			'address_alias'             => 'Auto test address',
102
+			'address_city'              => 'Philadelphia',
103
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
104
+			'EXT_FIELD_first_name'      => 'Igor',
105
+			'EXT_FIELD_last_name'       => 'Progman',
106
+			'EXT_FIELD_email'           => '[email protected]',
107
+			'EXT_FIELD_phone'           => '380380380380',
108
+			'EXT_FIELD_custom_data'     => [
109
+				0 => [
110
+					'order_id'  => '10',
111
+					'name'      => 'Bill Soul',
112
+				],
113
+			],
114
+		]);
115
+
116
+		$this->assertEquals('1358 E Luzerne St, Philadelphia, PA 19124, US', $orderParameters->address_1);
117
+		$this->assertEquals(48.335991, $orderParameters->cached_lat);
118
+		$this->assertEquals(31.18287, $orderParameters->cached_lng);
119
+		$this->assertEquals('Auto test address', $orderParameters->address_alias);
120
+		$this->assertEquals('Philadelphia', $orderParameters->address_city);
121
+		$this->assertEquals(date('Y-m-d'), $orderParameters->day_scheduled_for_YYMMDD);
122
+		$this->assertEquals('Igor', $orderParameters->EXT_FIELD_first_name);
123
+		$this->assertEquals('Progman', $orderParameters->EXT_FIELD_last_name);
124
+		$this->assertEquals('[email protected]', $orderParameters->EXT_FIELD_email);
125
+		$this->assertEquals('380380380380', $orderParameters->EXT_FIELD_phone);
126
+		$this->assertEquals([
127
+			0 => [
128
+				'order_id'  => '10',
129
+				'name'      => 'Bill Soul',
130
+			],
131
+		], $orderParameters->EXT_FIELD_custom_data);
132
+	}
133
+
134
+	public function testToArray()
135
+	{
136
+		$orderParameters = Order::fromArray([
137
+			'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
138
+			'cached_lat'                => 48.335991,
139
+			'cached_lng'                => 31.18287,
140
+			'address_alias'             => 'Auto test address',
141
+			'address_city'              => 'Philadelphia',
142
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
143
+			'EXT_FIELD_first_name'      => 'Igor',
144
+			'EXT_FIELD_last_name'       => 'Progman',
145
+			'EXT_FIELD_email'           => '[email protected]',
146
+			'EXT_FIELD_phone'           => '380380380380',
147
+			'EXT_FIELD_custom_data'     => [
148
+				0 => [
149
+					'order_id'  => '10',
150
+					'name'      => 'Bill Soul',
151
+				],
152
+			],
153
+		]);
154
+
155
+		$this->assertEquals($orderParameters->toArray(), [
156
+			'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
157
+			'cached_lat'                => 48.335991,
158
+			'cached_lng'                => 31.18287,
159
+			'address_alias'             => 'Auto test address',
160
+			'address_city'              => 'Philadelphia',
161
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
162
+			'EXT_FIELD_first_name'      => 'Igor',
163
+			'EXT_FIELD_last_name'       => 'Progman',
164
+			'EXT_FIELD_email'           => '[email protected]',
165
+			'EXT_FIELD_phone'           => '380380380380',
166
+			'EXT_FIELD_custom_data'     => [
167
+				0 => [
168
+					'order_id'  => '10',
169
+					'name'      => 'Bill Soul',
170
+				],
171
+			],
172
+		]);
173
+	}
174
+
175
+	public function testGetOrders()
176
+	{
177
+		$order = new Order();
178
+
179
+		$orderParameters = Order::fromArray([
180
+			'offset'    => 0,
181
+			'limit'     => 5,
182
+		]);
183
+
184
+		$response = $order->getOrders($orderParameters);
185
+
186
+		$this->assertNotNull($response);
187
+		$this->assertTrue(is_array($response));
188
+		$this->assertTrue(isset($response['total']));
189
+		$this->assertTrue(isset($response['results']));
190
+		$this->assertInstanceOf(
191
+			Order::class,
192
+			Order::fromArray($response['results'][0])
193
+		);
194
+	}
195
+
196
+	public function testCreateNewOrder()
197
+	{
198
+		$orderParameters = Order::fromArray([
199
+			'address_1'                 => '106 Liberty St, New York, NY 10006, USA',
200
+			'address_alias'             => 'BK Restaurant #: 2446',
201
+			'cached_lat'                => 40.709637,
202
+			'cached_lng'                => -74.011912,
203
+			'curbside_lat'              => 40.709637,
204
+			'curbside_lng'              => -74.011912,
205
+			'address_city'              => 'New York',
206
+			'EXT_FIELD_first_name'      => 'Lui',
207
+			'EXT_FIELD_last_name'       => 'Carol',
208
+			'EXT_FIELD_email'           => '[email protected]',
209
+			'EXT_FIELD_phone'           => '897946541',
210
+			'local_time_window_end'     => 39000,
211
+			'local_time_window_end_2'   => 46200,
212
+			'local_time_window_start'   => 37800,
213
+			'local_time_window_start_2' => 45000,
214
+			'local_timezone_string'     => 'America/New_York',
215
+			'order_icon'                => 'emoji/emoji-bank',
216
+		]);
217
+
218
+		$order = new Order();
219
+
220
+		$response = $order->addOrder($orderParameters);
221
+
222
+		self::assertNotNull($response);
223
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
224
+
225
+		self::$createdOrders[] = $response;
226
+	}
227
+
228
+	public function testAddOrdersToOptimization()
229
+	{
230
+		$body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_optimization_data.json'), true);
231
+
232
+		$optimizationProblemId = self::$createdProblems[0]->optimization_problem_id;
233
+
234
+		$orderParameters = [
235
+			'optimization_problem_id'   => $optimizationProblemId,
236
+			'redirect'                  => 0,
237
+			'device_type'               => 'web',
238
+			'addresses'                 => $body['addresses'],
239
+		];
240
+
241
+		$order = new Order();
242
+
243
+		$response = $order->addOrder2Optimization($orderParameters);
244
+
245
+		self::assertNotNull($response);
246
+		self::assertInstanceOf(OptimizationProblem::class, OptimizationProblem::fromArray($response));
247
+	}
248
+
249
+	public function testAddOrdersToRoute()
250
+	{
251
+		$this->markTestSkipped('Read old data.');
252
+
253
+		$body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_route_data.json'), true);
254
+
255
+		$routeId = self::$createdProblems[0]->routes[0]->route_id;
256
+
257
+		$orderParameters = Order::fromArray([
258
+			'route_id'  => $routeId,
259
+			'redirect'  => 0,
260
+			'addresses' => $body['addresses'],
261
+		]);
262
+
263
+		$order = new Order();
264
+
265
+		$response = $order->addOrder2Route($orderParameters);
266
+
267
+		self::assertNotNull($response);
268
+		self::assertInstanceOf(Route::class, Route::fromArray($response));
269
+	}
270
+
271
+	public function testAddScheduledOrder()
272
+	{
273
+		$orderParameters = Order::fromArray([
274
+			'address_1'                 => '318 S 39th St, Louisville, KY 40212, USA',
275
+			'cached_lat'                => 38.259326,
276
+			'cached_lng'                => -85.814979,
277
+			'curbside_lat'              => 38.259326,
278
+			'curbside_lng'              => -85.814979,
279
+			'address_alias'             => '318 S 39th St 40212',
280
+			'address_city'              => 'Louisville',
281
+			'EXT_FIELD_first_name'      => 'Lui',
282
+			'EXT_FIELD_last_name'       => 'Carol',
283
+			'EXT_FIELD_email'           => '[email protected]',
284
+			'EXT_FIELD_phone'           => '897946541',
285
+			'EXT_FIELD_custom_data'     => ['order_type' => 'scheduled order'],
286
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
287
+			'local_time_window_end'     => 39000,
288
+			'local_time_window_end_2'   => 46200,
289
+			'local_time_window_start'   => 37800,
290
+			'local_time_window_start_2' => 45000,
291
+			'local_timezone_string'     => 'America/New_York',
292
+			'order_icon'                => 'emoji/emoji-bank',
293
+		]);
294
+
295
+		$order = new Order();
296
+
297
+		$response = $order->addOrder($orderParameters);
298
+
299
+		self::assertNotNull($response);
300
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
301
+
302
+		self::$createdOrders[] = $response;
303
+	}
304
+
305
+	public function testCreateOrderWithCustomField()
306
+	{
307
+		$orderParameters = Order::fromArray([
308
+			'address_1'                => '1358 E Luzerne St, Philadelphia, PA 19124, US',
309
+			'cached_lat'               => 48.335991,
310
+			'cached_lng'               => 31.18287,
311
+			'day_scheduled_for_YYMMDD' => '2019-10-11',
312
+			'address_alias'            => 'Auto test address',
313
+			'custom_user_fields' => [
314
+				OrderCustomField::fromArray([
315
+					'order_custom_field_id'    => 93,
316
+					'order_custom_field_value' => 'false'
317
+				])
318
+			]
319
+		]);
320
+
321
+		$order = new Order();
322
+
323
+		$response = $order->addOrder($orderParameters);
324
+
325
+		self::assertNotNull($response);
326
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
327
+		$this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
328
+		$this->assertEquals(false, $response['custom_user_fields'][0]['order_custom_field_value']);
329
+
330
+		self::$createdOrders[] = $response;
331
+	}
332
+
333
+	public function testGetOrderByID()
334
+	{
335
+		$order = new Order();
336
+
337
+		$orderID = self::$createdOrders[0]['order_id'];
338
+
339
+		// Get an order
340
+		$orderParameters = Order::fromArray([
341
+			'order_id' => $orderID,
342
+		]);
343
+
344
+		$response = $order->getOrder($orderParameters);
345
+
346
+		self::assertNotNull($response);
347
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
348
+	}
349
+
350
+	public function testGetOrderByUUID()
351
+	{
352
+		$order = new Order();
353
+
354
+		$orderUUID = self::$createdOrders[0]['order_uuid'];
355
+
356
+		// Get an order
357
+		$orderParameters = Order::fromArray([
358
+			'order_id' => $orderUUID,
359
+		]);
360
+
361
+		$response = $order->getOrder($orderParameters);
362
+
363
+		self::assertNotNull($response);
364
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
365
+	}
366
+
367
+	public function testGetOrderByInsertedDate()
368
+	{
369
+		$orderParameters = Order::fromArray([
370
+			'day_added_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
371
+			'offset'            => 0,
372
+			'limit'             => 5,
373
+		]);
374
+
375
+		$order = new Order();
376
+
377
+		$response = $order->getOrder($orderParameters);
378
+
379
+		$this->assertNotNull($response);
380
+		$this->assertTrue(is_array($response));
381
+		$this->assertTrue(isset($response['total']));
382
+		$this->assertTrue(isset($response['results']));
383
+		$this->assertInstanceOf(
384
+			Order::class,
385
+			Order::fromArray($response['results'][0])
386
+		);
387
+	}
388
+
389
+	public function testGetOrderByScheduledDate()
390
+	{
391
+		$orderParameters = Order::fromArray([
392
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
393
+			'offset'                    => 0,
394
+			'limit'                     => 5,
395
+		]);
396
+
397
+		$order = new Order();
398
+
399
+		$response = $order->getOrder($orderParameters);
400
+
401
+		$this->assertNotNull($response);
402
+		$this->assertTrue(is_array($response));
403
+		$this->assertTrue(isset($response['total']));
404
+		$this->assertTrue(isset($response['results']));
405
+		$this->assertInstanceOf(
406
+			Order::class,
407
+			Order::fromArray($response['results'][0])
408
+		);
409
+	}
410
+
411
+	public function testGetOrdersByCustomFields()
412
+	{
413
+		$orderParameters = Order::fromArray([
414
+			'fields'    => 'order_id,member_id',
415
+			'offset'    => 0,
416
+			'limit'     => 5,
417
+		]);
418
+
419
+		$order = new Order();
420
+
421
+		$response = $order->getOrder($orderParameters);
422
+
423
+		$response = $order->getOrder($orderParameters);
424
+
425
+		$this->assertNotNull($response);
426
+		$this->assertTrue(is_array($response));
427
+		$this->assertTrue(isset($response['total']));
428
+		$this->assertTrue(isset($response['results']));
429
+		$this->assertTrue(isset($response['fields']));
430
+		$this->assertInstanceOf(
431
+			Order::class,
432
+			Order::fromArray($response['results'][0])
433
+		);
434
+	}
435
+
436
+	public function testGetOrdersByScheduleFilter()
437
+	{
438
+		$orderParameters = Order::fromArray([
439
+			'limit'  => 5,
440
+			'filter' => [
441
+				'display'               => 'all',
442
+				'scheduled_for_YYMMDD'  => [
443
+					date('Y-m-d', strtotime('-1 days')),
444
+					date('Y-m-d', strtotime('1 days'))
445
+				]
446
+			]
447
+		]);
448
+
449
+		$order = new Order();
450
+
451
+		$response = $order->getOrder($orderParameters);
452
+
453
+		$this->assertNotNull($response);
454
+		$this->assertTrue(is_array($response));
455
+		$this->assertTrue(isset($response['total']));
456
+		$this->assertTrue(isset($response['results']));
457
+		$this->assertInstanceOf(
458
+			Order::class,
459
+			Order::fromArray($response['results'][0])
460
+		);
461
+	}
462
+
463
+	public function testGetOrdersBySpecifiedText()
464
+	{
465
+		$orderParameters = Order::fromArray([
466
+			'query'     => 'Auto test',
467
+			'offset'    => 0,
468
+			'limit'     => 5,
469
+		]);
470
+
471
+		$order = new Order();
472
+
473
+		$response = $order->getOrder($orderParameters);
474
+
475
+		$this->assertNotNull($response);
476
+		$this->assertTrue(is_array($response));
477
+		$this->assertTrue(isset($response['total']));
478
+		$this->assertTrue(isset($response['results']));
479
+		$this->assertInstanceOf(
480
+			Order::class,
481
+			Order::fromArray($response['results'][0])
482
+		);
483
+	}
484
+
485
+	public function testUpdateOrder()
486
+	{
487
+		$order = new Order();
488
+
489
+		// Update the order
490
+		self::$createdOrders[0]['address_2'] = 'Lviv';
491
+		self::$createdOrders[0]['EXT_FIELD_phone'] = '032268593';
492
+		self::$createdOrders[0]['EXT_FIELD_custom_data'] = [
493
+			0 => [
494
+				'customer_no' => '11',
495
+			],
496
+		];
497
+
498
+		$response = $order->updateOrder(self::$createdOrders[0]);
499
+
500
+		$this->assertNotNull($response);
501
+		$this->assertInstanceOf(Order::class, Order::fromArray($response));
502
+		$this->assertEquals('Lviv', $response['address_2']);
503
+		$this->assertEquals('032268593', $response['EXT_FIELD_phone']);
504
+		$this->assertEquals(
505
+			[0 => '{"order_id":"10","name":"Bill Soul"}'],
506
+			$response['EXT_FIELD_custom_data']
507
+		);
508
+	}
509
+
510
+	public function testUpdateOrderWithCustomFiel()
511
+	{
512
+		$orderParameters = Order::fromArray([
513
+			'order_id'              => self::$createdOrders[0]['order_id'],
514
+			'custom_user_fields'    => [
515
+				OrderCustomField::fromArray([
516
+					'order_custom_field_id'    => 93,
517
+					'order_custom_field_value' => 'true'
518
+				])
519
+			]
520
+		]);
521
+
522
+		$order = new Order();
523
+
524
+		$response = $order->updateOrder($orderParameters);
525
+
526
+		$this->assertNotNull($response);
527
+		$this->assertInstanceOf(Order::class, Order::fromArray($response));
528
+		$this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
529
+		$this->assertEquals(true, $response['custom_user_fields'][0]['order_custom_field_value']);
530
+	}
531
+
532
+	public function testDeleteOrderByUuid()
533
+	{
534
+		$lastOrder = array_pop(self::$createdOrders);
535
+		if ($lastOrder != null) {
536
+			$order = new Order();
537
+			$ids = [
538
+				"order_ids" => [$lastOrder['order_uuid']]
539
+			];
540
+
541
+			$response = $order->removeOrder($ids);
542
+
543
+			if (!is_null($response) && isset($response['status']) && $response['status']) {
544
+				echo "The test order removed by UUID <br>";
545
+			}
546
+		}
547
+	}
548
+
549
+	public static function tearDownAfterClass()
550
+	{
551
+		if (sizeof(self::$createdOrders)) {
552
+			$orderIDs = [];
553
+
554
+			foreach (self::$createdOrders as $ord) {
555
+				$orderIDs[] = $ord['order_id'];
556
+			}
557
+
558
+			$orderParameters = Order::fromArray([
559
+				'order_ids' => $orderIDs
560
+			]);
561
+
562
+			$order = new Order();
563
+
564
+			$response = $order->removeOrder($orderParameters);
565
+
566
+			if (!is_null($response) &&
567
+				isset($response['status']) &&
568
+				$response['status']) {
569
+				echo "The test orders removed <br>";
570
+			}
571
+		}
572
+
573
+		if (sizeof(self::$createdProblems)>0) {
574
+			$optimizationProblemIDs = [];
575
+
576
+			foreach (self::$createdProblems as $problem) {
577
+				$optimizationProblemId = $problem->optimization_problem_id;
578
+
579
+				$optimizationProblemIDs[] = $optimizationProblemId;
580
+			}
581
+
582
+			$params = [
583
+				'optimization_problem_ids' => $optimizationProblemIDs,
584
+				'redirect'                 => 0,
585
+			];
586
+
587
+			$problem = new OptimizationProblem();
588
+			$result = $problem->removeOptimization($params);
589
+
590
+			if ($result!=null && $result['status']==true) {
591
+				echo "The test optimizations were removed <br>";
592
+			} else {
593
+				echo "Cannot remove the test optimizations <br>";
594
+			}
595
+		}
596
+	}
597 597
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -532,7 +532,7 @@
 block discarded – undo
532 532
     public function testDeleteOrderByUuid()
533 533
     {
534 534
         $lastOrder = array_pop(self::$createdOrders);
535
-        if ($lastOrder != null) {
535
+        if ($lastOrder!=null) {
536 536
             $order = new Order();
537 537
             $ids = [
538 538
                 "order_ids" => [$lastOrder['order_uuid']]
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/ResponseSearch.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -14,41 +14,41 @@
 block discarded – undo
14 14
  */
15 15
 class ResponseSearch extends Common
16 16
 {
17
-    /**
18
-     * Total number of orders found.
19
-     */
20
-    public ?int $total = null;
17
+	/**
18
+	 * Total number of orders found.
19
+	 */
20
+	public ?int $total = null;
21 21
 
22
-    /**
23
-     * An array of field names asked in the request.
24
-     * If null then field names were not asked.
25
-     */
26
-    public ?array $fields = null;
22
+	/**
23
+	 * An array of field names asked in the request.
24
+	 * If null then field names were not asked.
25
+	 */
26
+	public ?array $fields = null;
27 27
 
28
-    /**
29
-     * An array of orders received from the server.
30
-     */
31
-    public ?array $results = null;
28
+	/**
29
+	 * An array of orders received from the server.
30
+	 */
31
+	public ?array $results = null;
32 32
 
33
-    public function __construct(array $params = null)
34
-    {
35
-        if ($params !== null) {
36
-            foreach ($this as $key => $value) {
37
-                if (isset($params[$key])) {
38
-                    if ($key === 'results') {
39
-                        $this->{$key} = array();
40
-                        foreach ($params[$key] as $r_key => $r_value) {
41
-                            if (is_array($r_value)) {
42
-                                array_push($this->{$key}, new ResponseOrder($r_value));
43
-                            } elseif (is_object($r_value) && $r_value instanceof ResponseOrder) {
44
-                                array_push($this->{$key}, $r_value);
45
-                            }
46
-                        }
47
-                    } else {
48
-                        $this->{$key} = $params[$key];
49
-                    }
50
-                }
51
-            }
52
-        }
53
-    }
33
+	public function __construct(array $params = null)
34
+	{
35
+		if ($params !== null) {
36
+			foreach ($this as $key => $value) {
37
+				if (isset($params[$key])) {
38
+					if ($key === 'results') {
39
+						$this->{$key} = array();
40
+						foreach ($params[$key] as $r_key => $r_value) {
41
+							if (is_array($r_value)) {
42
+								array_push($this->{$key}, new ResponseOrder($r_value));
43
+							} elseif (is_object($r_value) && $r_value instanceof ResponseOrder) {
44
+								array_push($this->{$key}, $r_value);
45
+							}
46
+						}
47
+					} else {
48
+						$this->{$key} = $params[$key];
49
+					}
50
+				}
51
+			}
52
+		}
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
 
33 33
     public function __construct(array $params = null)
34 34
     {
35
-        if ($params !== null) {
35
+        if ($params!==null) {
36 36
             foreach ($this as $key => $value) {
37 37
                 if (isset($params[$key])) {
38
-                    if ($key === 'results') {
38
+                    if ($key==='results') {
39 39
                         $this->{$key} = array();
40 40
                         foreach ($params[$key] as $r_key => $r_value) {
41 41
                             if (is_array($r_value)) {
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/CustomData.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@
 block discarded – undo
13 13
  */
14 14
 class CustomData extends Common
15 15
 {
16
-    /**
17
-     * Tracking number for order.
18
-     */
19
-    public ?string $barcode = null;
16
+	/**
17
+	 * Tracking number for order.
18
+	 */
19
+	public ?string $barcode = null;
20 20
 
21
-    /**
22
-     * Additional tracking number for order.
23
-     */
24
-    public ?string $airbillno = null;
21
+	/**
22
+	 * Additional tracking number for order.
23
+	 */
24
+	public ?string $airbillno = null;
25 25
 
26
-    /**
27
-     * Datetime String with "T" delimiter, ISO 8601.
28
-     */
29
-    public ?string $sorted_on_date = null;
26
+	/**
27
+	 * Datetime String with "T" delimiter, ISO 8601.
28
+	 */
29
+	public ?string $sorted_on_date = null;
30 30
 
31
-    /**
32
-     * Timestamp only; replaced data in`sorted_on_date` property.
33
-     */
34
-    public ?int $sorted_on_utc = null;
31
+	/**
32
+	 * Timestamp only; replaced data in`sorted_on_date` property.
33
+	 */
34
+	public ?int $sorted_on_utc = null;
35 35
 
36
-    public function __construct(array $params = null)
37
-    {
38
-        if ($params != null) {
39
-            $this->fillFromArray($params);
40
-        }
41
-    }
36
+	public function __construct(array $params = null)
37
+	{
38
+		if ($params != null) {
39
+			$this->fillFromArray($params);
40
+		}
41
+	}
42 42
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     public function __construct(array $params = null)
37 37
     {
38
-        if ($params != null) {
38
+        if ($params!=null) {
39 39
             $this->fillFromArray($params);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/GPSCoords.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@
 block discarded – undo
13 13
  */
14 14
 class GPSCoords extends Common
15 15
 {
16
-    /**
17
-     * Latitude.
18
-     */
19
-    public ?float $lat = null;
16
+	/**
17
+	 * Latitude.
18
+	 */
19
+	public ?float $lat = null;
20 20
 
21
-    /**
22
-     * Longitude.
23
-     */
24
-    public ?float $lng = null;
21
+	/**
22
+	 * Longitude.
23
+	 */
24
+	public ?float $lng = null;
25 25
 
26
-    public function __construct($params_or_lat = null, float $lng = null)
27
-    {
28
-        if (is_array($params_or_lat)) {
29
-            $this->fillFromArray($params_or_lat);
30
-        } elseif (is_float($params_or_lat)) {
31
-            $this->lat = $params_or_lat;
32
-            $this->lng = $lng;
33
-        }
34
-    }
26
+	public function __construct($params_or_lat = null, float $lng = null)
27
+	{
28
+		if (is_array($params_or_lat)) {
29
+			$this->fillFromArray($params_or_lat);
30
+		} elseif (is_float($params_or_lat)) {
31
+			$this->lat = $params_or_lat;
32
+			$this->lng = $lng;
33
+		}
34
+	}
35 35
 }
Please login to merge, or discard this patch.