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 ( 6c805f...bce16d )
by Igor
09:12 queued 14s
created
UnitTestFiles/Test/GeocodingUnitTests.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -10,198 +10,198 @@
 block discarded – undo
10 10
 
11 11
 class GeocodingUnitTests extends \PHPUnit\Framework\TestCase
12 12
 {
13
-    public static function setUpBeforeClass()
14
-    {
15
-        Route4Me::setApiKey(Constants::API_KEY);
16
-    }
13
+	public static function setUpBeforeClass()
14
+	{
15
+		Route4Me::setApiKey(Constants::API_KEY);
16
+	}
17 17
 
18
-    public function testFromArray()
19
-    {
20
-        $geocoding = Geocoding::fromArray([
21
-            'strExportFormat'   => 'json',
22
-            'addresses'         => 'Los20%Angeles20%International20%Airport,20%CA',
23
-        ]);
18
+	public function testFromArray()
19
+	{
20
+		$geocoding = Geocoding::fromArray([
21
+			'strExportFormat'   => 'json',
22
+			'addresses'         => 'Los20%Angeles20%International20%Airport,20%CA',
23
+		]);
24 24
 
25
-        $this->assertEquals('json', $geocoding->strExportFormat);
26
-        $this->assertEquals('Los20%Angeles20%International20%Airport,20%CA', $geocoding->addresses);
27
-    }
25
+		$this->assertEquals('json', $geocoding->strExportFormat);
26
+		$this->assertEquals('Los20%Angeles20%International20%Airport,20%CA', $geocoding->addresses);
27
+	}
28 28
 
29
-    public function testForwardGeocoding()
30
-    {
31
-        $geoCodingParameters = [
32
-            'strExportFormat'   => 'json',
33
-            'addresses'         => 'Los20%Angeles20%International20%Airport,20%CA',
34
-        ];
29
+	public function testForwardGeocoding()
30
+	{
31
+		$geoCodingParameters = [
32
+			'strExportFormat'   => 'json',
33
+			'addresses'         => 'Los20%Angeles20%International20%Airport,20%CA',
34
+		];
35 35
 
36
-        $fGeocoding = new Geocoding();
36
+		$fGeocoding = new Geocoding();
37 37
 
38
-        $result = $fGeocoding->forwardGeocoding($geoCodingParameters);
38
+		$result = $fGeocoding->forwardGeocoding($geoCodingParameters);
39 39
 
40
-        $this->assertNotNull($result);
41
-        $this->assertTrue(sizeof($result)>0);
40
+		$this->assertNotNull($result);
41
+		$this->assertTrue(sizeof($result)>0);
42 42
 
43
-        $firstGeocoding = GeocodingResponse::fromArray(
44
-            $result[0]
45
-        );
43
+		$firstGeocoding = GeocodingResponse::fromArray(
44
+			$result[0]
45
+		);
46 46
 
47
-        $this->assertContainsOnlyInstancesOf(GeocodingResponse::class, [$firstGeocoding]);
48
-    }
47
+		$this->assertContainsOnlyInstancesOf(GeocodingResponse::class, [$firstGeocoding]);
48
+	}
49 49
 
50
-    public function testReverseGeocoding()
51
-    {
52
-        $geoCodingParameters = [
53
-            'strExportFormat'   => 'json',
54
-            'addresses'         => '42.35863,-71.05670',
55
-        ];
50
+	public function testReverseGeocoding()
51
+	{
52
+		$geoCodingParameters = [
53
+			'strExportFormat'   => 'json',
54
+			'addresses'         => '42.35863,-71.05670',
55
+		];
56 56
 
57
-        $rGeocoding = new Geocoding();
57
+		$rGeocoding = new Geocoding();
58 58
 
59
-        $result = $rGeocoding->reverseGeocoding($geoCodingParameters);
59
+		$result = $rGeocoding->reverseGeocoding($geoCodingParameters);
60 60
 
61
-        $this->assertNotNull($result);
62
-        $this->assertTrue(sizeof($result)>0);
61
+		$this->assertNotNull($result);
62
+		$this->assertTrue(sizeof($result)>0);
63 63
 
64
-        $firstGeocoding = GeocodingResponse::fromArray(
65
-            $result["destination"]
66
-        );
64
+		$firstGeocoding = GeocodingResponse::fromArray(
65
+			$result["destination"]
66
+		);
67 67
 
68
-        $this->assertContainsOnlyInstancesOf(GeocodingResponse::class, [$firstGeocoding]);
69
-    }
68
+		$this->assertContainsOnlyInstancesOf(GeocodingResponse::class, [$firstGeocoding]);
69
+	}
70 70
 
71
-    public function testGetStreetData()
72
-    {
73
-        $this->markTestSkipped('must be revisited.');
71
+	public function testGetStreetData()
72
+	{
73
+		$this->markTestSkipped('must be revisited.');
74 74
 
75
-        if (Constants::API_KEY == Constants::DEMO_API_KEY) {
76
-            $className = str_replace('UnitTestFiles\\Test\\','',get_class());
77
-            self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
78
-        }
75
+		if (Constants::API_KEY == Constants::DEMO_API_KEY) {
76
+			$className = str_replace('UnitTestFiles\\Test\\','',get_class());
77
+			self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
78
+		}
79 79
 
80
-        //region Get Single Street Address
81
-        $result = RapidAddressSearchResponse::fromArray(
82
-            Geocoding::getStreetData(['pk' => 4])
83
-        );
80
+		//region Get Single Street Address
81
+		$result = RapidAddressSearchResponse::fromArray(
82
+			Geocoding::getStreetData(['pk' => 4])
83
+		);
84 84
 
85
-        $this->assertNotNull($result);
86
-        $this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$result]);
87
-        //endregion
88
-
89
-        //region Get All Street Data
90
-        $resultAll = Geocoding::getStreetData([]);
85
+		$this->assertNotNull($result);
86
+		$this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$result]);
87
+		//endregion
88
+
89
+		//region Get All Street Data
90
+		$resultAll = Geocoding::getStreetData([]);
91 91
 
92
-        $this->assertNotNull($resultAll);
93
-        $this->assertTrue(sizeof($resultAll)>0);
92
+		$this->assertNotNull($resultAll);
93
+		$this->assertTrue(sizeof($resultAll)>0);
94 94
 
95
-        $firstGeocoding = RapidAddressSearchResponse::fromArray(
96
-            $resultAll[0]
97
-        );
95
+		$firstGeocoding = RapidAddressSearchResponse::fromArray(
96
+			$resultAll[0]
97
+		);
98 98
 
99
-        $this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
100
-        //endregion
101
-
102
-        //region Get Street Data Limited
103
-        $resultLimited = Geocoding::getStreetData([
104
-            'offset' => 0,
105
-            'limit'  => 5,
106
-        ]);
99
+		$this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
100
+		//endregion
101
+
102
+		//region Get Street Data Limited
103
+		$resultLimited = Geocoding::getStreetData([
104
+			'offset' => 0,
105
+			'limit'  => 5,
106
+		]);
107 107
 
108
-        $this->assertNotNull($resultLimited);
109
-        $this->assertTrue(sizeof($resultLimited)>0);
108
+		$this->assertNotNull($resultLimited);
109
+		$this->assertTrue(sizeof($resultLimited)>0);
110 110
 
111
-        $firstGeocoding = RapidAddressSearchResponse::fromArray(
112
-            $resultLimited[0]
113
-        );
111
+		$firstGeocoding = RapidAddressSearchResponse::fromArray(
112
+			$resultLimited[0]
113
+		);
114 114
 
115
-        $this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
116
-        //endregion
117
-    }
115
+		$this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
116
+		//endregion
117
+	}
118 118
 
119
-    public function testGetZipCode()
120
-    {
121
-        $this->markTestSkipped('must be revisited.');
119
+	public function testGetZipCode()
120
+	{
121
+		$this->markTestSkipped('must be revisited.');
122 122
 
123
-        if (Constants::API_KEY == Constants::DEMO_API_KEY) {
124
-            $className = str_replace('UnitTestFiles\\Test\\','',get_class());
125
-            self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
126
-        }
123
+		if (Constants::API_KEY == Constants::DEMO_API_KEY) {
124
+			$className = str_replace('UnitTestFiles\\Test\\','',get_class());
125
+			self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
126
+		}
127 127
 
128
-        //region Get All Geocodings With Specified Zipcode
129
-        $resultZipAll = Geocoding::getZipCode(['zipcode' => '00601']);
128
+		//region Get All Geocodings With Specified Zipcode
129
+		$resultZipAll = Geocoding::getZipCode(['zipcode' => '00601']);
130 130
 
131
-        $this->assertNotNull($resultZipAll);
132
-        $this->assertTrue(sizeof($resultZipAll)>0);
131
+		$this->assertNotNull($resultZipAll);
132
+		$this->assertTrue(sizeof($resultZipAll)>0);
133 133
 
134
-        $firstGeocoding = RapidAddressSearchResponse::fromArray(
135
-            $resultZipAll[0]
136
-        );
134
+		$firstGeocoding = RapidAddressSearchResponse::fromArray(
135
+			$resultZipAll[0]
136
+		);
137 137
 
138
-        $this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
139
-        //endregion
138
+		$this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
139
+		//endregion
140 140
 
141
-        //region Get Limited Geocodings With Specified Zipcode
142
-        $resultZipLimited = Geocoding::getZipCode([
143
-            'zipcode' => '00601',
144
-            'offset'  => 0,
145
-            'limit'   => 20,
146
-        ]);
141
+		//region Get Limited Geocodings With Specified Zipcode
142
+		$resultZipLimited = Geocoding::getZipCode([
143
+			'zipcode' => '00601',
144
+			'offset'  => 0,
145
+			'limit'   => 20,
146
+		]);
147 147
 
148
-        $this->assertNotNull($resultZipLimited);
149
-        $this->assertTrue(sizeof($resultZipLimited)>0);
148
+		$this->assertNotNull($resultZipLimited);
149
+		$this->assertTrue(sizeof($resultZipLimited)>0);
150 150
 
151
-        $firstGeocoding = RapidAddressSearchResponse::fromArray(
152
-            $resultZipLimited[0]
153
-        );
151
+		$firstGeocoding = RapidAddressSearchResponse::fromArray(
152
+			$resultZipLimited[0]
153
+		);
154 154
 
155
-        $this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
156
-        //endregion
157
-    }
155
+		$this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
156
+		//endregion
157
+	}
158 158
 
159
-    public function testGetService()
160
-    {
161
-        $this->markTestSkipped('must be revisited.');
159
+	public function testGetService()
160
+	{
161
+		$this->markTestSkipped('must be revisited.');
162 162
 
163
-        if (Constants::API_KEY == Constants::DEMO_API_KEY) {
164
-            $className = str_replace('UnitTestFiles\\Test\\','',get_class());
165
-            self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
166
-        }
163
+		if (Constants::API_KEY == Constants::DEMO_API_KEY) {
164
+			$className = str_replace('UnitTestFiles\\Test\\','',get_class());
165
+			self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
166
+		}
167 167
 
168
-        //region Get All Geocodings With Specified Zipcode And House Number
169
-        $resultZipHouseAll = Geocoding::getService([
170
-            'zipcode'     => '00601',
171
-            'housenumber' => 17,
172
-        ]);
168
+		//region Get All Geocodings With Specified Zipcode And House Number
169
+		$resultZipHouseAll = Geocoding::getService([
170
+			'zipcode'     => '00601',
171
+			'housenumber' => 17,
172
+		]);
173 173
 
174
-        $this->assertNotNull($resultZipHouseAll);
175
-        $this->assertTrue(sizeof($resultZipHouseAll)>0);
174
+		$this->assertNotNull($resultZipHouseAll);
175
+		$this->assertTrue(sizeof($resultZipHouseAll)>0);
176 176
 
177
-        $firstGeocoding = RapidAddressSearchResponse::fromArray(
178
-            $resultZipHouseAll[0]
179
-        );
177
+		$firstGeocoding = RapidAddressSearchResponse::fromArray(
178
+			$resultZipHouseAll[0]
179
+		);
180 180
 
181
-        $this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
182
-        //endregion
181
+		$this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
182
+		//endregion
183 183
 
184
-        //region Get Limited Geocodings With Specified Zipcode And House Number
185
-        $resultZipHouseLimited = Geocoding::getService([
186
-            'zipcode'       => '00601',
187
-            'housenumber'   => 17,
188
-            'offset'        => 0,
189
-            'limit'         => 10,
190
-        ]);
184
+		//region Get Limited Geocodings With Specified Zipcode And House Number
185
+		$resultZipHouseLimited = Geocoding::getService([
186
+			'zipcode'       => '00601',
187
+			'housenumber'   => 17,
188
+			'offset'        => 0,
189
+			'limit'         => 10,
190
+		]);
191 191
 
192
-        $this->assertNotNull($resultZipHouseLimited);
193
-        $this->assertTrue(sizeof($resultZipHouseLimited)>0);
192
+		$this->assertNotNull($resultZipHouseLimited);
193
+		$this->assertTrue(sizeof($resultZipHouseLimited)>0);
194 194
 
195
-        $firstGeocoding = RapidAddressSearchResponse::fromArray(
196
-            $resultZipHouseLimited[0]
197
-        );
195
+		$firstGeocoding = RapidAddressSearchResponse::fromArray(
196
+			$resultZipHouseLimited[0]
197
+		);
198 198
 
199
-        $this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
200
-        //endregion
201
-    }
202
-
203
-    public static function tearDownAfterClass()
204
-    {
199
+		$this->assertContainsOnlyInstancesOf(RapidAddressSearchResponse::class, [$firstGeocoding]);
200
+		//endregion
201
+	}
202
+
203
+	public static function tearDownAfterClass()
204
+	{
205 205
 
206
-    }
206
+	}
207 207
 }
208 208
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $this->markTestSkipped('must be revisited.');
74 74
 
75
-        if (Constants::API_KEY == Constants::DEMO_API_KEY) {
76
-            $className = str_replace('UnitTestFiles\\Test\\','',get_class());
77
-            self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
75
+        if (Constants::API_KEY==Constants::DEMO_API_KEY) {
76
+            $className = str_replace('UnitTestFiles\\Test\\', '', get_class());
77
+            self::markTestSkipped('PHPUnit will skip '.$className." class - it impossible run with demo API key");
78 78
         }
79 79
 
80 80
         //region Get Single Street Address
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $this->markTestSkipped('must be revisited.');
122 122
 
123
-        if (Constants::API_KEY == Constants::DEMO_API_KEY) {
124
-            $className = str_replace('UnitTestFiles\\Test\\','',get_class());
125
-            self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
123
+        if (Constants::API_KEY==Constants::DEMO_API_KEY) {
124
+            $className = str_replace('UnitTestFiles\\Test\\', '', get_class());
125
+            self::markTestSkipped('PHPUnit will skip '.$className." class - it impossible run with demo API key");
126 126
         }
127 127
 
128 128
         //region Get All Geocodings With Specified Zipcode
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
     {
161 161
         $this->markTestSkipped('must be revisited.');
162 162
 
163
-        if (Constants::API_KEY == Constants::DEMO_API_KEY) {
164
-            $className = str_replace('UnitTestFiles\\Test\\','',get_class());
165
-            self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
163
+        if (Constants::API_KEY==Constants::DEMO_API_KEY) {
164
+            $className = str_replace('UnitTestFiles\\Test\\', '', get_class());
165
+            self::markTestSkipped('PHPUnit will skip '.$className." class - it impossible run with demo API key");
166 166
         }
167 167
 
168 168
         //region Get All Geocodings With Specified Zipcode And House Number
Please login to merge, or discard this patch.
UnitTestFiles/Test/AddressBookLocationUnitTests.php 3 patches
Indentation   +434 added lines, -434 removed lines patch added patch discarded remove patch
@@ -9,450 +9,450 @@
 block discarded – undo
9 9
 
10 10
 class AddressBookLocationUnitTests extends \PHPUnit\Framework\TestCase
11 11
 {
12
-    public static $createdContacts=[];
13
-
14
-    public static $csvImportedAddressIDs=[];
15
-
16
-    public static function setUpBeforeClass()
17
-    {
18
-        Route4Me::setApiKey(Constants::API_KEY);
19
-
20
-        $abl = new AddressBookLocation();
21
-
22
-        $AddressBookLocationParameters = AddressBookLocation::fromArray([
23
-            'address_1'             => '1407 MCCOY, Louisville, KY, 40215',
24
-            'address_alias'         => '1407 MCCOY 40215',
25
-            'address_group'         => 'Scheduled weekly',
26
-            'first_name'            => 'Bart',
27
-            'last_name'             => 'Douglas',
28
-            'address_email'         => '[email protected]',
29
-            'address_phone_number'  => '95487454',
30
-            'cached_lat'            => 38.202496,
31
-            'cached_lng'            => -85.786514,
32
-            'curbside_lat'          => 38.202496,
33
-            'curbside_lng'          => -85.786514,
34
-            'address_city'          => 'Louisville',
35
-            'schedule' => [[
36
-                'enabled'   => true,
37
-                'mode'      => 'weekly',
38
-                'weekly'    => [
39
-                    'every'    => 1,
40
-                    'weekdays' => [1, 2, 3, 4, 5],
41
-                ],
42
-            ]],
43
-            'service_time' => 600,
44
-        ]);
45
-
46
-        self::$createdContacts[] = AddressBookLocation::fromArray(
47
-            $abl->addAdressBookLocation($AddressBookLocationParameters)
48
-         );
49
-
50
-        $AddressBookLocationParameters = AddressBookLocation::fromArray([
51
-            'address_1'             => '4805 BELLEVUE AVE, Louisville, KY, 40215',
52
-            'address_2'             => '4806 BELLEVUE AVE, Louisville, KY, 40215',
53
-            'address_alias'         => '4805 BELLEVUE AVE 40215',
54
-            'address_group'         => 'Scheduled monthly',
55
-            'first_name'            => 'Bart',
56
-            'last_name'             => 'Douglas',
57
-            'address_email'         => '[email protected]',
58
-            'address_phone_number'  => '95487454',
59
-            'cached_lat'            => 38.178844,
60
-            'cached_lng'            => -85.774864,
61
-            'curbside_lat'          => 38.178844,
62
-            'curbside_lng'          => -85.774864,
63
-            'address_city'          => 'Louisville',
64
-            'address_country_id'    => 'US',
65
-            'address_state_id'      => 'KY',
66
-            'address_zip'           => '40215',
67
-            'schedule' => [[
68
-                'enabled'   => true,
69
-                'mode'      => 'monthly',
70
-                'monthly'   => [
71
-                    'every' => 1,
72
-                    'mode'  => 'dates',
73
-                    'dates' => [20, 22, 23, 24, 25],
74
-                ],
75
-            ]],
76
-            'service_time' => 750,
77
-            'color'        => 'red',
78
-        ]);
79
-
80
-        self::$createdContacts[] = AddressBookLocation::fromArray(
81
-            $abl->addAdressBookLocation($AddressBookLocationParameters)
82
-        );
83
-    }
84
-
85
-    public function testAddressBookLocationFromArray()
86
-    {
87
-        $location = AddressBookLocation::fromArray([
88
-            'address_1'             => '1604 PARKRIDGE PKWY, Louisville, KY, 40214',
89
-            'cached_lat'            => 38.141598,
90
-            'cached_lng'            => -85.793846,
91
-            'address_alias'         => '1604 PARKRIDGE PKWY 40214',
92
-            'address_group'         => 'Scheduled daily',
93
-            'first_name'            => 'Peter',
94
-            'last_name'             => 'Newman',
95
-            'address_email'         => '[email protected]',
96
-            'address_phone_number'  => '65432178',
97
-            'address_city'          => 'Louisville',
98
-            'address_custom_data'   => ['scheduled'     => 'yes',
99
-                                        'serice type'   => 'publishing', ],
100
-            'schedule' => [[
101
-                'enabled'   => true,
102
-                'mode'      => 'daily',
103
-                'daily'     => ['every' => 1],
104
-            ]],
105
-            'service_time'          => 900,
106
-        ]);
107
-
108
-        $this->assertEquals('1604 PARKRIDGE PKWY, Louisville, KY, 40214', $location->address_1);
109
-        $this->assertEquals(38.141598, $location->cached_lat);
110
-        $this->assertEquals(-85.793846, $location->cached_lng);
111
-        $this->assertEquals('1604 PARKRIDGE PKWY 40214', $location->address_alias);
112
-
113
-        $this->assertEquals('Peter', $location->first_name);
114
-        $this->assertEquals('Newman', $location->last_name);
115
-        $this->assertEquals('[email protected]', $location->address_email);
116
-        $this->assertEquals('65432178', $location->address_phone_number);
117
-        $this->assertEquals('Louisville', $location->address_city);
118
-    }
119
-
120
-    public function testToArray()
121
-    {
122
-        $location = AddressBookLocation::fromArray([
123
-            'address_1'             => '1604 PARKRIDGE PKWY, Louisville, KY, 40214',
124
-            'cached_lat'            => 38.141598,
125
-            'cached_lng'            => -85.793846,
126
-            'address_alias'         => '1604 PARKRIDGE PKWY 40214',
127
-            'address_group'         => 'Scheduled daily',
128
-            'first_name'            => 'Peter',
129
-            'last_name'             => 'Newman',
130
-            'address_email'         => '[email protected]',
131
-            'address_phone_number'  => '65432178',
132
-            'address_city'          => 'Louisville',
133
-            'address_custom_data'   => ['scheduled'     => 'yes',
134
-                'serice type'   => 'publishing', ],
135
-            'schedule' => [[
136
-                'enabled'   => true,
137
-                'mode'      => 'daily',
138
-                'daily'     => ['every' => 1],
139
-            ]],
140
-            'service_time'          => 900,
141
-        ]);
142
-
143
-        $this->assertEquals($location->toArray(),
144
-            [
145
-                'address_1'             => '1604 PARKRIDGE PKWY, Louisville, KY, 40214',
146
-                'cached_lat'            => 38.141598,
147
-                'cached_lng'            => -85.793846,
148
-                'address_alias'         => '1604 PARKRIDGE PKWY 40214',
149
-                'address_group'         => 'Scheduled daily',
150
-                'first_name'            => 'Peter',
151
-                'last_name'             => 'Newman',
152
-                'address_email'         => '[email protected]',
153
-                'address_phone_number'  => '65432178',
154
-                'address_city'          => 'Louisville',
155
-                'address_custom_data'   => ['scheduled'     => 'yes',
156
-                    'serice type'   => 'publishing', ],
157
-                'schedule' => [[
158
-                    'enabled'   => true,
159
-                    'mode'      => 'daily',
160
-                    'daily'     => ['every' => 1],
161
-                ]],
162
-                'service_time'          => 900,
163
-            ]
164
-        );
165
-    }
166
-
167
-    public function testGetAddressBookLocation()
168
-    {
169
-        $abl = new AddressBookLocation();
170
-
171
-        $addressID = self::$createdContacts[0]->address_id;
172
-
173
-        $result = AddressBookLocation::fromArray(
174
-            $abl->getAddressBookLocation($addressID)
175
-        );
176
-
177
-        $this->assertNotNull($addressID);
178
-        $this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$result]);
179
-
180
-    }
181
-
182
-    public function testSearchAddressBookLocations()
183
-    {
184
-        $abl = new AddressBookLocation();
185
-
186
-        $params = [
187
-            'query'  => 'Douglas',
188
-            'fields' => 'first_name,address_email,schedule_blacklist,schedule,address_custom_data,address_1',
189
-            'offset' => 0,
190
-            'limit'  => 5,
191
-        ];
12
+	public static $createdContacts=[];
13
+
14
+	public static $csvImportedAddressIDs=[];
15
+
16
+	public static function setUpBeforeClass()
17
+	{
18
+		Route4Me::setApiKey(Constants::API_KEY);
19
+
20
+		$abl = new AddressBookLocation();
21
+
22
+		$AddressBookLocationParameters = AddressBookLocation::fromArray([
23
+			'address_1'             => '1407 MCCOY, Louisville, KY, 40215',
24
+			'address_alias'         => '1407 MCCOY 40215',
25
+			'address_group'         => 'Scheduled weekly',
26
+			'first_name'            => 'Bart',
27
+			'last_name'             => 'Douglas',
28
+			'address_email'         => '[email protected]',
29
+			'address_phone_number'  => '95487454',
30
+			'cached_lat'            => 38.202496,
31
+			'cached_lng'            => -85.786514,
32
+			'curbside_lat'          => 38.202496,
33
+			'curbside_lng'          => -85.786514,
34
+			'address_city'          => 'Louisville',
35
+			'schedule' => [[
36
+				'enabled'   => true,
37
+				'mode'      => 'weekly',
38
+				'weekly'    => [
39
+					'every'    => 1,
40
+					'weekdays' => [1, 2, 3, 4, 5],
41
+				],
42
+			]],
43
+			'service_time' => 600,
44
+		]);
45
+
46
+		self::$createdContacts[] = AddressBookLocation::fromArray(
47
+			$abl->addAdressBookLocation($AddressBookLocationParameters)
48
+		 );
49
+
50
+		$AddressBookLocationParameters = AddressBookLocation::fromArray([
51
+			'address_1'             => '4805 BELLEVUE AVE, Louisville, KY, 40215',
52
+			'address_2'             => '4806 BELLEVUE AVE, Louisville, KY, 40215',
53
+			'address_alias'         => '4805 BELLEVUE AVE 40215',
54
+			'address_group'         => 'Scheduled monthly',
55
+			'first_name'            => 'Bart',
56
+			'last_name'             => 'Douglas',
57
+			'address_email'         => '[email protected]',
58
+			'address_phone_number'  => '95487454',
59
+			'cached_lat'            => 38.178844,
60
+			'cached_lng'            => -85.774864,
61
+			'curbside_lat'          => 38.178844,
62
+			'curbside_lng'          => -85.774864,
63
+			'address_city'          => 'Louisville',
64
+			'address_country_id'    => 'US',
65
+			'address_state_id'      => 'KY',
66
+			'address_zip'           => '40215',
67
+			'schedule' => [[
68
+				'enabled'   => true,
69
+				'mode'      => 'monthly',
70
+				'monthly'   => [
71
+					'every' => 1,
72
+					'mode'  => 'dates',
73
+					'dates' => [20, 22, 23, 24, 25],
74
+				],
75
+			]],
76
+			'service_time' => 750,
77
+			'color'        => 'red',
78
+		]);
79
+
80
+		self::$createdContacts[] = AddressBookLocation::fromArray(
81
+			$abl->addAdressBookLocation($AddressBookLocationParameters)
82
+		);
83
+	}
84
+
85
+	public function testAddressBookLocationFromArray()
86
+	{
87
+		$location = AddressBookLocation::fromArray([
88
+			'address_1'             => '1604 PARKRIDGE PKWY, Louisville, KY, 40214',
89
+			'cached_lat'            => 38.141598,
90
+			'cached_lng'            => -85.793846,
91
+			'address_alias'         => '1604 PARKRIDGE PKWY 40214',
92
+			'address_group'         => 'Scheduled daily',
93
+			'first_name'            => 'Peter',
94
+			'last_name'             => 'Newman',
95
+			'address_email'         => '[email protected]',
96
+			'address_phone_number'  => '65432178',
97
+			'address_city'          => 'Louisville',
98
+			'address_custom_data'   => ['scheduled'     => 'yes',
99
+										'serice type'   => 'publishing', ],
100
+			'schedule' => [[
101
+				'enabled'   => true,
102
+				'mode'      => 'daily',
103
+				'daily'     => ['every' => 1],
104
+			]],
105
+			'service_time'          => 900,
106
+		]);
107
+
108
+		$this->assertEquals('1604 PARKRIDGE PKWY, Louisville, KY, 40214', $location->address_1);
109
+		$this->assertEquals(38.141598, $location->cached_lat);
110
+		$this->assertEquals(-85.793846, $location->cached_lng);
111
+		$this->assertEquals('1604 PARKRIDGE PKWY 40214', $location->address_alias);
112
+
113
+		$this->assertEquals('Peter', $location->first_name);
114
+		$this->assertEquals('Newman', $location->last_name);
115
+		$this->assertEquals('[email protected]', $location->address_email);
116
+		$this->assertEquals('65432178', $location->address_phone_number);
117
+		$this->assertEquals('Louisville', $location->address_city);
118
+	}
119
+
120
+	public function testToArray()
121
+	{
122
+		$location = AddressBookLocation::fromArray([
123
+			'address_1'             => '1604 PARKRIDGE PKWY, Louisville, KY, 40214',
124
+			'cached_lat'            => 38.141598,
125
+			'cached_lng'            => -85.793846,
126
+			'address_alias'         => '1604 PARKRIDGE PKWY 40214',
127
+			'address_group'         => 'Scheduled daily',
128
+			'first_name'            => 'Peter',
129
+			'last_name'             => 'Newman',
130
+			'address_email'         => '[email protected]',
131
+			'address_phone_number'  => '65432178',
132
+			'address_city'          => 'Louisville',
133
+			'address_custom_data'   => ['scheduled'     => 'yes',
134
+				'serice type'   => 'publishing', ],
135
+			'schedule' => [[
136
+				'enabled'   => true,
137
+				'mode'      => 'daily',
138
+				'daily'     => ['every' => 1],
139
+			]],
140
+			'service_time'          => 900,
141
+		]);
142
+
143
+		$this->assertEquals($location->toArray(),
144
+			[
145
+				'address_1'             => '1604 PARKRIDGE PKWY, Louisville, KY, 40214',
146
+				'cached_lat'            => 38.141598,
147
+				'cached_lng'            => -85.793846,
148
+				'address_alias'         => '1604 PARKRIDGE PKWY 40214',
149
+				'address_group'         => 'Scheduled daily',
150
+				'first_name'            => 'Peter',
151
+				'last_name'             => 'Newman',
152
+				'address_email'         => '[email protected]',
153
+				'address_phone_number'  => '65432178',
154
+				'address_city'          => 'Louisville',
155
+				'address_custom_data'   => ['scheduled'     => 'yes',
156
+					'serice type'   => 'publishing', ],
157
+				'schedule' => [[
158
+					'enabled'   => true,
159
+					'mode'      => 'daily',
160
+					'daily'     => ['every' => 1],
161
+				]],
162
+				'service_time'          => 900,
163
+			]
164
+		);
165
+	}
166
+
167
+	public function testGetAddressBookLocation()
168
+	{
169
+		$abl = new AddressBookLocation();
170
+
171
+		$addressID = self::$createdContacts[0]->address_id;
172
+
173
+		$result = AddressBookLocation::fromArray(
174
+			$abl->getAddressBookLocation($addressID)
175
+		);
176
+
177
+		$this->assertNotNull($addressID);
178
+		$this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$result]);
179
+
180
+	}
181
+
182
+	public function testSearchAddressBookLocations()
183
+	{
184
+		$abl = new AddressBookLocation();
185
+
186
+		$params = [
187
+			'query'  => 'Douglas',
188
+			'fields' => 'first_name,address_email,schedule_blacklist,schedule,address_custom_data,address_1',
189
+			'offset' => 0,
190
+			'limit'  => 5,
191
+		];
192 192
                                                                                                                                 
193
-        $result =  SearchResponse::fromArray(
194
-            $abl->searchAddressBookLocations($params)
195
-        );
193
+		$result =  SearchResponse::fromArray(
194
+			$abl->searchAddressBookLocations($params)
195
+		);
196 196
 
197
-        $this->assertNotNull($result);
198
-        $this->assertTrue(sizeof($result->fields)==6);
199
-        $this->assertContains('first_name',$result->fields);
200
-        $this->assertContains('address_email',$result->fields);
197
+		$this->assertNotNull($result);
198
+		$this->assertTrue(sizeof($result->fields)==6);
199
+		$this->assertContains('first_name',$result->fields);
200
+		$this->assertContains('address_email',$result->fields);
201 201
 
202
-        $this->assertNotNull($result->results);
202
+		$this->assertNotNull($result->results);
203 203
 
204
-        $txt = json_encode($result->results[0]);
204
+		$txt = json_encode($result->results[0]);
205 205
 
206
-        $firstRecord = strtolower($txt);
206
+		$firstRecord = strtolower($txt);
207 207
         
208
-        $this->assertTrue(strpos($firstRecord, 'douglas')>=0);
209
-    }
208
+		$this->assertTrue(strpos($firstRecord, 'douglas')>=0);
209
+	}
210 210
 
211
-    public function testGetAddressBookLocations()
212
-    {
213
-        $abl = new AddressBookLocation();
211
+	public function testGetAddressBookLocations()
212
+	{
213
+		$abl = new AddressBookLocation();
214 214
 
215
-        $AddressBookLocationParameters = [
216
-            'limit'  => 5,
217
-            'offset' => 0,
218
-        ];
215
+		$AddressBookLocationParameters = [
216
+			'limit'  => 5,
217
+			'offset' => 0,
218
+		];
219 219
 
220
-        $result = SearchResponse::fromArray(
221
-            $abl->getAddressBookLocations($AddressBookLocationParameters)
222
-        );
220
+		$result = SearchResponse::fromArray(
221
+			$abl->getAddressBookLocations($AddressBookLocationParameters)
222
+		);
223 223
 
224
-        $firstLocation = AddressBookLocation::fromArray(
225
-            $result->results[0]
226
-        );
224
+		$firstLocation = AddressBookLocation::fromArray(
225
+			$result->results[0]
226
+		);
227 227
 
228
-        $this->assertNotNull($result);
229
-        $this->assertNotNull($result->results);
230
-        $this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$firstLocation]);
231
-    }
228
+		$this->assertNotNull($result);
229
+		$this->assertNotNull($result->results);
230
+		$this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$firstLocation]);
231
+	}
232 232
 
233
-    public function testGetRandomAddressBookLocation()
234
-    {
235
-        $AddressBookLocationParameters = [
236
-            'limit'  => 30,
237
-            'offset' => 0,
238
-        ];
239
-
240
-        $result = AddressBookLocation::fromArray(
241
-            AddressBookLocation::getRandomAddressBookLocation($AddressBookLocationParameters)
242
-        );
243
-
244
-        $this->assertNotNull($result);
245
-        $this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$result]);
246
-    }
247
-
248
-    public function testAddAdressBookLocation()
249
-    {
250
-        $abl = new AddressBookLocation();
251
-
252
-        $AddressBookLocationParameters = AddressBookLocation::fromArray([
253
-            'first_name'    => 'Test FirstName '.strval(rand(10000, 99999)),
254
-            'address_1'     => 'Test Address1 '.strval(rand(10000, 99999)),
255
-            'cached_lat'    => 38.024654,
256
-            'cached_lng'    => -77.338814,
257
-        ]);
258
-
259
-        $result = AddressBookLocation::fromArray(
260
-            $abl->addAdressBookLocation($AddressBookLocationParameters)
261
-        );
262
-
263
-        $this->assertNotNull($result);
264
-        $this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$result]);
265
-
266
-        self::$createdContacts[] = $result;
267
-    }
268
-
269
-    public function testDeleteAdressBookLocation()
270
-    {
271
-        $abl = new AddressBookLocation();
272
-
273
-        $lastContact = end(self::$createdContacts);
274
-
275
-        $deleteResult = $abl->deleteAdressBookLocation([$lastContact->address_id]);
276
-
277
-        $this->assertTrue(isset($deleteResult['status']), 'Address Book Location delete operation failed!.. <br>');
278
-        $this->assertTrue($deleteResult['status'], 'Address Book Location delete operation failed!.. <br>');
279
-
280
-        self::$createdContacts[] = array_pop(self::$createdContacts);
281
-    }
282
-
283
-    public function testUpdateAddressBookLocation()
284
-    {
285
-        $abl = new AddressBookLocation();
286
-
287
-        reset(self::$createdContacts);
288
-
289
-        $firstContact = self::$createdContacts[0];
290
-
291
-        $firstContact->first_name = $firstContact->first_name.' updated';
292
-
293
-        $result = AddressBookLocation::fromArray(
294
-            $abl->updateAddressBookLocation($firstContact)
295
-        );
296
-
297
-        $this->assertNotNull($result);
298
-        $this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$result]);
299
-        $this->assertEquals($firstContact->first_name, $result->first_name);
300
-    }
301
-
302
-    public function testValidateScheduleMode()
303
-    {
304
-        $this->assertTrue(AddressBookLocation::validateScheduleMode('daily'));
305
-        $this->assertTrue(AddressBookLocation::validateScheduleMode('weekly'));
306
-        $this->assertTrue(AddressBookLocation::validateScheduleMode('monthly'));
307
-        $this->assertTrue(AddressBookLocation::validateScheduleMode('annually'));
308
-
309
-        $this->assertFalse(AddressBookLocation::validateScheduleMode('wrongMode'));
310
-    }
311
-
312
-    public function testValidateScheduleEnable()
313
-    {
314
-        $this->assertTrue(AddressBookLocation::validateScheduleEnable(true));
315
-        $this->assertTrue(AddressBookLocation::validateScheduleEnable(false));
316
-
317
-        $this->assertFalse(AddressBookLocation::validateScheduleEnable('wrongValue'));
318
-        $this->assertFalse(AddressBookLocation::validateScheduleEnable(null));
319
-    }
320
-
321
-    public function testValidateScheduleEvery()
322
-    {
323
-        $this->assertTrue(AddressBookLocation::validateScheduleEvery(1));
324
-        $this->assertTrue(AddressBookLocation::validateScheduleEvery(8));
325
-
326
-        $this->assertFalse(AddressBookLocation::validateScheduleEvery(0));
327
-        $this->assertFalse(AddressBookLocation::validateScheduleEvery(-1));
328
-        $this->assertFalse(AddressBookLocation::validateScheduleEvery('stringValue'));
329
-        $this->assertFalse(AddressBookLocation::validateScheduleEvery(true));
330
-        $this->assertFalse(AddressBookLocation::validateScheduleEvery(null));
331
-    }
332
-
333
-    public function testValidateScheduleWeekDays()
334
-    {
335
-        $this->assertTrue(AddressBookLocation::validateScheduleWeekDays('1,2,3,4,5,6,7'));
336
-
337
-        $this->assertFalse(AddressBookLocation::validateScheduleWeekDays('1,2,3,4,5,6,7,8'));
338
-        $this->assertFalse(AddressBookLocation::validateScheduleWeekDays('1,-2,3,4,5,6,7'));
339
-        $this->assertFalse(AddressBookLocation::validateScheduleWeekDays(true));
340
-        $this->assertTrue(AddressBookLocation::validateScheduleWeekDays(4));
341
-        $this->assertFalse(AddressBookLocation::validateScheduleWeekDays('dds'));
342
-    }
343
-
344
-    public function testValidateScheduleMonthlyMode()
345
-    {
346
-        $this->assertTrue(AddressBookLocation::validateScheduleMonthlyMode('dates'));
347
-        $this->assertTrue(AddressBookLocation::validateScheduleMonthlyMode('nth' ));
348
-
349
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode('wrongParam' ));
350
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode(4 ));
351
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode(true ));
352
-    }
353
-
354
-    public function testValidateScheduleMonthlyDates()
355
-    {
356
-        $this->assertTrue(AddressBookLocation::validateScheduleMonthlyDates('1,2,3,7,31'));
357
-        $this->assertTrue(AddressBookLocation::validateScheduleMonthlyDates('12,21,23,24,28'));
358
-
359
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates('0,2,3,7,31'));
360
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates('0,2,3,7,33'));
361
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates('-1,2,3,7'));
362
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates('wrongText'));
363
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates(true));
364
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates(false));
365
-    }
366
-
367
-    public function testValidateScheduleNthN()
368
-    {
369
-        $this->assertTrue(AddressBookLocation::validateScheduleNthN(1));
370
-        $this->assertTrue(AddressBookLocation::validateScheduleNthN(2));
371
-        $this->assertTrue(AddressBookLocation::validateScheduleNthN(3));
372
-        $this->assertTrue(AddressBookLocation::validateScheduleNthN(4));
373
-        $this->assertTrue(AddressBookLocation::validateScheduleNthN(5));
374
-        $this->assertTrue(AddressBookLocation::validateScheduleNthN(-1));
375
-
376
-        $this->assertFalse(AddressBookLocation::validateScheduleNthN(-5));
377
-        $this->assertFalse(AddressBookLocation::validateScheduleNthN(0));
378
-        $this->assertFalse(AddressBookLocation::validateScheduleNthN(7));
379
-        $this->assertFalse(AddressBookLocation::validateScheduleNthN(true));
380
-        $this->assertFalse(AddressBookLocation::validateScheduleNthN(false));
381
-        $this->assertFalse(AddressBookLocation::validateScheduleNthN('wrongText'));
382
-    }
383
-
384
-    public function testValidateScheduleNthWhat()
385
-    {
386
-        for ($i=1;$i<11;$i++) $this->assertTrue(AddressBookLocation::validateScheduleNthWhat($i));
387
-
388
-        $this->assertFalse(AddressBookLocation::validateScheduleNthWhat(0));
389
-        $this->assertFalse(AddressBookLocation::validateScheduleNthWhat(14));
390
-        $this->assertFalse(AddressBookLocation::validateScheduleNthWhat(true));
391
-        $this->assertFalse(AddressBookLocation::validateScheduleNthWhat(false));
392
-        $this->assertFalse(AddressBookLocation::validateScheduleNthWhat('wrongText'));
393
-    }
394
-
395
-    public function testAddLocationsFromCsvFile()
396
-    {
397
-        $root = realpath(dirname(__FILE__).'/../../');
398
-        $source_file = $root.'/UnitTestFiles/Test/data/addresses_10.csv';
399
-
400
-        $locationsFieldsMapping['cached_lat'] = 0;
401
-        $locationsFieldsMapping['cached_lng'] = 1;
402
-        $locationsFieldsMapping['address_alias'] = 2;
403
-        $locationsFieldsMapping['address_1'] = 3;
404
-        $locationsFieldsMapping['address_city'] = 4;
405
-        $locationsFieldsMapping['address_state_id'] = 5;
406
-        $locationsFieldsMapping['address_zip'] = 6;
407
-        $locationsFieldsMapping['address_phone_number'] = 7;
408
-        $locationsFieldsMapping['schedule_mode'] = 8;
409
-        $locationsFieldsMapping['schedule_enabled'] = 9;
410
-        $locationsFieldsMapping['schedule_every'] = 10;
411
-        $locationsFieldsMapping['schedule_weekdays'] = 11;
412
-        $locationsFieldsMapping['monthly_mode'] = 12;
413
-        $locationsFieldsMapping['monthly_dates'] = 13;
414
-        $locationsFieldsMapping['monthly_nth_n'] = 14;
415
-        $locationsFieldsMapping['monthly_nth_what'] = 15;
416
-        $locationsFieldsMapping['anually_nth_n'] = 16;
417
-        $locationsFieldsMapping['anually_nth_what'] = 17;
418
-
419
-        $handle = fopen("$source_file", 'r');
420
-
421
-        $this->assertNotNull($handle);
422
-
423
-        $abl = new AddressBookLocation();
424
-
425
-        $results = $abl->addLocationsFromCsvFile($handle, $locationsFieldsMapping);
426
-
427
-        $this->assertNotNull($results);
428
-
429
-        $this->assertTrue(isset($results['success']));
430
-
431
-        $this->assertTrue(isset($results['fail']));
432
-
433
-        foreach ($results['success'] as $sc) {
434
-            self::$csvImportedAddressIDs[] = filter_var($sc, FILTER_SANITIZE_NUMBER_INT);
435
-        }
436
-
437
-        $this->assertTrue(sizeof(self::$csvImportedAddressIDs)==10);
438
-    }
439
-
440
-    public static function tearDownAfterClass()
441
-    {
442
-        $addressBookLocations=[];
443
-
444
-        foreach (self::$createdContacts as $createdContact) {
445
-            $addressBookLocations[] = $createdContact->address_id;
446
-        }
447
-
448
-        $addressBookLocations = array_merge($addressBookLocations,self::$csvImportedAddressIDs);
449
-
450
-        $abl = new AddressBookLocation();
451
-
452
-        $deleteResult = $abl->deleteAdressBookLocation($addressBookLocations);
453
-
454
-        if (isset($deleteResult['status']) && $deleteResult['status']) {
455
-            echo "Created contacts were removed.<br>";
456
-        }
457
-    }
233
+	public function testGetRandomAddressBookLocation()
234
+	{
235
+		$AddressBookLocationParameters = [
236
+			'limit'  => 30,
237
+			'offset' => 0,
238
+		];
239
+
240
+		$result = AddressBookLocation::fromArray(
241
+			AddressBookLocation::getRandomAddressBookLocation($AddressBookLocationParameters)
242
+		);
243
+
244
+		$this->assertNotNull($result);
245
+		$this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$result]);
246
+	}
247
+
248
+	public function testAddAdressBookLocation()
249
+	{
250
+		$abl = new AddressBookLocation();
251
+
252
+		$AddressBookLocationParameters = AddressBookLocation::fromArray([
253
+			'first_name'    => 'Test FirstName '.strval(rand(10000, 99999)),
254
+			'address_1'     => 'Test Address1 '.strval(rand(10000, 99999)),
255
+			'cached_lat'    => 38.024654,
256
+			'cached_lng'    => -77.338814,
257
+		]);
258
+
259
+		$result = AddressBookLocation::fromArray(
260
+			$abl->addAdressBookLocation($AddressBookLocationParameters)
261
+		);
262
+
263
+		$this->assertNotNull($result);
264
+		$this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$result]);
265
+
266
+		self::$createdContacts[] = $result;
267
+	}
268
+
269
+	public function testDeleteAdressBookLocation()
270
+	{
271
+		$abl = new AddressBookLocation();
272
+
273
+		$lastContact = end(self::$createdContacts);
274
+
275
+		$deleteResult = $abl->deleteAdressBookLocation([$lastContact->address_id]);
276
+
277
+		$this->assertTrue(isset($deleteResult['status']), 'Address Book Location delete operation failed!.. <br>');
278
+		$this->assertTrue($deleteResult['status'], 'Address Book Location delete operation failed!.. <br>');
279
+
280
+		self::$createdContacts[] = array_pop(self::$createdContacts);
281
+	}
282
+
283
+	public function testUpdateAddressBookLocation()
284
+	{
285
+		$abl = new AddressBookLocation();
286
+
287
+		reset(self::$createdContacts);
288
+
289
+		$firstContact = self::$createdContacts[0];
290
+
291
+		$firstContact->first_name = $firstContact->first_name.' updated';
292
+
293
+		$result = AddressBookLocation::fromArray(
294
+			$abl->updateAddressBookLocation($firstContact)
295
+		);
296
+
297
+		$this->assertNotNull($result);
298
+		$this->assertContainsOnlyInstancesOf(AddressBookLocation::class, [$result]);
299
+		$this->assertEquals($firstContact->first_name, $result->first_name);
300
+	}
301
+
302
+	public function testValidateScheduleMode()
303
+	{
304
+		$this->assertTrue(AddressBookLocation::validateScheduleMode('daily'));
305
+		$this->assertTrue(AddressBookLocation::validateScheduleMode('weekly'));
306
+		$this->assertTrue(AddressBookLocation::validateScheduleMode('monthly'));
307
+		$this->assertTrue(AddressBookLocation::validateScheduleMode('annually'));
308
+
309
+		$this->assertFalse(AddressBookLocation::validateScheduleMode('wrongMode'));
310
+	}
311
+
312
+	public function testValidateScheduleEnable()
313
+	{
314
+		$this->assertTrue(AddressBookLocation::validateScheduleEnable(true));
315
+		$this->assertTrue(AddressBookLocation::validateScheduleEnable(false));
316
+
317
+		$this->assertFalse(AddressBookLocation::validateScheduleEnable('wrongValue'));
318
+		$this->assertFalse(AddressBookLocation::validateScheduleEnable(null));
319
+	}
320
+
321
+	public function testValidateScheduleEvery()
322
+	{
323
+		$this->assertTrue(AddressBookLocation::validateScheduleEvery(1));
324
+		$this->assertTrue(AddressBookLocation::validateScheduleEvery(8));
325
+
326
+		$this->assertFalse(AddressBookLocation::validateScheduleEvery(0));
327
+		$this->assertFalse(AddressBookLocation::validateScheduleEvery(-1));
328
+		$this->assertFalse(AddressBookLocation::validateScheduleEvery('stringValue'));
329
+		$this->assertFalse(AddressBookLocation::validateScheduleEvery(true));
330
+		$this->assertFalse(AddressBookLocation::validateScheduleEvery(null));
331
+	}
332
+
333
+	public function testValidateScheduleWeekDays()
334
+	{
335
+		$this->assertTrue(AddressBookLocation::validateScheduleWeekDays('1,2,3,4,5,6,7'));
336
+
337
+		$this->assertFalse(AddressBookLocation::validateScheduleWeekDays('1,2,3,4,5,6,7,8'));
338
+		$this->assertFalse(AddressBookLocation::validateScheduleWeekDays('1,-2,3,4,5,6,7'));
339
+		$this->assertFalse(AddressBookLocation::validateScheduleWeekDays(true));
340
+		$this->assertTrue(AddressBookLocation::validateScheduleWeekDays(4));
341
+		$this->assertFalse(AddressBookLocation::validateScheduleWeekDays('dds'));
342
+	}
343
+
344
+	public function testValidateScheduleMonthlyMode()
345
+	{
346
+		$this->assertTrue(AddressBookLocation::validateScheduleMonthlyMode('dates'));
347
+		$this->assertTrue(AddressBookLocation::validateScheduleMonthlyMode('nth' ));
348
+
349
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode('wrongParam' ));
350
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode(4 ));
351
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode(true ));
352
+	}
353
+
354
+	public function testValidateScheduleMonthlyDates()
355
+	{
356
+		$this->assertTrue(AddressBookLocation::validateScheduleMonthlyDates('1,2,3,7,31'));
357
+		$this->assertTrue(AddressBookLocation::validateScheduleMonthlyDates('12,21,23,24,28'));
358
+
359
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates('0,2,3,7,31'));
360
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates('0,2,3,7,33'));
361
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates('-1,2,3,7'));
362
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates('wrongText'));
363
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates(true));
364
+		$this->assertFalse(AddressBookLocation::validateScheduleMonthlyDates(false));
365
+	}
366
+
367
+	public function testValidateScheduleNthN()
368
+	{
369
+		$this->assertTrue(AddressBookLocation::validateScheduleNthN(1));
370
+		$this->assertTrue(AddressBookLocation::validateScheduleNthN(2));
371
+		$this->assertTrue(AddressBookLocation::validateScheduleNthN(3));
372
+		$this->assertTrue(AddressBookLocation::validateScheduleNthN(4));
373
+		$this->assertTrue(AddressBookLocation::validateScheduleNthN(5));
374
+		$this->assertTrue(AddressBookLocation::validateScheduleNthN(-1));
375
+
376
+		$this->assertFalse(AddressBookLocation::validateScheduleNthN(-5));
377
+		$this->assertFalse(AddressBookLocation::validateScheduleNthN(0));
378
+		$this->assertFalse(AddressBookLocation::validateScheduleNthN(7));
379
+		$this->assertFalse(AddressBookLocation::validateScheduleNthN(true));
380
+		$this->assertFalse(AddressBookLocation::validateScheduleNthN(false));
381
+		$this->assertFalse(AddressBookLocation::validateScheduleNthN('wrongText'));
382
+	}
383
+
384
+	public function testValidateScheduleNthWhat()
385
+	{
386
+		for ($i=1;$i<11;$i++) $this->assertTrue(AddressBookLocation::validateScheduleNthWhat($i));
387
+
388
+		$this->assertFalse(AddressBookLocation::validateScheduleNthWhat(0));
389
+		$this->assertFalse(AddressBookLocation::validateScheduleNthWhat(14));
390
+		$this->assertFalse(AddressBookLocation::validateScheduleNthWhat(true));
391
+		$this->assertFalse(AddressBookLocation::validateScheduleNthWhat(false));
392
+		$this->assertFalse(AddressBookLocation::validateScheduleNthWhat('wrongText'));
393
+	}
394
+
395
+	public function testAddLocationsFromCsvFile()
396
+	{
397
+		$root = realpath(dirname(__FILE__).'/../../');
398
+		$source_file = $root.'/UnitTestFiles/Test/data/addresses_10.csv';
399
+
400
+		$locationsFieldsMapping['cached_lat'] = 0;
401
+		$locationsFieldsMapping['cached_lng'] = 1;
402
+		$locationsFieldsMapping['address_alias'] = 2;
403
+		$locationsFieldsMapping['address_1'] = 3;
404
+		$locationsFieldsMapping['address_city'] = 4;
405
+		$locationsFieldsMapping['address_state_id'] = 5;
406
+		$locationsFieldsMapping['address_zip'] = 6;
407
+		$locationsFieldsMapping['address_phone_number'] = 7;
408
+		$locationsFieldsMapping['schedule_mode'] = 8;
409
+		$locationsFieldsMapping['schedule_enabled'] = 9;
410
+		$locationsFieldsMapping['schedule_every'] = 10;
411
+		$locationsFieldsMapping['schedule_weekdays'] = 11;
412
+		$locationsFieldsMapping['monthly_mode'] = 12;
413
+		$locationsFieldsMapping['monthly_dates'] = 13;
414
+		$locationsFieldsMapping['monthly_nth_n'] = 14;
415
+		$locationsFieldsMapping['monthly_nth_what'] = 15;
416
+		$locationsFieldsMapping['anually_nth_n'] = 16;
417
+		$locationsFieldsMapping['anually_nth_what'] = 17;
418
+
419
+		$handle = fopen("$source_file", 'r');
420
+
421
+		$this->assertNotNull($handle);
422
+
423
+		$abl = new AddressBookLocation();
424
+
425
+		$results = $abl->addLocationsFromCsvFile($handle, $locationsFieldsMapping);
426
+
427
+		$this->assertNotNull($results);
428
+
429
+		$this->assertTrue(isset($results['success']));
430
+
431
+		$this->assertTrue(isset($results['fail']));
432
+
433
+		foreach ($results['success'] as $sc) {
434
+			self::$csvImportedAddressIDs[] = filter_var($sc, FILTER_SANITIZE_NUMBER_INT);
435
+		}
436
+
437
+		$this->assertTrue(sizeof(self::$csvImportedAddressIDs)==10);
438
+	}
439
+
440
+	public static function tearDownAfterClass()
441
+	{
442
+		$addressBookLocations=[];
443
+
444
+		foreach (self::$createdContacts as $createdContact) {
445
+			$addressBookLocations[] = $createdContact->address_id;
446
+		}
447
+
448
+		$addressBookLocations = array_merge($addressBookLocations,self::$csvImportedAddressIDs);
449
+
450
+		$abl = new AddressBookLocation();
451
+
452
+		$deleteResult = $abl->deleteAdressBookLocation($addressBookLocations);
453
+
454
+		if (isset($deleteResult['status']) && $deleteResult['status']) {
455
+			echo "Created contacts were removed.<br>";
456
+		}
457
+	}
458 458
 }
459 459
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
 
10 10
 class AddressBookLocationUnitTests extends \PHPUnit\Framework\TestCase
11 11
 {
12
-    public static $createdContacts=[];
12
+    public static $createdContacts = [];
13 13
 
14
-    public static $csvImportedAddressIDs=[];
14
+    public static $csvImportedAddressIDs = [];
15 15
 
16 16
     public static function setUpBeforeClass()
17 17
     {
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
             'limit'  => 5,
191 191
         ];
192 192
                                                                                                                                 
193
-        $result =  SearchResponse::fromArray(
193
+        $result = SearchResponse::fromArray(
194 194
             $abl->searchAddressBookLocations($params)
195 195
         );
196 196
 
197 197
         $this->assertNotNull($result);
198 198
         $this->assertTrue(sizeof($result->fields)==6);
199
-        $this->assertContains('first_name',$result->fields);
200
-        $this->assertContains('address_email',$result->fields);
199
+        $this->assertContains('first_name', $result->fields);
200
+        $this->assertContains('address_email', $result->fields);
201 201
 
202 202
         $this->assertNotNull($result->results);
203 203
 
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
     public function testValidateScheduleMonthlyMode()
345 345
     {
346 346
         $this->assertTrue(AddressBookLocation::validateScheduleMonthlyMode('dates'));
347
-        $this->assertTrue(AddressBookLocation::validateScheduleMonthlyMode('nth' ));
347
+        $this->assertTrue(AddressBookLocation::validateScheduleMonthlyMode('nth'));
348 348
 
349
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode('wrongParam' ));
350
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode(4 ));
351
-        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode(true ));
349
+        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode('wrongParam'));
350
+        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode(4));
351
+        $this->assertFalse(AddressBookLocation::validateScheduleMonthlyMode(true));
352 352
     }
353 353
 
354 354
     public function testValidateScheduleMonthlyDates()
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 
384 384
     public function testValidateScheduleNthWhat()
385 385
     {
386
-        for ($i=1;$i<11;$i++) $this->assertTrue(AddressBookLocation::validateScheduleNthWhat($i));
386
+        for ($i = 1; $i<11; $i++) $this->assertTrue(AddressBookLocation::validateScheduleNthWhat($i));
387 387
 
388 388
         $this->assertFalse(AddressBookLocation::validateScheduleNthWhat(0));
389 389
         $this->assertFalse(AddressBookLocation::validateScheduleNthWhat(14));
@@ -439,13 +439,13 @@  discard block
 block discarded – undo
439 439
 
440 440
     public static function tearDownAfterClass()
441 441
     {
442
-        $addressBookLocations=[];
442
+        $addressBookLocations = [];
443 443
 
444 444
         foreach (self::$createdContacts as $createdContact) {
445 445
             $addressBookLocations[] = $createdContact->address_id;
446 446
         }
447 447
 
448
-        $addressBookLocations = array_merge($addressBookLocations,self::$csvImportedAddressIDs);
448
+        $addressBookLocations = array_merge($addressBookLocations, self::$csvImportedAddressIDs);
449 449
 
450 450
         $abl = new AddressBookLocation();
451 451
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -383,7 +383,9 @@
 block discarded – undo
383 383
 
384 384
     public function testValidateScheduleNthWhat()
385 385
     {
386
-        for ($i=1;$i<11;$i++) $this->assertTrue(AddressBookLocation::validateScheduleNthWhat($i));
386
+        for ($i=1;$i<11;$i++) {
387
+        	$this->assertTrue(AddressBookLocation::validateScheduleNthWhat($i));
388
+        }
387 389
 
388 390
         $this->assertFalse(AddressBookLocation::validateScheduleNthWhat(0));
389 391
         $this->assertFalse(AddressBookLocation::validateScheduleNthWhat(14));
Please login to merge, or discard this patch.
UnitTestFiles/Test/AddressUnitTests.php 2 patches
Indentation   +328 added lines, -328 removed lines patch added patch discarded remove patch
@@ -12,339 +12,339 @@
 block discarded – undo
12 12
 use Route4Me\RouteParameters;
13 13
 
14 14
 class AddressUnitTests extends \PHPUnit\Framework\TestCase {
15
-    protected $address;
16
-    public static $createdAddresses;
17
-
18
-    public static $problem;
19
-    public static $problemDest;
20
-
21
-    public static $route_id = null;
22
-    public static $address_id = null;
23
-    public static $address_address = null;
24
-    public static $address_lat = null;
25
-    public static $address_lng = null;
26
-    public static $address_is_depot = null;
27
-
28
-    public static $addresIdMarkedAsVisited;
29
-
30
-    public static $afterAddressId;
31
-    public static $route_id_dest;
32
-
33
-    public static function setUpBeforeClass()
34
-    {
35
-        if (Constants::API_KEY == Constants::DEMO_API_KEY) {
36
-            $className = str_replace('UnitTestFiles\\Test\\','',get_class());
37
-            self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
38
-        }
39
-
40
-        Route4Me::setApiKey(Constants::API_KEY);
41
-
42
-        //<editor-fold desc="Prepare Addresses">
43
-        $addresses = [];
44
-        $addresses[] = Address::fromArray([
45
-            'address'           => '11497 Columbia Park Dr W, Jacksonville, FL 32258',
46
-            'is_depot'          => true,
47
-            'lat'               => 30.159341812134,
48
-            'lng'               => -81.538619995117,
49
-            'time'              => 300,
50
-            'time_window_start' => 28800,
51
-            'time_window_end'   => 32400,
52
-        ]);
53
-
54
-        $addresses[] = Address::fromArray([
55
-            'address'           => '214 Edgewater Branch Drive 32259',
56
-            'lat'               => 30.103567123413,
57
-            'lng'               => -81.595352172852,
58
-            'time'              => 300,
59
-            'time_window_start' => 36000,
60
-            'time_window_end'   => 37200,
61
-        ]);
62
-
63
-        $addresses[] = Address::fromArray([
64
-            'address'           => '756 eagle point dr 32092',
65
-            'lat'               => 30.046422958374,
66
-            'lng'               => -81.508758544922,
67
-            'time'              => 300,
68
-            'time_window_start' => 39600,
69
-            'time_window_end'   => 41400,
70
-        ]);
71
-
72
-        $addresses[] = Address::fromArray([
73
-            'address'           => '63 Stone Creek Cir St Johns, FL 32259, USA',
74
-            'lat'               => 30.048496,
75
-            'lng'               => -81.558716,
76
-            'time'              => 300,
77
-            'time_window_start' => 43200,
78
-            'time_window_end'   => 45000,
79
-        ]);
80
-
81
-        $addresses[] = Address::fromArray([
82
-            'address'           => 'St Johns Florida 32259, USA',
83
-            'lat'               => 30.099642,
84
-            'lng'               => -81.547201,
85
-            'time'              => 300,
86
-            'time_window_start' => 46800,
87
-            'time_window_end'   => 48600,
88
-        ]);
89
-
90
-        $parameters = RouteParameters::fromArray([
91
-            'device_type'           => DeviceType::IPAD,
92
-            'disable_optimization'  => false,
93
-            'route_name'            => 'phpunit test '.date('Y-m-d H:i'),
94
-        ]);
95
-        //</editor-fold>
96
-
97
-        $optimizationParameters = new OptimizationProblemParams();
98
-        $optimizationParameters->setAddresses($addresses);
99
-        $optimizationParameters->setParameters($parameters);
100
-
101
-        self::$problem = OptimizationProblem::optimize($optimizationParameters);
102
-        $routes = self::$problem->getRoutes();
103
-        self::$route_id = $routes[0]->route_id;
104
-        self::$createdAddresses = $routes[0]->addresses;
105
-
106
-        self::$problemDest = OptimizationProblem::optimize($optimizationParameters);
107
-        $routesDest = self::$problemDest->getRoutes();
108
-        $addressesDest = $routesDest[0]->addresses;
109
-        self::$route_id_dest = $routesDest[0]->route_id;
110
-        self::$afterAddressId = $addressesDest[2]->route_destination_id;
111
-
112
-        $addresses = self::$problem->addresses;
113
-        self::$address_id = $addresses[1]->getAddressId();
114
-        self::$address_address = $addresses[1]->address;
115
-        self::$address_lat = $addresses[1]->lat;
116
-        self::$address_lng = $addresses[1]->lng;
117
-        self::$address_is_depot = $addresses[1]->is_depot;
118
-
119
-        self::$addresIdMarkedAsVisited = $addresses[2]->getAddressId();
120
-
121
-        $params = [
122
-            'route_id'      =>  self::$route_id,
123
-            'address_id'    =>  self::$addresIdMarkedAsVisited,
124
-            'is_visited'    => 1
125
-        ];
126
-
127
-        $result =  $addresses[2]->markAsVisited($params);
128
-
129
-    }
130
-
131
-    public function testAddressFromArray()
132
-    {
133
-        $address = Address::fromArray([
134
-            'address'           => '10609 Mystic Pointe Dr, Fredericksburg, VA 22407',
135
-            'lat'               => 38.2513427734,
136
-            'lng'               => -77.5993652344,
137
-            'time'              => 300,
138
-            'time_window_end'   => 75600,
139
-            'time_window_start' => 28800,
140
-        ]);
141
-
142
-        $this->assertEquals($address->address, '10609 Mystic Pointe Dr, Fredericksburg, VA 22407');
143
-        $this->assertEquals($address->lat, 38.2513427734);
144
-        $this->assertEquals($address->lng, -77.5993652344);
145
-        $this->assertEquals($address->time, 300);
146
-        $this->assertEquals($address->time_window_start, 28800);
147
-        $this->assertEquals($address->time_window_end, 75600);
148
-    }
149
-
150
-    public function testToArray()
151
-    {
152
-        $address = Address::fromArray([
153
-            'address'           => '10609 Mystic Pointe Dr, Fredericksburg, VA 22407',
154
-            'lat'               => 38.2513427734,
155
-            'lng'               => -77.5993652344,
156
-            'time'              => 300,
157
-            'time_window_end'   => 75600,
158
-            'time_window_start' => 28800,
159
-            'custom_fields'     => [
160
-                'cf_1' => 1,
161
-            ],
162
-        ]);
163
-
164
-        $this->assertEquals($address->toArray(), [
165
-            'address'           => '10609 Mystic Pointe Dr, Fredericksburg, VA 22407',
166
-            'lat'               => 38.2513427734,
167
-            'lng'               => -77.5993652344,
168
-            'is_depot'          => false,
169
-            'time'              => 300,
170
-            'time_window_end'   => 75600,
171
-            'time_window_start' => 28800,
172
-            'custom_fields'     => [
173
-                'cf_1' => 1,
174
-            ],
175
-        ]);
176
-    }
177
-
178
-    public function testBadParameter()
179
-    {
180
-        $this->expectException(BadParam::class);
181
-
182
-        $address = Address::fromArray([
183
-            'lat1' => 38.2513427734,
184
-            'lng1' => -77.5993652344,
185
-        ]);
186
-
187
-        echo "address: ".$address->lat." <br>";
188
-    }
189
-
190
-    public function testAddressFromArrayWithBadKeys()
191
-    {
192
-        $this->expectException(BadParam::class);
193
-
194
-        $address = Address::fromArray([
195
-            'address'       => '10609 Mystic Pointe Dr, Fredericksburg, VA 22407',
196
-            'lat'           => 38.2513427734,
197
-            'lng'           => -77.5993652344,
198
-            'demoaddress'   => '333333',
199
-        ]);
200
-
201
-        $this->assertNotNull($address->address);
202
-        $this->assertEquals($address->address, '10609 Mystic Pointe Dr, Fredericksburg, VA 22407');
203
-        $this->assertEquals($address->lat, 38.2513427734);
204
-        $this->assertEquals($address->lng, -77.5993652344);
205
-
206
-        $this->assertFalse(property_exists($address, 'demoaddress'));
207
-    }
208
-
209
-    public function testGetAddress()
210
-    {
211
-        $address = Address::getAddress(self::$route_id, self::$address_id);
212
-
213
-        $this->assertNotNull($address);
214
-        $this->assertNotNull($address->address);
215
-        $this->assertEquals($address->address, self::$address_address);
216
-        $this->assertEquals($address->lat, self::$address_lat);
217
-        $this->assertEquals($address->lng, self::$address_lng);
218
-        $this->assertEquals($address->is_depot, self::$address_is_depot);
219
-
220
-        return $address;
221
-    }
222
-
223
-    public function testUpdateAddress()
224
-    {
225
-        $address = Address::getAddress(self::$route_id, self::$address_id);
226
-        $this->assertNotNull($address);
227
-
228
-        $address->route_id = self::$route_id;
229
-
230
-        $address->address = 'Updated address';
231
-        $newAddress = $address->update();
232
-
233
-        $this->assertEquals($newAddress->address, 'Updated address');
234
-    }
235
-
236
-    public function testMarkAsDeparted()
237
-    {
238
-        $address = new Address();
239
-
240
-        $params = [
241
-            'route_id'      =>  self::$route_id,
242
-            'address_id'    =>  self::$addresIdMarkedAsVisited,
243
-            'is_departed'   => 1
244
-        ];
245
-
246
-        $result = $address->markAsDeparted($params);
247
-
248
-        $this->assertNotNull($result);
249
-        $this->assertIsBool($result['status']);
250
-        $this->assertTrue($result['status']);
251
-    }
252
-
253
-    public function testMarkAsVisited()
254
-    {
255
-        $address = new Address();
256
-
257
-        $params = [
258
-            'route_id'   =>  self::$route_id,
259
-            'address_id' =>  self::$address_id,
260
-            'is_visited' => 1
261
-        ];
262
-
263
-        $result = $address->markAsVisited($params);
264
-
265
-        $this->assertNotNull($result);
266
-        $this->assertIsInt($result);
267
-        $this->assertEquals(1,$result);
268
-    }
269
-
270
-    public function testDeleteAddress()
271
-    {
272
-        $lastAddressId = self::$createdAddresses[sizeof(self::$createdAddresses)-1]->route_destination_id;
273
-
274
-        $address = Address::getAddress(self::$route_id, $lastAddressId);
275
-        $this->assertNotNull($address);
276
-
277
-        $state = $address->deleteAddress();
278
-        $this->assertTrue($state);
279
-
280
-        array_pop(self::$createdAddresses);
281
-    }
282
-
283
-    public function testMoveDestinationToRoute()
284
-    {
285
-        $lastAddressId = self::$createdAddresses[sizeof(self::$createdAddresses)-1]->route_destination_id;
286
-
287
-        // Move the destination to the route
288
-        $routeParams = [
289
-            'to_route_id'           => self::$route_id_dest,
290
-            'route_destination_id'  => $lastAddressId,
291
-            'after_destination_id'  => self::$afterAddressId,
292
-        ];
293
-
294
-        $address = new Address();
295
-        $result = $address->moveDestinationToRoute($routeParams);
296
-
297
-        $this->assertNotNull($result);
298
-        $this->assertNotNull($result['success']);
299
-        $this->assertEquals(true,$result['success']);
300
-    }
301
-
302
-    public function testChangeRouteDepote()
303
-    {
304
-        $address1 = Address::getAddress(
305
-            self::$route_id,
306
-            self::$createdAddresses[0]->route_destination_id);
15
+	protected $address;
16
+	public static $createdAddresses;
17
+
18
+	public static $problem;
19
+	public static $problemDest;
20
+
21
+	public static $route_id = null;
22
+	public static $address_id = null;
23
+	public static $address_address = null;
24
+	public static $address_lat = null;
25
+	public static $address_lng = null;
26
+	public static $address_is_depot = null;
27
+
28
+	public static $addresIdMarkedAsVisited;
29
+
30
+	public static $afterAddressId;
31
+	public static $route_id_dest;
32
+
33
+	public static function setUpBeforeClass()
34
+	{
35
+		if (Constants::API_KEY == Constants::DEMO_API_KEY) {
36
+			$className = str_replace('UnitTestFiles\\Test\\','',get_class());
37
+			self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
38
+		}
39
+
40
+		Route4Me::setApiKey(Constants::API_KEY);
41
+
42
+		//<editor-fold desc="Prepare Addresses">
43
+		$addresses = [];
44
+		$addresses[] = Address::fromArray([
45
+			'address'           => '11497 Columbia Park Dr W, Jacksonville, FL 32258',
46
+			'is_depot'          => true,
47
+			'lat'               => 30.159341812134,
48
+			'lng'               => -81.538619995117,
49
+			'time'              => 300,
50
+			'time_window_start' => 28800,
51
+			'time_window_end'   => 32400,
52
+		]);
53
+
54
+		$addresses[] = Address::fromArray([
55
+			'address'           => '214 Edgewater Branch Drive 32259',
56
+			'lat'               => 30.103567123413,
57
+			'lng'               => -81.595352172852,
58
+			'time'              => 300,
59
+			'time_window_start' => 36000,
60
+			'time_window_end'   => 37200,
61
+		]);
62
+
63
+		$addresses[] = Address::fromArray([
64
+			'address'           => '756 eagle point dr 32092',
65
+			'lat'               => 30.046422958374,
66
+			'lng'               => -81.508758544922,
67
+			'time'              => 300,
68
+			'time_window_start' => 39600,
69
+			'time_window_end'   => 41400,
70
+		]);
71
+
72
+		$addresses[] = Address::fromArray([
73
+			'address'           => '63 Stone Creek Cir St Johns, FL 32259, USA',
74
+			'lat'               => 30.048496,
75
+			'lng'               => -81.558716,
76
+			'time'              => 300,
77
+			'time_window_start' => 43200,
78
+			'time_window_end'   => 45000,
79
+		]);
80
+
81
+		$addresses[] = Address::fromArray([
82
+			'address'           => 'St Johns Florida 32259, USA',
83
+			'lat'               => 30.099642,
84
+			'lng'               => -81.547201,
85
+			'time'              => 300,
86
+			'time_window_start' => 46800,
87
+			'time_window_end'   => 48600,
88
+		]);
89
+
90
+		$parameters = RouteParameters::fromArray([
91
+			'device_type'           => DeviceType::IPAD,
92
+			'disable_optimization'  => false,
93
+			'route_name'            => 'phpunit test '.date('Y-m-d H:i'),
94
+		]);
95
+		//</editor-fold>
96
+
97
+		$optimizationParameters = new OptimizationProblemParams();
98
+		$optimizationParameters->setAddresses($addresses);
99
+		$optimizationParameters->setParameters($parameters);
100
+
101
+		self::$problem = OptimizationProblem::optimize($optimizationParameters);
102
+		$routes = self::$problem->getRoutes();
103
+		self::$route_id = $routes[0]->route_id;
104
+		self::$createdAddresses = $routes[0]->addresses;
105
+
106
+		self::$problemDest = OptimizationProblem::optimize($optimizationParameters);
107
+		$routesDest = self::$problemDest->getRoutes();
108
+		$addressesDest = $routesDest[0]->addresses;
109
+		self::$route_id_dest = $routesDest[0]->route_id;
110
+		self::$afterAddressId = $addressesDest[2]->route_destination_id;
111
+
112
+		$addresses = self::$problem->addresses;
113
+		self::$address_id = $addresses[1]->getAddressId();
114
+		self::$address_address = $addresses[1]->address;
115
+		self::$address_lat = $addresses[1]->lat;
116
+		self::$address_lng = $addresses[1]->lng;
117
+		self::$address_is_depot = $addresses[1]->is_depot;
118
+
119
+		self::$addresIdMarkedAsVisited = $addresses[2]->getAddressId();
120
+
121
+		$params = [
122
+			'route_id'      =>  self::$route_id,
123
+			'address_id'    =>  self::$addresIdMarkedAsVisited,
124
+			'is_visited'    => 1
125
+		];
126
+
127
+		$result =  $addresses[2]->markAsVisited($params);
128
+
129
+	}
130
+
131
+	public function testAddressFromArray()
132
+	{
133
+		$address = Address::fromArray([
134
+			'address'           => '10609 Mystic Pointe Dr, Fredericksburg, VA 22407',
135
+			'lat'               => 38.2513427734,
136
+			'lng'               => -77.5993652344,
137
+			'time'              => 300,
138
+			'time_window_end'   => 75600,
139
+			'time_window_start' => 28800,
140
+		]);
141
+
142
+		$this->assertEquals($address->address, '10609 Mystic Pointe Dr, Fredericksburg, VA 22407');
143
+		$this->assertEquals($address->lat, 38.2513427734);
144
+		$this->assertEquals($address->lng, -77.5993652344);
145
+		$this->assertEquals($address->time, 300);
146
+		$this->assertEquals($address->time_window_start, 28800);
147
+		$this->assertEquals($address->time_window_end, 75600);
148
+	}
149
+
150
+	public function testToArray()
151
+	{
152
+		$address = Address::fromArray([
153
+			'address'           => '10609 Mystic Pointe Dr, Fredericksburg, VA 22407',
154
+			'lat'               => 38.2513427734,
155
+			'lng'               => -77.5993652344,
156
+			'time'              => 300,
157
+			'time_window_end'   => 75600,
158
+			'time_window_start' => 28800,
159
+			'custom_fields'     => [
160
+				'cf_1' => 1,
161
+			],
162
+		]);
163
+
164
+		$this->assertEquals($address->toArray(), [
165
+			'address'           => '10609 Mystic Pointe Dr, Fredericksburg, VA 22407',
166
+			'lat'               => 38.2513427734,
167
+			'lng'               => -77.5993652344,
168
+			'is_depot'          => false,
169
+			'time'              => 300,
170
+			'time_window_end'   => 75600,
171
+			'time_window_start' => 28800,
172
+			'custom_fields'     => [
173
+				'cf_1' => 1,
174
+			],
175
+		]);
176
+	}
177
+
178
+	public function testBadParameter()
179
+	{
180
+		$this->expectException(BadParam::class);
181
+
182
+		$address = Address::fromArray([
183
+			'lat1' => 38.2513427734,
184
+			'lng1' => -77.5993652344,
185
+		]);
186
+
187
+		echo "address: ".$address->lat." <br>";
188
+	}
189
+
190
+	public function testAddressFromArrayWithBadKeys()
191
+	{
192
+		$this->expectException(BadParam::class);
193
+
194
+		$address = Address::fromArray([
195
+			'address'       => '10609 Mystic Pointe Dr, Fredericksburg, VA 22407',
196
+			'lat'           => 38.2513427734,
197
+			'lng'           => -77.5993652344,
198
+			'demoaddress'   => '333333',
199
+		]);
200
+
201
+		$this->assertNotNull($address->address);
202
+		$this->assertEquals($address->address, '10609 Mystic Pointe Dr, Fredericksburg, VA 22407');
203
+		$this->assertEquals($address->lat, 38.2513427734);
204
+		$this->assertEquals($address->lng, -77.5993652344);
205
+
206
+		$this->assertFalse(property_exists($address, 'demoaddress'));
207
+	}
208
+
209
+	public function testGetAddress()
210
+	{
211
+		$address = Address::getAddress(self::$route_id, self::$address_id);
212
+
213
+		$this->assertNotNull($address);
214
+		$this->assertNotNull($address->address);
215
+		$this->assertEquals($address->address, self::$address_address);
216
+		$this->assertEquals($address->lat, self::$address_lat);
217
+		$this->assertEquals($address->lng, self::$address_lng);
218
+		$this->assertEquals($address->is_depot, self::$address_is_depot);
219
+
220
+		return $address;
221
+	}
222
+
223
+	public function testUpdateAddress()
224
+	{
225
+		$address = Address::getAddress(self::$route_id, self::$address_id);
226
+		$this->assertNotNull($address);
227
+
228
+		$address->route_id = self::$route_id;
229
+
230
+		$address->address = 'Updated address';
231
+		$newAddress = $address->update();
232
+
233
+		$this->assertEquals($newAddress->address, 'Updated address');
234
+	}
235
+
236
+	public function testMarkAsDeparted()
237
+	{
238
+		$address = new Address();
239
+
240
+		$params = [
241
+			'route_id'      =>  self::$route_id,
242
+			'address_id'    =>  self::$addresIdMarkedAsVisited,
243
+			'is_departed'   => 1
244
+		];
245
+
246
+		$result = $address->markAsDeparted($params);
247
+
248
+		$this->assertNotNull($result);
249
+		$this->assertIsBool($result['status']);
250
+		$this->assertTrue($result['status']);
251
+	}
252
+
253
+	public function testMarkAsVisited()
254
+	{
255
+		$address = new Address();
256
+
257
+		$params = [
258
+			'route_id'   =>  self::$route_id,
259
+			'address_id' =>  self::$address_id,
260
+			'is_visited' => 1
261
+		];
262
+
263
+		$result = $address->markAsVisited($params);
264
+
265
+		$this->assertNotNull($result);
266
+		$this->assertIsInt($result);
267
+		$this->assertEquals(1,$result);
268
+	}
269
+
270
+	public function testDeleteAddress()
271
+	{
272
+		$lastAddressId = self::$createdAddresses[sizeof(self::$createdAddresses)-1]->route_destination_id;
273
+
274
+		$address = Address::getAddress(self::$route_id, $lastAddressId);
275
+		$this->assertNotNull($address);
276
+
277
+		$state = $address->deleteAddress();
278
+		$this->assertTrue($state);
279
+
280
+		array_pop(self::$createdAddresses);
281
+	}
282
+
283
+	public function testMoveDestinationToRoute()
284
+	{
285
+		$lastAddressId = self::$createdAddresses[sizeof(self::$createdAddresses)-1]->route_destination_id;
286
+
287
+		// Move the destination to the route
288
+		$routeParams = [
289
+			'to_route_id'           => self::$route_id_dest,
290
+			'route_destination_id'  => $lastAddressId,
291
+			'after_destination_id'  => self::$afterAddressId,
292
+		];
293
+
294
+		$address = new Address();
295
+		$result = $address->moveDestinationToRoute($routeParams);
296
+
297
+		$this->assertNotNull($result);
298
+		$this->assertNotNull($result['success']);
299
+		$this->assertEquals(true,$result['success']);
300
+	}
301
+
302
+	public function testChangeRouteDepote()
303
+	{
304
+		$address1 = Address::getAddress(
305
+			self::$route_id,
306
+			self::$createdAddresses[0]->route_destination_id);
307 307
 
308
-        $address1->route_id = self::$route_id;
309
-
310
-        $address2 = Address::getAddress(
311
-            self::$route_id,
312
-            self::$createdAddresses[1]->route_destination_id);
313
-
314
-        $address2->route_id = self::$route_id;
308
+		$address1->route_id = self::$route_id;
309
+
310
+		$address2 = Address::getAddress(
311
+			self::$route_id,
312
+			self::$createdAddresses[1]->route_destination_id);
313
+
314
+		$address2->route_id = self::$route_id;
315 315
 
316
-        $this->assertEquals(true, $address1->is_depot);
317
-        $this->assertEquals(false, $address2->is_depot);
316
+		$this->assertEquals(true, $address1->is_depot);
317
+		$this->assertEquals(false, $address2->is_depot);
318 318
 
319
-        $address1->is_depot = false;
320
-        $updatedAddress1 = $address1->update();
319
+		$address1->is_depot = false;
320
+		$updatedAddress1 = $address1->update();
321 321
 
322
-        $address2->is_depot = true;
323
-        $updatedAddress2 = $address2->update();
322
+		$address2->is_depot = true;
323
+		$updatedAddress2 = $address2->update();
324 324
 
325
-        $this->assertEquals(false, $updatedAddress1->is_depot);
326
-        $this->assertEquals(true, $updatedAddress2->is_depot);
327
-    }
325
+		$this->assertEquals(false, $updatedAddress1->is_depot);
326
+		$this->assertEquals(true, $updatedAddress2->is_depot);
327
+	}
328 328
 
329
-    public static function tearDownAfterClass()
330
-    {
331
-        $optimizationProblemId = self:: $problem->optimization_problem_id;
332
-        $destOptimizationProblemId = self::$problemDest->optimization_problem_id;
333
-
334
-        $params = [
335
-            'optimization_problem_ids' => [
336
-                '0' => $optimizationProblemId,
337
-                '1' => $destOptimizationProblemId
338
-            ],
339
-            'redirect' => 0,
340
-        ];
341
-
342
-        $result = self:: $problem->removeOptimization($params);
329
+	public static function tearDownAfterClass()
330
+	{
331
+		$optimizationProblemId = self:: $problem->optimization_problem_id;
332
+		$destOptimizationProblemId = self::$problemDest->optimization_problem_id;
333
+
334
+		$params = [
335
+			'optimization_problem_ids' => [
336
+				'0' => $optimizationProblemId,
337
+				'1' => $destOptimizationProblemId
338
+			],
339
+			'redirect' => 0,
340
+		];
341
+
342
+		$result = self:: $problem->removeOptimization($params);
343 343
 
344
-        if ($result!=null && $result['status']==true) {
345
-            echo "The test optimization was removed <br>";
346
-        } else {
347
-            echo "Cannot remove the test optimization <br>";
348
-        }
349
-    }
344
+		if ($result!=null && $result['status']==true) {
345
+			echo "The test optimization was removed <br>";
346
+		} else {
347
+			echo "Cannot remove the test optimization <br>";
348
+		}
349
+	}
350 350
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 
33 33
     public static function setUpBeforeClass()
34 34
     {
35
-        if (Constants::API_KEY == Constants::DEMO_API_KEY) {
36
-            $className = str_replace('UnitTestFiles\\Test\\','',get_class());
37
-            self::markTestSkipped( 'PHPUnit will skip '. $className ." class - it impossible run with demo API key" );
35
+        if (Constants::API_KEY==Constants::DEMO_API_KEY) {
36
+            $className = str_replace('UnitTestFiles\\Test\\', '', get_class());
37
+            self::markTestSkipped('PHPUnit will skip '.$className." class - it impossible run with demo API key");
38 38
         }
39 39
 
40 40
         Route4Me::setApiKey(Constants::API_KEY);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             'is_visited'    => 1
125 125
         ];
126 126
 
127
-        $result =  $addresses[2]->markAsVisited($params);
127
+        $result = $addresses[2]->markAsVisited($params);
128 128
 
129 129
     }
130 130
 
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 
265 265
         $this->assertNotNull($result);
266 266
         $this->assertIsInt($result);
267
-        $this->assertEquals(1,$result);
267
+        $this->assertEquals(1, $result);
268 268
     }
269 269
 
270 270
     public function testDeleteAddress()
271 271
     {
272
-        $lastAddressId = self::$createdAddresses[sizeof(self::$createdAddresses)-1]->route_destination_id;
272
+        $lastAddressId = self::$createdAddresses[sizeof(self::$createdAddresses) - 1]->route_destination_id;
273 273
 
274 274
         $address = Address::getAddress(self::$route_id, $lastAddressId);
275 275
         $this->assertNotNull($address);
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
     public function testMoveDestinationToRoute()
284 284
     {
285
-        $lastAddressId = self::$createdAddresses[sizeof(self::$createdAddresses)-1]->route_destination_id;
285
+        $lastAddressId = self::$createdAddresses[sizeof(self::$createdAddresses) - 1]->route_destination_id;
286 286
 
287 287
         // Move the destination to the route
288 288
         $routeParams = [
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 
297 297
         $this->assertNotNull($result);
298 298
         $this->assertNotNull($result['success']);
299
-        $this->assertEquals(true,$result['success']);
299
+        $this->assertEquals(true, $result['success']);
300 300
     }
301 301
 
302 302
     public function testChangeRouteDepote()
Please login to merge, or discard this patch.
UnitTestFiles/Test/TrackingTests.php 1 patch
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -26,260 +26,260 @@
 block discarded – undo
26 26
 
27 27
 class TrackingTests extends \PHPUnit\Framework\TestCase
28 28
 {
29
-    public static $createdProblems = [];
30
-    public static $testRoutes = [];
31
-
32
-    public static function setUpBeforeClass()
33
-    {
34
-        Route4Me::setApiKey(Constants::API_KEY);
35
-
36
-        $json = json_decode(file_get_contents(dirname(__FILE__).'/data/addresses_md_tw.json'), true);
37
-
38
-        $addresses = [];
39
-        foreach ($json as $address) {
40
-            $addresses[] = Address::fromArray($address);
41
-        }
42
-
43
-        $parameters = RouteParameters::fromArray([
44
-            'algorithm_type'            => AlgorithmType::CVRP_TW_MD,
45
-            'distance_unit'             => DistanceUnit::MILES,
46
-            'device_type'               => DeviceType::WEB,
47
-            'optimize'                  => OptimizationType::DISTANCE,
48
-            'metric'                    => Metric::GEODESIC,
49
-            'route_max_duration'        => 86400 * 2,
50
-            'travel_mode'               => TravelMode::DRIVING,
51
-            'vehicle_capacity'          => 50,
52
-            'vehicle_max_distance_mi'   => 10000,
53
-            'parts'                     => 50,
54
-        ]);
55
-        //endregion
56
-
57
-        $optimizationParameters = new OptimizationProblemParams();
58
-        $optimizationParameters->setAddresses($addresses);
59
-        $optimizationParameters->setParameters($parameters);
60
-
61
-        self::$createdProblems[] = OptimizationProblem::optimize($optimizationParameters);
62
-
63
-        self::$testRoutes = self::$createdProblems[0]->routes;
64
-
65
-        $params = TrackSetParams::fromArray([
66
-            'format'            => Format::SERIALIZED,
67
-            'route_id'          => self::$testRoutes[0]->route_id,
68
-            'member_id'         => self::$testRoutes[0]->parameters->member_id,
69
-            'course'            => 1,
70
-            'speed'             => 120,
71
-            'lat'               => 41.8927521,
72
-            'lng'               => -109.0803888,
73
-            'device_type'       => 'android_phone',
74
-            'device_guid'       => 'qweqweqwe',
75
-            'device_timestamp'  => date('Y-m-d H:i:s', strtotime('-2 day')),
76
-        ]);
77
-
78
-        $status = Track ::set($params);
79
-
80
-        self::assertNotNull($status, "Cannot send GPS position to the selected route");
81
-        self::assertTrue(isset($status['status']), "Cannot send GPS position to the selected route");
82
-        self::assertTrue($status['status'], "Cannot send GPS position to the selected route");
83
-    }
84
-
85
-    public function testFromArray()
86
-    {
87
-        $trackingParams = TrackSetParams::fromArray([
88
-            'member_id'     => 44444,
89
-            'format'        => 'json',
90
-            'route_id'      => '489D597EE62534C906096F1AAC278D26',
91
-            'course'        => 72,
92
-            'speed'         => 65,
93
-            'lat'           => 38.218662,
94
-            'lng'           => -85.789032,
95
-            'device_type'   => 'android_phone',
96
-            'device_guid'   => 'HK5454H0K454564WWER445'
97
-        ]);
98
-
99
-        $this->assertEquals(44444, $trackingParams->member_id);
100
-        $this->assertEquals('489D597EE62534C906096F1AAC278D26', $trackingParams->route_id);
101
-
102
-        $this->assertEquals(72, $trackingParams->course);
103
-        $this->assertEquals(65, $trackingParams->speed);
104
-        $this->assertEquals(38.218662, $trackingParams->lat);
105
-        $this->assertEquals(-85.789032, $trackingParams->lng);
106
-        $this->assertEquals('android_phone', $trackingParams->device_type);
107
-        $this->assertEquals('HK5454H0K454564WWER445', $trackingParams->device_guid);
108
-    }
109
-
110
-    public function testFindAsset()
111
-    {
112
-        $trackingNumber = null;
113
-
114
-        //region -- Get a tracking number from a random route destination --
115
-        $routeId = self::$testRoutes[0]->route_id;
116
-
117
-        $addresses = self::$testRoutes[0]->addresses;
118
-        assert(!is_null($addresses), "Cannot retrieve a random route ID");
119
-
120
-        foreach ($addresses as $addr1) {
121
-            if (!is_null($addr1->tracking_number)) {
122
-                $trackingNumber = $addr1->tracking_number;
123
-                break;
124
-            }
125
-        }
126
-
127
-        $this->assertNotNull($trackingNumber, "Cannot select a tracking number");
128
-
129
-        //endregion
130
-
131
-        $params = [
132
-            'tracking' => $trackingNumber,
133
-        ];
134
-
135
-        $route = new Route();
136
-
137
-        $result = $route->GetAssetTracking($params);
138
-
139
-        $this->assertNotNull($result);
140
-        $this->assertInstanceOf(FindAssetResponse::class, FindAssetResponse::fromArray($result));
141
-    }
142
-
143
-    public function testGetAllUserLocations()
144
-    {
145
-        $track = new Track();
146
-
147
-        $userLocations = $track->getUserLocations();
148
-
149
-        $this->assertNotNull($userLocations);
150
-        $this->assertTrue(is_array($userLocations));
151
-        $this->assertTrue(sizeof($userLocations)>0);
152
-        $this->assertInstanceOf(
153
-            UserLocation::class,
154
-            UserLocation::fromArray($userLocations[0]));
155
-        $this->assertInstanceOf(
156
-            MemberData::class,
157
-            MemberData::fromArray($userLocations[0]['member_data']));
158
-        $this->assertInstanceOf(
159
-            UserTracking::class,
160
-            UserTracking::fromArray($userLocations[0]['tracking']));
161
-    }
162
-
163
-    public function testQueryUserLocations()
164
-    {
165
-        $track = new Track();
166
-        $userLocations = $track->getUserLocations();
167
-        $userLocation = reset($userLocations);
168
-
169
-        $email = $userLocation['member_data']['member_email'];
170
-
171
-        $queriedUserLocations = $track->getUserLocations($email);
172
-
173
-        $this->assertNotNull($queriedUserLocations);
174
-        $this->assertTrue(is_array($queriedUserLocations));
175
-        $this->assertTrue(sizeof($queriedUserLocations)>0);
176
-        $this->assertInstanceOf(
177
-            UserLocation::class,
178
-            UserLocation::fromArray($queriedUserLocations[0])
179
-        );
180
-        $this->assertInstanceOf(
181
-            MemberData::class,
182
-            MemberData::fromArray($queriedUserLocations[0]['member_data'])
183
-        );
184
-        $this->assertInstanceOf(
185
-            UserTracking::class,
186
-            UserTracking::fromArray($queriedUserLocations[0]['tracking'])
187
-        );
188
-    }
189
-
190
-    public function testGetDeviceHistoryTimeRange()
191
-    {
192
-        $startDate = time() - 30 * 24 * 3600;
193
-        $endDate = time() + 1 * 24 * 3600;
194
-
195
-        $params = [
196
-            'route_id'      => self::$testRoutes[0]->route_id,
197
-            'format'        => Format::JSON,
198
-            'time_period'   => 'custom',
199
-            'start_date'    => $startDate,
200
-            'end_date'      => $endDate,
201
-        ];
202
-
203
-        $route = new Route();
204
-
205
-        $result = $route->GetTrackingHistoryFromTimeRange($params);
206
-
207
-        $this->assertNotNull($result);
208
-    }
209
-
210
-    public function testSetGPSPosition()
211
-    {
212
-        $route = new Route();
213
-
214
-        $routeId = self::$testRoutes[0]->route_id;
215
-
216
-        // Set GPS postion to the selected route
217
-        // Set right member_id corresponding to the API key
218
-        $params = TrackSetParams::fromArray([
219
-            'format'            => Format::CSV,
220
-            'route_id'          => $routeId,
221
-            'member_id'         => self::$testRoutes[0]->parameters->member_id,
222
-            'course'            => 1,
223
-            'speed'             => 120,
224
-            'lat'               => 41.8927521,
225
-            'lng'               => -109.0803888,
226
-            'device_type'       => 'android_phone',
227
-            'device_guid'       => 'qweqweqwe',
228
-            'device_timestamp'  => date('Y-m-d H:i:s', strtotime('-1 day')),
229
-        ]);
230
-
231
-        $status = Track::set($params);
232
-
233
-        $this->assertNotNull($status);
234
-        $this->assertInstanceOf(
235
-            SetGpsResponse::class,
236
-            SetGpsResponse::fromArray($status)
237
-        );
238
-        $this->assertTrue($status['status']);
239
-    }
240
-
241
-    public function testTrackDeviceLastLocationHistory()
242
-    {
243
-        $route = new Route();
244
-
245
-        $routeId = self::$testRoutes[0]->route_id;
246
-
247
-        $params = [
248
-            'route_id'                  => $routeId,
249
-            'device_tracking_history'   => '1',
250
-        ];
251
-
252
-        $result = $route->GetLastLocation($params);
253
-
254
-        $this->assertNotNull($result);
255
-        $this->assertInstanceOf(Route::class, $result);
256
-        $this->assertTrue(isset($result->tracking_history));
257
-    }
258
-
259
-    public static function tearDownAfterClass()
260
-    {
261
-        if (sizeof(self::$createdProblems)>0) {
262
-            $optimizationProblemIDs = [];
263
-
264
-            foreach (self::$createdProblems as $problem) {
265
-                $optimizationProblemId = $problem->optimization_problem_id;
266
-
267
-                $optimizationProblemIDs[] = $optimizationProblemId;
268
-            }
269
-
270
-            $params = [
271
-                'optimization_problem_ids' => $optimizationProblemIDs,
272
-                'redirect'                 => 0,
273
-            ];
274
-
275
-            $problem = new OptimizationProblem();
276
-            $result = $problem->removeOptimization($params);
277
-
278
-            if ($result!=null && $result['status']==true) {
279
-                echo "The test optimizations were removed <br>";
280
-            } else {
281
-                echo "Cannot remove the test optimizations <br>";
282
-            }
283
-        }
284
-    }
29
+	public static $createdProblems = [];
30
+	public static $testRoutes = [];
31
+
32
+	public static function setUpBeforeClass()
33
+	{
34
+		Route4Me::setApiKey(Constants::API_KEY);
35
+
36
+		$json = json_decode(file_get_contents(dirname(__FILE__).'/data/addresses_md_tw.json'), true);
37
+
38
+		$addresses = [];
39
+		foreach ($json as $address) {
40
+			$addresses[] = Address::fromArray($address);
41
+		}
42
+
43
+		$parameters = RouteParameters::fromArray([
44
+			'algorithm_type'            => AlgorithmType::CVRP_TW_MD,
45
+			'distance_unit'             => DistanceUnit::MILES,
46
+			'device_type'               => DeviceType::WEB,
47
+			'optimize'                  => OptimizationType::DISTANCE,
48
+			'metric'                    => Metric::GEODESIC,
49
+			'route_max_duration'        => 86400 * 2,
50
+			'travel_mode'               => TravelMode::DRIVING,
51
+			'vehicle_capacity'          => 50,
52
+			'vehicle_max_distance_mi'   => 10000,
53
+			'parts'                     => 50,
54
+		]);
55
+		//endregion
56
+
57
+		$optimizationParameters = new OptimizationProblemParams();
58
+		$optimizationParameters->setAddresses($addresses);
59
+		$optimizationParameters->setParameters($parameters);
60
+
61
+		self::$createdProblems[] = OptimizationProblem::optimize($optimizationParameters);
62
+
63
+		self::$testRoutes = self::$createdProblems[0]->routes;
64
+
65
+		$params = TrackSetParams::fromArray([
66
+			'format'            => Format::SERIALIZED,
67
+			'route_id'          => self::$testRoutes[0]->route_id,
68
+			'member_id'         => self::$testRoutes[0]->parameters->member_id,
69
+			'course'            => 1,
70
+			'speed'             => 120,
71
+			'lat'               => 41.8927521,
72
+			'lng'               => -109.0803888,
73
+			'device_type'       => 'android_phone',
74
+			'device_guid'       => 'qweqweqwe',
75
+			'device_timestamp'  => date('Y-m-d H:i:s', strtotime('-2 day')),
76
+		]);
77
+
78
+		$status = Track ::set($params);
79
+
80
+		self::assertNotNull($status, "Cannot send GPS position to the selected route");
81
+		self::assertTrue(isset($status['status']), "Cannot send GPS position to the selected route");
82
+		self::assertTrue($status['status'], "Cannot send GPS position to the selected route");
83
+	}
84
+
85
+	public function testFromArray()
86
+	{
87
+		$trackingParams = TrackSetParams::fromArray([
88
+			'member_id'     => 44444,
89
+			'format'        => 'json',
90
+			'route_id'      => '489D597EE62534C906096F1AAC278D26',
91
+			'course'        => 72,
92
+			'speed'         => 65,
93
+			'lat'           => 38.218662,
94
+			'lng'           => -85.789032,
95
+			'device_type'   => 'android_phone',
96
+			'device_guid'   => 'HK5454H0K454564WWER445'
97
+		]);
98
+
99
+		$this->assertEquals(44444, $trackingParams->member_id);
100
+		$this->assertEquals('489D597EE62534C906096F1AAC278D26', $trackingParams->route_id);
101
+
102
+		$this->assertEquals(72, $trackingParams->course);
103
+		$this->assertEquals(65, $trackingParams->speed);
104
+		$this->assertEquals(38.218662, $trackingParams->lat);
105
+		$this->assertEquals(-85.789032, $trackingParams->lng);
106
+		$this->assertEquals('android_phone', $trackingParams->device_type);
107
+		$this->assertEquals('HK5454H0K454564WWER445', $trackingParams->device_guid);
108
+	}
109
+
110
+	public function testFindAsset()
111
+	{
112
+		$trackingNumber = null;
113
+
114
+		//region -- Get a tracking number from a random route destination --
115
+		$routeId = self::$testRoutes[0]->route_id;
116
+
117
+		$addresses = self::$testRoutes[0]->addresses;
118
+		assert(!is_null($addresses), "Cannot retrieve a random route ID");
119
+
120
+		foreach ($addresses as $addr1) {
121
+			if (!is_null($addr1->tracking_number)) {
122
+				$trackingNumber = $addr1->tracking_number;
123
+				break;
124
+			}
125
+		}
126
+
127
+		$this->assertNotNull($trackingNumber, "Cannot select a tracking number");
128
+
129
+		//endregion
130
+
131
+		$params = [
132
+			'tracking' => $trackingNumber,
133
+		];
134
+
135
+		$route = new Route();
136
+
137
+		$result = $route->GetAssetTracking($params);
138
+
139
+		$this->assertNotNull($result);
140
+		$this->assertInstanceOf(FindAssetResponse::class, FindAssetResponse::fromArray($result));
141
+	}
142
+
143
+	public function testGetAllUserLocations()
144
+	{
145
+		$track = new Track();
146
+
147
+		$userLocations = $track->getUserLocations();
148
+
149
+		$this->assertNotNull($userLocations);
150
+		$this->assertTrue(is_array($userLocations));
151
+		$this->assertTrue(sizeof($userLocations)>0);
152
+		$this->assertInstanceOf(
153
+			UserLocation::class,
154
+			UserLocation::fromArray($userLocations[0]));
155
+		$this->assertInstanceOf(
156
+			MemberData::class,
157
+			MemberData::fromArray($userLocations[0]['member_data']));
158
+		$this->assertInstanceOf(
159
+			UserTracking::class,
160
+			UserTracking::fromArray($userLocations[0]['tracking']));
161
+	}
162
+
163
+	public function testQueryUserLocations()
164
+	{
165
+		$track = new Track();
166
+		$userLocations = $track->getUserLocations();
167
+		$userLocation = reset($userLocations);
168
+
169
+		$email = $userLocation['member_data']['member_email'];
170
+
171
+		$queriedUserLocations = $track->getUserLocations($email);
172
+
173
+		$this->assertNotNull($queriedUserLocations);
174
+		$this->assertTrue(is_array($queriedUserLocations));
175
+		$this->assertTrue(sizeof($queriedUserLocations)>0);
176
+		$this->assertInstanceOf(
177
+			UserLocation::class,
178
+			UserLocation::fromArray($queriedUserLocations[0])
179
+		);
180
+		$this->assertInstanceOf(
181
+			MemberData::class,
182
+			MemberData::fromArray($queriedUserLocations[0]['member_data'])
183
+		);
184
+		$this->assertInstanceOf(
185
+			UserTracking::class,
186
+			UserTracking::fromArray($queriedUserLocations[0]['tracking'])
187
+		);
188
+	}
189
+
190
+	public function testGetDeviceHistoryTimeRange()
191
+	{
192
+		$startDate = time() - 30 * 24 * 3600;
193
+		$endDate = time() + 1 * 24 * 3600;
194
+
195
+		$params = [
196
+			'route_id'      => self::$testRoutes[0]->route_id,
197
+			'format'        => Format::JSON,
198
+			'time_period'   => 'custom',
199
+			'start_date'    => $startDate,
200
+			'end_date'      => $endDate,
201
+		];
202
+
203
+		$route = new Route();
204
+
205
+		$result = $route->GetTrackingHistoryFromTimeRange($params);
206
+
207
+		$this->assertNotNull($result);
208
+	}
209
+
210
+	public function testSetGPSPosition()
211
+	{
212
+		$route = new Route();
213
+
214
+		$routeId = self::$testRoutes[0]->route_id;
215
+
216
+		// Set GPS postion to the selected route
217
+		// Set right member_id corresponding to the API key
218
+		$params = TrackSetParams::fromArray([
219
+			'format'            => Format::CSV,
220
+			'route_id'          => $routeId,
221
+			'member_id'         => self::$testRoutes[0]->parameters->member_id,
222
+			'course'            => 1,
223
+			'speed'             => 120,
224
+			'lat'               => 41.8927521,
225
+			'lng'               => -109.0803888,
226
+			'device_type'       => 'android_phone',
227
+			'device_guid'       => 'qweqweqwe',
228
+			'device_timestamp'  => date('Y-m-d H:i:s', strtotime('-1 day')),
229
+		]);
230
+
231
+		$status = Track::set($params);
232
+
233
+		$this->assertNotNull($status);
234
+		$this->assertInstanceOf(
235
+			SetGpsResponse::class,
236
+			SetGpsResponse::fromArray($status)
237
+		);
238
+		$this->assertTrue($status['status']);
239
+	}
240
+
241
+	public function testTrackDeviceLastLocationHistory()
242
+	{
243
+		$route = new Route();
244
+
245
+		$routeId = self::$testRoutes[0]->route_id;
246
+
247
+		$params = [
248
+			'route_id'                  => $routeId,
249
+			'device_tracking_history'   => '1',
250
+		];
251
+
252
+		$result = $route->GetLastLocation($params);
253
+
254
+		$this->assertNotNull($result);
255
+		$this->assertInstanceOf(Route::class, $result);
256
+		$this->assertTrue(isset($result->tracking_history));
257
+	}
258
+
259
+	public static function tearDownAfterClass()
260
+	{
261
+		if (sizeof(self::$createdProblems)>0) {
262
+			$optimizationProblemIDs = [];
263
+
264
+			foreach (self::$createdProblems as $problem) {
265
+				$optimizationProblemId = $problem->optimization_problem_id;
266
+
267
+				$optimizationProblemIDs[] = $optimizationProblemId;
268
+			}
269
+
270
+			$params = [
271
+				'optimization_problem_ids' => $optimizationProblemIDs,
272
+				'redirect'                 => 0,
273
+			];
274
+
275
+			$problem = new OptimizationProblem();
276
+			$result = $problem->removeOptimization($params);
277
+
278
+			if ($result!=null && $result['status']==true) {
279
+				echo "The test optimizations were removed <br>";
280
+			} else {
281
+				echo "Cannot remove the test optimizations <br>";
282
+			}
283
+		}
284
+	}
285 285
 }
286 286
\ No newline at end of file
Please login to merge, or discard this patch.
UnitTestFiles/Test/TelematicsGateWayApiTests.php 2 patches
Indentation   +476 added lines, -476 removed lines patch added patch discarded remove patch
@@ -15,490 +15,490 @@
 block discarded – undo
15 15
 
16 16
 class TelematicsGateWayApiTests extends \PHPUnit\Framework\TestCase
17 17
 {
18
-    static $createdConnections = [];
19
-    static $firstMemberId;
18
+	static $createdConnections = [];
19
+	static $firstMemberId;
20 20
 
21
-    static $api_token;
22
-    static $tomtom_vendor;
21
+	static $api_token;
22
+	static $tomtom_vendor;
23 23
     
24
-    public static function setUpBeforeClass()
25
-    {
26
-        Route4Me::setApiKey(Constants::API_KEY);
24
+	public static function setUpBeforeClass()
25
+	{
26
+		Route4Me::setApiKey(Constants::API_KEY);
27 27
         
28
-        $member = new Member();
28
+		$member = new Member();
29 29
         
30
-        $results = $member->getUsers();
30
+		$results = $member->getUsers();
31 31
 
32
-        self::$firstMemberId = Member::fromArray($results['results'][0])->member_id;
32
+		self::$firstMemberId = Member::fromArray($results['results'][0])->member_id;
33 33
         
34
-        print_r("\n member_id = ".self::$firstMemberId."\n");
35
-
36
-        //region Get API token
37
-
38
-        $vendorParameters = new TelematicsVendorParameters();
39
-        $vendorParameters->member_id = self::$firstMemberId;
40
-        $vendorParameters->api_key = Constants::API_KEY;
41
-
42
-        $vendors = new TelematicsVendor();
43
-        $result = $vendors->RegisterTelematicsMember($vendorParameters);
44
-
45
-        self::assertNotNull($result);
46
-        self::assertInstanceOf(
47
-            TelematicsRegisterMemberResponse::class,
48
-            TelematicsRegisterMemberResponse::fromArray($result)
49
-        );
50
-
51
-        self::$api_token = TelematicsRegisterMemberResponse::fromArray(
52
-            $result
53
-        )->api_token;
54
-
55
-        //endregion
56
-
57
-        //region Get TomTom vendor
58
-
59
-        $vendorsParameters = TelematicsVendorParameters::fromArray([
60
-            //"country"     => "GB",  // uncomment this line for searching by Country
61
-            'is_integrated' => 1,
62
-            //"feature"     => "satellite",  // uncomment this line for searching by Feature
63
-            'search'        => 'tomtom',
64
-            'page'          => 1,
65
-            'per_page'      => 5,
66
-        ]);
67
-
68
-        $vendors = new TelematicsVendor();
69
-        $vendorsResults = $vendors->GetTelematicsVendors($vendorsParameters);
70
-
71
-        self::assertNotNull($vendorsResults);
72
-        self::assertTrue(is_array($vendorsResults));
73
-        self::assertTrue(sizeof($vendorsResults)>0);
74
-        self::assertTrue(
75
-            TelematicsVendor::fromArray($vendorsResults['vendors'][0])
76
-                instanceof
77
-                TelematicsVendor);
78
-
79
-        self::$tomtom_vendor = TelematicsVendor::fromArray($vendorsResults['vendors'][0]);
80
-        //endregion
81
-
82
-        //region Create Test Connection
83
-
84
-        $vendParams = new TelematicsConnectionParameters();
85
-
86
-        $vendParams->vendor       = TelematicsVendorsTypes::GEOTAB;
87
-        $vendParams->account_id   = '54321';
88
-        $vendParams->username     = 'John Doe 0';
89
-        $vendParams->password     = 'password0';
90
-        $vendParams->vehicle_position_refresh_rate    = 60;
91
-        $vendParams->name         = 'Test Geotab Connection from php SDK';
92
-        $vendParams->validate_remote_credentials      = 0;
93
-
94
-        $teleConnection = new TelematicsConnection();
95
-
96
-        $result2 = $teleConnection->createTelematicsConnection(
97
-            self::$api_token,
98
-            $vendParams->toArray()
99
-        );
100
-
101
-        self::assertNotNull($result2);
102
-        self::assertTrue( CreateConnectionResponse::fromArray($result2) instanceof CreateConnectionResponse);
103
-
104
-        self::$createdConnections[] = TelematicsConnection::fromArray($result2);
105
-        //endregion
106
-    }
107
-
108
-    public function testFromArray()
109
-    {
110
-        $vendorParameters = TelematicsVendor::fromArray([
111
-            'id'            => 14,
112
-            'name'          => 'Borea',
113
-            'slug'          => 'borea',
114
-            'description'   => 'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
115
-            'logo_url'      => 'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
116
-            'website_url'   => 'https:\/\/www.borea.com\/',
117
-            'api_docs_url'  => 'https:\/\/www.borea.com\/docs\/',
118
-            'is_integrated' => true,
119
-            'size'          => 'regional',
120
-            'features'      => [
121
-                0 => [
122
-                    'id'    => '1',
123
-                    'name'  => 'Customizable Reports',
124
-                    'slug'  => 'customizable-reports',
125
-                    'feature_group' => 'Analytics & Reporting'
126
-                ],
127
-                1 => [
128
-                    'id'            => '2',
129
-                    'name'          => 'Publicly Accessible API Documention',
130
-                    'slug'          => 'publicly-accessible-api-doc',
131
-                    'feature_group' => 'API & SDK'
132
-                ]
133
-            ],
134
-            'countries' => [
135
-                0 => [
136
-                    'id'            => '38',
137
-                    'country_code'  => 'CA',
138
-                    'country_name'  => 'Canada'
139
-                ],
140
-                1 => [
141
-                    'id'            => '230',
142
-                    'country_code'  => 'USA',
143
-                    'country_name'  => 'United States'
144
-                ]
145
-            ]
146
-        ]);
147
-
148
-        $this->assertEquals(14, $vendorParameters->id);
149
-        $this->assertEquals('Borea', $vendorParameters->name);
150
-        $this->assertEquals('borea', $vendorParameters->slug);
151
-        $this->assertEquals(
152
-            'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
153
-            $vendorParameters->description
154
-        );
155
-        $this->assertEquals(
156
-            'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
157
-            $vendorParameters->logo_url
158
-        );
159
-        $this->assertEquals('https:\/\/www.borea.com\/', $vendorParameters->website_url);
160
-        $this->assertEquals('https:\/\/www.borea.com\/docs\/', $vendorParameters->api_docs_url);
161
-        $this->assertEquals(true, $vendorParameters->is_integrated);
162
-        $this->assertEquals('regional', $vendorParameters->size);
163
-        $this->assertEquals(
164
-            [
165
-                0 => [
166
-                    'id'            => '1',
167
-                    'name'          => 'Customizable Reports',
168
-                    'slug'          => 'customizable-reports',
169
-                    'feature_group' => 'Analytics & Reporting'
170
-                ],
171
-                1 => [
172
-                    'id'            => '2',
173
-                    'name'          => 'Publicly Accessible API Documention',
174
-                    'slug'          => 'publicly-accessible-api-doc',
175
-                    'feature_group' => 'API & SDK'
176
-                ]
177
-            ],
178
-            $vendorParameters->features
179
-        );
180
-        $this->assertEquals(
181
-            [
182
-                0 => [
183
-                    'id'            => '38',
184
-                    'country_code'  => 'CA',
185
-                    'country_name'  => 'Canada'
186
-                ],
187
-                1 => [
188
-                    'id'            => '230',
189
-                    'country_code'  => 'USA',
190
-                    'country_name'  => 'United States'
191
-                ]
192
-            ],
193
-            $vendorParameters->countries
194
-        );
195
-    }
196
-
197
-    public function testToArray()
198
-    {
199
-        $vendorParameters = TelematicsVendor::fromArray([
200
-            'id'            => 14,
201
-            'name'          => 'Borea',
202
-            'slug'          => 'borea',
203
-            'description'   => 'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
204
-            'logo_url'      => 'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
205
-            'website_url'   => 'https:\/\/www.borea.com\/',
206
-            'api_docs_url'  => 'https:\/\/www.borea.com\/docs\/',
207
-            'is_integrated' => true,
208
-            'size'          => 'regional',
209
-            'features'      => [
210
-                0 => [
211
-                    'id'            => '1',
212
-                    'name'          => 'Customizable Reports',
213
-                    'slug'          => 'customizable-reports',
214
-                    'feature_group' => 'Analytics & Reporting'
215
-                ],
216
-                1 => [
217
-                    'id'            => '2',
218
-                    'name'          => 'Publicly Accessible API Documention',
219
-                    'slug'          => 'publicly-accessible-api-doc',
220
-                    'feature_group' => 'API & SDK'
221
-                ]
222
-            ],
223
-            'countries' => [
224
-                0 => [
225
-                    'id'            => '38',
226
-                    'country_code'  => 'CA',
227
-                    'country_name'  => 'Canada'
228
-                ],
229
-                1 => [
230
-                    'id'            => '230',
231
-                    'country_code'  => 'USA',
232
-                    'country_name'  => 'United States'
233
-                ]
234
-            ]
235
-        ]);
236
-
237
-        $this->assertEquals(14, $vendorParameters->id);
238
-        $this->assertEquals('Borea', $vendorParameters->name);
239
-        $this->assertEquals('borea', $vendorParameters->slug);
240
-        $this->assertEquals(
241
-            'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
242
-            $vendorParameters->description
243
-        );
244
-        $this->assertEquals(
245
-            'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
246
-            $vendorParameters->logo_url
247
-        );
248
-        $this->assertEquals('https:\/\/www.borea.com\/', $vendorParameters->website_url);
249
-        $this->assertEquals('https:\/\/www.borea.com\/docs\/', $vendorParameters->api_docs_url);
250
-        $this->assertEquals(true, $vendorParameters->is_integrated);
251
-        $this->assertEquals('regional', $vendorParameters->size);
252
-        $this->assertEquals(
253
-            [
254
-                0 => [
255
-                    'id'            => '1',
256
-                    'name'          => 'Customizable Reports',
257
-                    'slug'          => 'customizable-reports',
258
-                    'feature_group' => 'Analytics & Reporting'
259
-                ],
260
-                1 => [
261
-                    'id'            => '2',
262
-                    'name'          => 'Publicly Accessible API Documention',
263
-                    'slug'          => 'publicly-accessible-api-doc',
264
-                    'feature_group' => 'API & SDK'
265
-                ]
266
-            ],
267
-            $vendorParameters->features
268
-        );
269
-        $this->assertEquals(
270
-            [
271
-                0 => [
272
-                    'id'            => '38',
273
-                    'country_code'  => 'CA',
274
-                    'country_name'  => 'Canada'
275
-                ],
276
-                1 => [
277
-                    'id'            => '230',
278
-                    'country_code'  => 'USA',
279
-                    'country_name'  => 'United States'
280
-                ]
281
-            ],
282
-            $vendorParameters->countries
283
-        );
284
-
285
-        $this->assertEquals($vendorParameters->toArray(),
286
-            [
287
-                'id'            => 14,
288
-                'name'          => 'Borea',
289
-                'slug'          => 'borea',
290
-                'description'   => 'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
291
-                'logo_url'      => 'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
292
-                'website_url'   => 'https:\/\/www.borea.com\/',
293
-                'api_docs_url'  => 'https:\/\/www.borea.com\/docs\/',
294
-                'is_integrated' => true,
295
-                'size'          => 'regional',
296
-                'features'      => [
297
-                    0 => [
298
-                        'id'            => '1',
299
-                        'name'          => 'Customizable Reports',
300
-                        'slug'          => 'customizable-reports',
301
-                        'feature_group' => 'Analytics & Reporting'
302
-                    ],
303
-                    1 => [
304
-                        'id'            => '2',
305
-                        'name'          => 'Publicly Accessible API Documention',
306
-                        'slug'          => 'publicly-accessible-api-doc',
307
-                        'feature_group' => 'API & SDK'
308
-                    ]
309
-                ],
310
-                'countries' => [
311
-                    0 => [
312
-                        'id'            => '38',
313
-                        'country_code'  => 'CA',
314
-                        'country_name'  => 'Canada'
315
-                    ],
316
-                    1 => [
317
-                        'id'            => '230',
318
-                        'country_code'  => 'USA',
319
-                        'country_name'  => 'United States'
320
-                    ]
321
-                ]
322
-            ]
323
-        );
324
-    }
325
-
326
-    public function testGetAllVendors()
327
-    {
328
-        $vendorsParameters = TelematicsVendor::fromArray( [ ] );
329
-
330
-        $vendors = new TelematicsVendor();
331
-        $vendorsResults = $vendors->GetTelematicsVendors($vendorsParameters);
332
-
333
-        $this->assertNotNull($vendorsResults);
334
-        $this->assertTrue(is_array($vendorsResults));
335
-        $this->assertTrue(sizeof($vendorsResults)>0);
336
-        $this->assertInstanceOf(
337
-            TelematicsVendor::class,
338
-            TelematicsVendor::fromArray($vendorsResults['vendors'][0])
339
-        );
340
-    }
341
-
342
-    public function testGetVendor()
343
-    {
344
-        $vendorResult = TelematicsVendor::getVendorById(self::$tomtom_vendor->id);
345
-
346
-        $this->assertNotNull($vendorResult);
347
-        $this->assertTrue(is_array($vendorResult));
348
-        $this->assertInstanceOf(
349
-            TelematicsVendor::class,
350
-            TelematicsVendor::fromArray($vendorResult)
351
-        );
352
-    }
353
-
354
-    public function testSearchVendors()
355
-    {
356
-        $vendorsParameters = TelematicsVendorParameters::fromArray([
357
-            //"country"     => "GB",  // uncomment this line for searching by Country
358
-            'is_integrated' => 1,
359
-            //"feature"     => "satellite",  // uncomment this line for searching by Feature
360
-            'search'        => 'Fleet',
361
-            'page'          => 1,
362
-            'per_page'      => 5,
363
-        ]);
364
-
365
-        $vendors = new TelematicsVendor();
366
-        $vendorsResults = $vendors->GetTelematicsVendors($vendorsParameters);
367
-
368
-        $this->assertNotNull($vendorsResults);
369
-        $this->assertTrue(is_array($vendorsResults));
370
-        $this->assertTrue(sizeof($vendorsResults)>0);
371
-        $this->assertInstanceOf(
372
-            TelematicsVendor::class,
373
-            TelematicsVendor::fromArray($vendorsResults['vendors'][0])
374
-        );
375
-    }
376
-
377
-    public function testVendorsComparison()
378
-    {
379
-        $vendorsParameters = TelematicsVendorParameters::fromArray([
380
-            'vendors' => '55,56,57',
381
-        ]);
382
-
383
-        $vendors = new TelematicsVendor();
384
-        $comparisonResults = $vendors->GetTelematicsVendors($vendorsParameters);
385
-
386
-        $this->assertNotNull($comparisonResults);
387
-        $this->assertTrue(is_array($comparisonResults));
388
-        $this->assertTrue(sizeof($comparisonResults)>0);
389
-        $this->assertInstanceOf(
390
-            TelematicsVendor::class,
391
-            TelematicsVendor::fromArray($comparisonResults['vendors'][0])
392
-        );
393
-    }
34
+		print_r("\n member_id = ".self::$firstMemberId."\n");
35
+
36
+		//region Get API token
37
+
38
+		$vendorParameters = new TelematicsVendorParameters();
39
+		$vendorParameters->member_id = self::$firstMemberId;
40
+		$vendorParameters->api_key = Constants::API_KEY;
41
+
42
+		$vendors = new TelematicsVendor();
43
+		$result = $vendors->RegisterTelematicsMember($vendorParameters);
44
+
45
+		self::assertNotNull($result);
46
+		self::assertInstanceOf(
47
+			TelematicsRegisterMemberResponse::class,
48
+			TelematicsRegisterMemberResponse::fromArray($result)
49
+		);
50
+
51
+		self::$api_token = TelematicsRegisterMemberResponse::fromArray(
52
+			$result
53
+		)->api_token;
54
+
55
+		//endregion
56
+
57
+		//region Get TomTom vendor
58
+
59
+		$vendorsParameters = TelematicsVendorParameters::fromArray([
60
+			//"country"     => "GB",  // uncomment this line for searching by Country
61
+			'is_integrated' => 1,
62
+			//"feature"     => "satellite",  // uncomment this line for searching by Feature
63
+			'search'        => 'tomtom',
64
+			'page'          => 1,
65
+			'per_page'      => 5,
66
+		]);
67
+
68
+		$vendors = new TelematicsVendor();
69
+		$vendorsResults = $vendors->GetTelematicsVendors($vendorsParameters);
70
+
71
+		self::assertNotNull($vendorsResults);
72
+		self::assertTrue(is_array($vendorsResults));
73
+		self::assertTrue(sizeof($vendorsResults)>0);
74
+		self::assertTrue(
75
+			TelematicsVendor::fromArray($vendorsResults['vendors'][0])
76
+				instanceof
77
+				TelematicsVendor);
78
+
79
+		self::$tomtom_vendor = TelematicsVendor::fromArray($vendorsResults['vendors'][0]);
80
+		//endregion
81
+
82
+		//region Create Test Connection
83
+
84
+		$vendParams = new TelematicsConnectionParameters();
85
+
86
+		$vendParams->vendor       = TelematicsVendorsTypes::GEOTAB;
87
+		$vendParams->account_id   = '54321';
88
+		$vendParams->username     = 'John Doe 0';
89
+		$vendParams->password     = 'password0';
90
+		$vendParams->vehicle_position_refresh_rate    = 60;
91
+		$vendParams->name         = 'Test Geotab Connection from php SDK';
92
+		$vendParams->validate_remote_credentials      = 0;
93
+
94
+		$teleConnection = new TelematicsConnection();
95
+
96
+		$result2 = $teleConnection->createTelematicsConnection(
97
+			self::$api_token,
98
+			$vendParams->toArray()
99
+		);
100
+
101
+		self::assertNotNull($result2);
102
+		self::assertTrue( CreateConnectionResponse::fromArray($result2) instanceof CreateConnectionResponse);
103
+
104
+		self::$createdConnections[] = TelematicsConnection::fromArray($result2);
105
+		//endregion
106
+	}
107
+
108
+	public function testFromArray()
109
+	{
110
+		$vendorParameters = TelematicsVendor::fromArray([
111
+			'id'            => 14,
112
+			'name'          => 'Borea',
113
+			'slug'          => 'borea',
114
+			'description'   => 'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
115
+			'logo_url'      => 'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
116
+			'website_url'   => 'https:\/\/www.borea.com\/',
117
+			'api_docs_url'  => 'https:\/\/www.borea.com\/docs\/',
118
+			'is_integrated' => true,
119
+			'size'          => 'regional',
120
+			'features'      => [
121
+				0 => [
122
+					'id'    => '1',
123
+					'name'  => 'Customizable Reports',
124
+					'slug'  => 'customizable-reports',
125
+					'feature_group' => 'Analytics & Reporting'
126
+				],
127
+				1 => [
128
+					'id'            => '2',
129
+					'name'          => 'Publicly Accessible API Documention',
130
+					'slug'          => 'publicly-accessible-api-doc',
131
+					'feature_group' => 'API & SDK'
132
+				]
133
+			],
134
+			'countries' => [
135
+				0 => [
136
+					'id'            => '38',
137
+					'country_code'  => 'CA',
138
+					'country_name'  => 'Canada'
139
+				],
140
+				1 => [
141
+					'id'            => '230',
142
+					'country_code'  => 'USA',
143
+					'country_name'  => 'United States'
144
+				]
145
+			]
146
+		]);
147
+
148
+		$this->assertEquals(14, $vendorParameters->id);
149
+		$this->assertEquals('Borea', $vendorParameters->name);
150
+		$this->assertEquals('borea', $vendorParameters->slug);
151
+		$this->assertEquals(
152
+			'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
153
+			$vendorParameters->description
154
+		);
155
+		$this->assertEquals(
156
+			'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
157
+			$vendorParameters->logo_url
158
+		);
159
+		$this->assertEquals('https:\/\/www.borea.com\/', $vendorParameters->website_url);
160
+		$this->assertEquals('https:\/\/www.borea.com\/docs\/', $vendorParameters->api_docs_url);
161
+		$this->assertEquals(true, $vendorParameters->is_integrated);
162
+		$this->assertEquals('regional', $vendorParameters->size);
163
+		$this->assertEquals(
164
+			[
165
+				0 => [
166
+					'id'            => '1',
167
+					'name'          => 'Customizable Reports',
168
+					'slug'          => 'customizable-reports',
169
+					'feature_group' => 'Analytics & Reporting'
170
+				],
171
+				1 => [
172
+					'id'            => '2',
173
+					'name'          => 'Publicly Accessible API Documention',
174
+					'slug'          => 'publicly-accessible-api-doc',
175
+					'feature_group' => 'API & SDK'
176
+				]
177
+			],
178
+			$vendorParameters->features
179
+		);
180
+		$this->assertEquals(
181
+			[
182
+				0 => [
183
+					'id'            => '38',
184
+					'country_code'  => 'CA',
185
+					'country_name'  => 'Canada'
186
+				],
187
+				1 => [
188
+					'id'            => '230',
189
+					'country_code'  => 'USA',
190
+					'country_name'  => 'United States'
191
+				]
192
+			],
193
+			$vendorParameters->countries
194
+		);
195
+	}
196
+
197
+	public function testToArray()
198
+	{
199
+		$vendorParameters = TelematicsVendor::fromArray([
200
+			'id'            => 14,
201
+			'name'          => 'Borea',
202
+			'slug'          => 'borea',
203
+			'description'   => 'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
204
+			'logo_url'      => 'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
205
+			'website_url'   => 'https:\/\/www.borea.com\/',
206
+			'api_docs_url'  => 'https:\/\/www.borea.com\/docs\/',
207
+			'is_integrated' => true,
208
+			'size'          => 'regional',
209
+			'features'      => [
210
+				0 => [
211
+					'id'            => '1',
212
+					'name'          => 'Customizable Reports',
213
+					'slug'          => 'customizable-reports',
214
+					'feature_group' => 'Analytics & Reporting'
215
+				],
216
+				1 => [
217
+					'id'            => '2',
218
+					'name'          => 'Publicly Accessible API Documention',
219
+					'slug'          => 'publicly-accessible-api-doc',
220
+					'feature_group' => 'API & SDK'
221
+				]
222
+			],
223
+			'countries' => [
224
+				0 => [
225
+					'id'            => '38',
226
+					'country_code'  => 'CA',
227
+					'country_name'  => 'Canada'
228
+				],
229
+				1 => [
230
+					'id'            => '230',
231
+					'country_code'  => 'USA',
232
+					'country_name'  => 'United States'
233
+				]
234
+			]
235
+		]);
236
+
237
+		$this->assertEquals(14, $vendorParameters->id);
238
+		$this->assertEquals('Borea', $vendorParameters->name);
239
+		$this->assertEquals('borea', $vendorParameters->slug);
240
+		$this->assertEquals(
241
+			'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
242
+			$vendorParameters->description
243
+		);
244
+		$this->assertEquals(
245
+			'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
246
+			$vendorParameters->logo_url
247
+		);
248
+		$this->assertEquals('https:\/\/www.borea.com\/', $vendorParameters->website_url);
249
+		$this->assertEquals('https:\/\/www.borea.com\/docs\/', $vendorParameters->api_docs_url);
250
+		$this->assertEquals(true, $vendorParameters->is_integrated);
251
+		$this->assertEquals('regional', $vendorParameters->size);
252
+		$this->assertEquals(
253
+			[
254
+				0 => [
255
+					'id'            => '1',
256
+					'name'          => 'Customizable Reports',
257
+					'slug'          => 'customizable-reports',
258
+					'feature_group' => 'Analytics & Reporting'
259
+				],
260
+				1 => [
261
+					'id'            => '2',
262
+					'name'          => 'Publicly Accessible API Documention',
263
+					'slug'          => 'publicly-accessible-api-doc',
264
+					'feature_group' => 'API & SDK'
265
+				]
266
+			],
267
+			$vendorParameters->features
268
+		);
269
+		$this->assertEquals(
270
+			[
271
+				0 => [
272
+					'id'            => '38',
273
+					'country_code'  => 'CA',
274
+					'country_name'  => 'Canada'
275
+				],
276
+				1 => [
277
+					'id'            => '230',
278
+					'country_code'  => 'USA',
279
+					'country_name'  => 'United States'
280
+				]
281
+			],
282
+			$vendorParameters->countries
283
+		);
284
+
285
+		$this->assertEquals($vendorParameters->toArray(),
286
+			[
287
+				'id'            => 14,
288
+				'name'          => 'Borea',
289
+				'slug'          => 'borea',
290
+				'description'   => 'Borea is a leading connected vehicle platform, helping our customers turn data about vehicles and their use into intelligence',
291
+				'logo_url'      => 'https:\/\/storage.googleapis.com\/telematics-directory-production\/silent-passanger555555.png',
292
+				'website_url'   => 'https:\/\/www.borea.com\/',
293
+				'api_docs_url'  => 'https:\/\/www.borea.com\/docs\/',
294
+				'is_integrated' => true,
295
+				'size'          => 'regional',
296
+				'features'      => [
297
+					0 => [
298
+						'id'            => '1',
299
+						'name'          => 'Customizable Reports',
300
+						'slug'          => 'customizable-reports',
301
+						'feature_group' => 'Analytics & Reporting'
302
+					],
303
+					1 => [
304
+						'id'            => '2',
305
+						'name'          => 'Publicly Accessible API Documention',
306
+						'slug'          => 'publicly-accessible-api-doc',
307
+						'feature_group' => 'API & SDK'
308
+					]
309
+				],
310
+				'countries' => [
311
+					0 => [
312
+						'id'            => '38',
313
+						'country_code'  => 'CA',
314
+						'country_name'  => 'Canada'
315
+					],
316
+					1 => [
317
+						'id'            => '230',
318
+						'country_code'  => 'USA',
319
+						'country_name'  => 'United States'
320
+					]
321
+				]
322
+			]
323
+		);
324
+	}
325
+
326
+	public function testGetAllVendors()
327
+	{
328
+		$vendorsParameters = TelematicsVendor::fromArray( [ ] );
329
+
330
+		$vendors = new TelematicsVendor();
331
+		$vendorsResults = $vendors->GetTelematicsVendors($vendorsParameters);
332
+
333
+		$this->assertNotNull($vendorsResults);
334
+		$this->assertTrue(is_array($vendorsResults));
335
+		$this->assertTrue(sizeof($vendorsResults)>0);
336
+		$this->assertInstanceOf(
337
+			TelematicsVendor::class,
338
+			TelematicsVendor::fromArray($vendorsResults['vendors'][0])
339
+		);
340
+	}
341
+
342
+	public function testGetVendor()
343
+	{
344
+		$vendorResult = TelematicsVendor::getVendorById(self::$tomtom_vendor->id);
345
+
346
+		$this->assertNotNull($vendorResult);
347
+		$this->assertTrue(is_array($vendorResult));
348
+		$this->assertInstanceOf(
349
+			TelematicsVendor::class,
350
+			TelematicsVendor::fromArray($vendorResult)
351
+		);
352
+	}
353
+
354
+	public function testSearchVendors()
355
+	{
356
+		$vendorsParameters = TelematicsVendorParameters::fromArray([
357
+			//"country"     => "GB",  // uncomment this line for searching by Country
358
+			'is_integrated' => 1,
359
+			//"feature"     => "satellite",  // uncomment this line for searching by Feature
360
+			'search'        => 'Fleet',
361
+			'page'          => 1,
362
+			'per_page'      => 5,
363
+		]);
364
+
365
+		$vendors = new TelematicsVendor();
366
+		$vendorsResults = $vendors->GetTelematicsVendors($vendorsParameters);
367
+
368
+		$this->assertNotNull($vendorsResults);
369
+		$this->assertTrue(is_array($vendorsResults));
370
+		$this->assertTrue(sizeof($vendorsResults)>0);
371
+		$this->assertInstanceOf(
372
+			TelematicsVendor::class,
373
+			TelematicsVendor::fromArray($vendorsResults['vendors'][0])
374
+		);
375
+	}
376
+
377
+	public function testVendorsComparison()
378
+	{
379
+		$vendorsParameters = TelematicsVendorParameters::fromArray([
380
+			'vendors' => '55,56,57',
381
+		]);
382
+
383
+		$vendors = new TelematicsVendor();
384
+		$comparisonResults = $vendors->GetTelematicsVendors($vendorsParameters);
385
+
386
+		$this->assertNotNull($comparisonResults);
387
+		$this->assertTrue(is_array($comparisonResults));
388
+		$this->assertTrue(sizeof($comparisonResults)>0);
389
+		$this->assertInstanceOf(
390
+			TelematicsVendor::class,
391
+			TelematicsVendor::fromArray($comparisonResults['vendors'][0])
392
+		);
393
+	}
394 394
     
395
-    public function testRegisterTelematicsVendor() 
396
-    {
397
-        $vendorParameters = new TelematicsVendorParameters();
398
-        $vendorParameters->member_id = self::$firstMemberId;
399
-        $vendorParameters->api_key = Constants::API_KEY;
395
+	public function testRegisterTelematicsVendor() 
396
+	{
397
+		$vendorParameters = new TelematicsVendorParameters();
398
+		$vendorParameters->member_id = self::$firstMemberId;
399
+		$vendorParameters->api_key = Constants::API_KEY;
400 400
         
401
-        $vendors = new TelematicsVendor();
402
-        $result = $vendors->RegisterTelematicsMember($vendorParameters);
401
+		$vendors = new TelematicsVendor();
402
+		$result = $vendors->RegisterTelematicsMember($vendorParameters);
403 403
         
404
-        $this->assertNotNull($result);
405
-        $this->assertInstanceOf(
406
-            TelematicsRegisterMemberResponse::class,
407
-            TelematicsRegisterMemberResponse::fromArray($result)
408
-        );
409
-    }
410
-
411
-    public function testGetTelematicsConnections()
412
-    {
413
-        $teleConnection = new TelematicsConnection();
414
-
415
-        $connections = $teleConnection->getTelematicsConnections(self::$api_token);
416
-
417
-        $this->assertNotNull($connections);
418
-        $this->assertTrue(
419
-            TelematicsConnection::fromArray($connections[0])
420
-            instanceof
421
-            TelematicsConnection);
422
-    }
423
-
424
-    public function testGetTelematicsConnection()
425
-    {
426
-        $teleConnection = new TelematicsConnection();
427
-
428
-        $connection = $teleConnection->getTelematicsConnection(
429
-            self::$api_token,
430
-            self::$createdConnections[sizeof(self::$createdConnections)-1]->connection_token
431
-        );
432
-
433
-        $this->assertNotNull($connection);
434
-        $this->assertTrue(
435
-            TelematicsConnection::fromArray($connection)
436
-            instanceof
437
-            TelematicsConnection);
438
-    }
439
-
440
-    public function testCreateTelematicsConnection()
441
-    {
442
-        $vendorParameters = new TelematicsConnectionParameters();
443
-
444
-        $vendorParameters->vendor_id    = self::$tomtom_vendor->id;
445
-        $vendorParameters->vendor       = self::$tomtom_vendor->slug;
446
-        $vendorParameters->account_id   = '12345';
447
-        $vendorParameters->username     = 'John Doe';
448
-        $vendorParameters->password     = 'password';
449
-        $vendorParameters->vehicle_position_refresh_rate    = 60;
450
-        $vendorParameters->name         = 'Test Telematics Connection from php SDK';
451
-        $vendorParameters->validate_remote_credentials      = 0;
452
-
453
-        $teleConnection = new TelematicsConnection();
454
-
455
-       $result = $teleConnection->createTelematicsConnection(
456
-           self::$api_token,
457
-           $vendorParameters->toArray()
458
-       );
459
-
460
-        $this->assertNotNull($result);
461
-        $this->assertTrue( CreateConnectionResponse::fromArray($result) instanceof CreateConnectionResponse);
462
-
463
-        self::$createdConnections[] = TelematicsConnection::fromArray($result);
464
-    }
465
-
466
-    public function testUpdateTelematicsConnection()
467
-    {
468
-        $teleConParams = new TelematicsConnectionParameters();
469
-
470
-        $teleConParams->vehicle_position_refresh_rate    = 50;
471
-        $teleConParams->name         = 'Test Telematics Connection from php SDK Updated';
472
-        $teleConParams->validate_remote_credentials      = 0;
473
-
474
-        $teleConnection = new TelematicsConnection();
475
-
476
-        $result = $teleConnection->updateTelematicsConnection(
477
-            self::$api_token,
478
-            self::$createdConnections[0]->connection_token,
479
-            $teleConParams->toArray()
480
-        );
481
-
482
-        $this->assertNotNull($result);
483
-        $this->assertTrue(
484
-            TelematicsConnection::fromArray($result)
485
-            instanceof
486
-            TelematicsConnection);
487
-    }
488
-
489
-    public static function tearDownAfterClass()
490
-    {
491
-        if (sizeof(self::$createdConnections)>0) {
492
-
493
-            $teleConn = new TelematicsConnection();
494
-
495
-            foreach (self::$createdConnections as $createdConn) {
496
-                $deleted = $teleConn->deleteTelematicsConnection(
497
-                    self::$api_token,
498
-                    $createdConn->connection_token
499
-                );
500
-            }
501
-        }
502
-    }
404
+		$this->assertNotNull($result);
405
+		$this->assertInstanceOf(
406
+			TelematicsRegisterMemberResponse::class,
407
+			TelematicsRegisterMemberResponse::fromArray($result)
408
+		);
409
+	}
410
+
411
+	public function testGetTelematicsConnections()
412
+	{
413
+		$teleConnection = new TelematicsConnection();
414
+
415
+		$connections = $teleConnection->getTelematicsConnections(self::$api_token);
416
+
417
+		$this->assertNotNull($connections);
418
+		$this->assertTrue(
419
+			TelematicsConnection::fromArray($connections[0])
420
+			instanceof
421
+			TelematicsConnection);
422
+	}
423
+
424
+	public function testGetTelematicsConnection()
425
+	{
426
+		$teleConnection = new TelematicsConnection();
427
+
428
+		$connection = $teleConnection->getTelematicsConnection(
429
+			self::$api_token,
430
+			self::$createdConnections[sizeof(self::$createdConnections)-1]->connection_token
431
+		);
432
+
433
+		$this->assertNotNull($connection);
434
+		$this->assertTrue(
435
+			TelematicsConnection::fromArray($connection)
436
+			instanceof
437
+			TelematicsConnection);
438
+	}
439
+
440
+	public function testCreateTelematicsConnection()
441
+	{
442
+		$vendorParameters = new TelematicsConnectionParameters();
443
+
444
+		$vendorParameters->vendor_id    = self::$tomtom_vendor->id;
445
+		$vendorParameters->vendor       = self::$tomtom_vendor->slug;
446
+		$vendorParameters->account_id   = '12345';
447
+		$vendorParameters->username     = 'John Doe';
448
+		$vendorParameters->password     = 'password';
449
+		$vendorParameters->vehicle_position_refresh_rate    = 60;
450
+		$vendorParameters->name         = 'Test Telematics Connection from php SDK';
451
+		$vendorParameters->validate_remote_credentials      = 0;
452
+
453
+		$teleConnection = new TelematicsConnection();
454
+
455
+	   $result = $teleConnection->createTelematicsConnection(
456
+		   self::$api_token,
457
+		   $vendorParameters->toArray()
458
+	   );
459
+
460
+		$this->assertNotNull($result);
461
+		$this->assertTrue( CreateConnectionResponse::fromArray($result) instanceof CreateConnectionResponse);
462
+
463
+		self::$createdConnections[] = TelematicsConnection::fromArray($result);
464
+	}
465
+
466
+	public function testUpdateTelematicsConnection()
467
+	{
468
+		$teleConParams = new TelematicsConnectionParameters();
469
+
470
+		$teleConParams->vehicle_position_refresh_rate    = 50;
471
+		$teleConParams->name         = 'Test Telematics Connection from php SDK Updated';
472
+		$teleConParams->validate_remote_credentials      = 0;
473
+
474
+		$teleConnection = new TelematicsConnection();
475
+
476
+		$result = $teleConnection->updateTelematicsConnection(
477
+			self::$api_token,
478
+			self::$createdConnections[0]->connection_token,
479
+			$teleConParams->toArray()
480
+		);
481
+
482
+		$this->assertNotNull($result);
483
+		$this->assertTrue(
484
+			TelematicsConnection::fromArray($result)
485
+			instanceof
486
+			TelematicsConnection);
487
+	}
488
+
489
+	public static function tearDownAfterClass()
490
+	{
491
+		if (sizeof(self::$createdConnections)>0) {
492
+
493
+			$teleConn = new TelematicsConnection();
494
+
495
+			foreach (self::$createdConnections as $createdConn) {
496
+				$deleted = $teleConn->deleteTelematicsConnection(
497
+					self::$api_token,
498
+					$createdConn->connection_token
499
+				);
500
+			}
501
+		}
502
+	}
503 503
 
504 504
 }
505 505
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         );
100 100
 
101 101
         self::assertNotNull($result2);
102
-        self::assertTrue( CreateConnectionResponse::fromArray($result2) instanceof CreateConnectionResponse);
102
+        self::assertTrue(CreateConnectionResponse::fromArray($result2) instanceof CreateConnectionResponse);
103 103
 
104 104
         self::$createdConnections[] = TelematicsConnection::fromArray($result2);
105 105
         //endregion
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
     public function testGetAllVendors()
327 327
     {
328
-        $vendorsParameters = TelematicsVendor::fromArray( [ ] );
328
+        $vendorsParameters = TelematicsVendor::fromArray([]);
329 329
 
330 330
         $vendors = new TelematicsVendor();
331 331
         $vendorsResults = $vendors->GetTelematicsVendors($vendorsParameters);
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 
428 428
         $connection = $teleConnection->getTelematicsConnection(
429 429
             self::$api_token,
430
-            self::$createdConnections[sizeof(self::$createdConnections)-1]->connection_token
430
+            self::$createdConnections[sizeof(self::$createdConnections) - 1]->connection_token
431 431
         );
432 432
 
433 433
         $this->assertNotNull($connection);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
        );
459 459
 
460 460
         $this->assertNotNull($result);
461
-        $this->assertTrue( CreateConnectionResponse::fromArray($result) instanceof CreateConnectionResponse);
461
+        $this->assertTrue(CreateConnectionResponse::fromArray($result) instanceof CreateConnectionResponse);
462 462
 
463 463
         self::$createdConnections[] = TelematicsConnection::fromArray($result);
464 464
     }
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
         $teleConParams = new TelematicsConnectionParameters();
469 469
 
470 470
         $teleConParams->vehicle_position_refresh_rate    = 50;
471
-        $teleConParams->name         = 'Test Telematics Connection from php SDK Updated';
471
+        $teleConParams->name = 'Test Telematics Connection from php SDK Updated';
472 472
         $teleConParams->validate_remote_credentials      = 0;
473 473
 
474 474
         $teleConnection = new TelematicsConnection();
Please login to merge, or discard this patch.
UnitTestFiles/Test/MemberConfigurationTest.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -10,187 +10,187 @@
 block discarded – undo
10 10
 
11 11
 class MemberConfigurationTest extends \PHPUnit\Framework\TestCase
12 12
 {
13
-    public static $createdConfigurationKeys;
14
-
15
-    public static function setUpBeforeClass()
16
-    {
17
-        Route4Me::setApiKey(Constants::API_KEY);
13
+	public static $createdConfigurationKeys;
14
+
15
+	public static function setUpBeforeClass()
16
+	{
17
+		Route4Me::setApiKey(Constants::API_KEY);
18 18
 
19
-        $memberConfiguration = new MemberConfiguration();
19
+		$memberConfiguration = new MemberConfiguration();
20 20
 
21
-        $query = [
22
-            'config_key' => 'Test My weight'
23
-        ];
24
-
25
-        $removed = $memberConfiguration->RemoveConfigurationData($query, $errorText);
21
+		$query = [
22
+			'config_key' => 'Test My weight'
23
+		];
24
+
25
+		$removed = $memberConfiguration->RemoveConfigurationData($query, $errorText);
26 26
 
27
-        $memberConfiguration->config_key = 'Test My height';
28
-        $memberConfiguration->config_value = '180';
29
-
30
-        $result = $memberConfiguration->CreateNewConfigurationData($memberConfiguration->toArray(), $errorText);
27
+		$memberConfiguration->config_key = 'Test My height';
28
+		$memberConfiguration->config_value = '180';
29
+
30
+		$result = $memberConfiguration->CreateNewConfigurationData($memberConfiguration->toArray(), $errorText);
31 31
 
32
-        if(isset($result['affected']) && $result['affected']==1) {
33
-            self::$createdConfigurationKeys[] = 'Test My height';
34
-        } else {
35
-            echo "$errorText <br>";
36
-        }
37
-    }
32
+		if(isset($result['affected']) && $result['affected']==1) {
33
+			self::$createdConfigurationKeys[] = 'Test My height';
34
+		} else {
35
+			echo "$errorText <br>";
36
+		}
37
+	}
38 38
 
39
-    public function testConfigurationMemberFromArray()
40
-    {
41
-        $memberConfiguration = MemberConfiguration::fromArray([
42
-            'member_id'     =>  444444,
43
-            'config_key'    =>  'test_key',
44
-            'config_value'  =>  'test_value'
45
-        ]);
39
+	public function testConfigurationMemberFromArray()
40
+	{
41
+		$memberConfiguration = MemberConfiguration::fromArray([
42
+			'member_id'     =>  444444,
43
+			'config_key'    =>  'test_key',
44
+			'config_value'  =>  'test_value'
45
+		]);
46 46
 
47
-        $this->assertEquals($memberConfiguration->member_id, 444444 ,"member_id != 444444");
48
-        $this->assertEquals($memberConfiguration->config_key, 'test_key' ,"config_key != 'test_key'");
49
-        $this->assertEquals($memberConfiguration->config_value, 'test_value' ,"config_value != 'test_value'");
50
-    }
47
+		$this->assertEquals($memberConfiguration->member_id, 444444 ,"member_id != 444444");
48
+		$this->assertEquals($memberConfiguration->config_key, 'test_key' ,"config_key != 'test_key'");
49
+		$this->assertEquals($memberConfiguration->config_value, 'test_value' ,"config_value != 'test_value'");
50
+	}
51 51
 
52
-    public function testToArray()
53
-    {
54
-        $memberConfiguration = MemberConfiguration::fromArray([
55
-            'member_id'     =>  444444,
56
-            'config_key'    =>  'test_key',
57
-            'config_value'  =>  'test_value'
58
-        ]);
52
+	public function testToArray()
53
+	{
54
+		$memberConfiguration = MemberConfiguration::fromArray([
55
+			'member_id'     =>  444444,
56
+			'config_key'    =>  'test_key',
57
+			'config_value'  =>  'test_value'
58
+		]);
59 59
 
60
-        $this->assertEquals($memberConfiguration->toArray(), [
61
-            'member_id'     =>  444444,
62
-            'config_key'    =>  'test_key',
63
-            'config_value'  =>  'test_value'
64
-         ]);
65
-    }
60
+		$this->assertEquals($memberConfiguration->toArray(), [
61
+			'member_id'     =>  444444,
62
+			'config_key'    =>  'test_key',
63
+			'config_value'  =>  'test_value'
64
+		 ]);
65
+	}
66 66
 
67
-    public function testBadParameter()
68
-    {
69
-        $this->expectException(BadParam::class);
67
+	public function testBadParameter()
68
+	{
69
+		$this->expectException(BadParam::class);
70 70
 
71
-        $memberConfiguration = MemberConfiguration::fromArray([
72
-            'memberID'   => 44444444,
73
-            'config_kkk' => 'test_key'
74
-        ]);
71
+		$memberConfiguration = MemberConfiguration::fromArray([
72
+			'memberID'   => 44444444,
73
+			'config_kkk' => 'test_key'
74
+		]);
75 75
 
76
-        echo "memberConfiguration: ".$memberConfiguration->memberID." <br>";
77
-    }
76
+		echo "memberConfiguration: ".$memberConfiguration->memberID." <br>";
77
+	}
78 78
 
79
-    public function testGetAllConfigurationData()
80
-    {
81
-        $memberConfiguration = new MemberConfiguration();
79
+	public function testGetAllConfigurationData()
80
+	{
81
+		$memberConfiguration = new MemberConfiguration();
82 82
 
83
-        $result = $memberConfiguration->GetConfigurationData();
84
-
85
-        $this->assertNotNull($result);
86
-        $this->assertTrue(isset($result['result']), "Wrong response for member configuration data.");
87
-        $this->assertEquals($result['result'], "OK", "Cannot retrieve the member configuration data.");
88
-    }
83
+		$result = $memberConfiguration->GetConfigurationData();
84
+
85
+		$this->assertNotNull($result);
86
+		$this->assertTrue(isset($result['result']), "Wrong response for member configuration data.");
87
+		$this->assertEquals($result['result'], "OK", "Cannot retrieve the member configuration data.");
88
+	}
89 89
 
90
-    public function testGetSpecificConfigurationKeyData()
91
-    {
92
-        $memberConfiguration = new MemberConfiguration();
93
-
94
-        $allData = $memberConfiguration->GetConfigurationData();
95
-
96
-        $this->assertNotNull($allData);
97
-        $this->assertTrue(isset($allData['data']), "Wrong response for member configuration data.");
98
-        $this->assertTrue(sizeof($allData['data'])>0, "Retrieved member data size <1");
99
-
100
-        $query = [
101
-            'config_key' => $allData['data'][0]['config_key']
102
-        ];
103
-
104
-        $result = $memberConfiguration->GetConfigurationData($query);
105
-
106
-        $this->assertNotNull($result);
107
-        $this->assertTrue(isset($result['data']), "Wrong response for member configuration data.");
108
-        $this->assertTrue(sizeof($result['data'])==1, "Retrieved member data size != 1");
109
-        $this->assertEquals($result['data'][0]['config_key'], $allData['data'][0]['config_key']);
110
-    }
111
-
112
-    public function testCreateConfigurationData()
113
-    {
114
-        $memberConfiguration = new MemberConfiguration();
115
-
116
-        $memberConfiguration->config_key = 'Test My weight';
117
-        $memberConfiguration->config_value = '100';
118
-
119
-        $result = $memberConfiguration->CreateNewConfigurationData($memberConfiguration->toArray(), $errorText);
120
-
121
-        $this->assertNotNull($result);
122
-        $this->assertTrue(isset($result['result']), "Wrong response for member configuration data.");
123
-        $this->assertTrue(isset($result['affected']), "Wrong response for member configuration data.");
124
-        $this->assertEquals(1, $result['affected'], "Cannot create new member configuration data <br> $errorText");
125
-
126
-        if($result['affected']==1) {
127
-            self::$createdConfigurationKeys[] = 'Test My weight';
128
-        }
129
-    }
130
-
131
-    public function testUpdateConfigurationData()
132
-    {
133
-        $memberConfiguration = new MemberConfiguration();
134
-
135
-        $memberConfiguration->config_key = 'Test My height';
136
-        $memberConfiguration->config_value = '120';
137
-
138
-        $result = $memberConfiguration->UpdateConfigurationData($memberConfiguration->toArray(), $errorText);
139
-
140
-        $this->assertNotNull($result);
141
-        $this->assertTrue(isset($result['result']), "Wrong response for member configuration data.");
142
-        $this->assertTrue(isset($result['affected']), "Wrong response for member configuration data.");
143
-        $this->assertEquals(1, $result['affected'], "Cannot update member configuration data <br> $errorText");
144
-
145
-        $query = [
146
-            'config_key' => 'Test My height'
147
-        ];
148
-
149
-        $updatedResult = $memberConfiguration->GetConfigurationData($query);
150
-
151
-        $this->assertNotNull($updatedResult);
152
-        $this->assertTrue(isset($updatedResult['data']), "Wrong response for member configuration data.");
153
-        $this->assertTrue(sizeof($updatedResult['data'])==1, "Retrieved member data size != 1");
154
-        $this->assertEquals('120', $updatedResult['data'][0]['config_value'], "The config value is not updated");
155
-    }
156
-
157
-    public function testRemoveConfigurationData()
158
-    {
159
-        $memberConfiguration = new MemberConfiguration();
160
-
161
-        $query = [
162
-            'config_key' => 'Test My height'
163
-        ];
90
+	public function testGetSpecificConfigurationKeyData()
91
+	{
92
+		$memberConfiguration = new MemberConfiguration();
93
+
94
+		$allData = $memberConfiguration->GetConfigurationData();
95
+
96
+		$this->assertNotNull($allData);
97
+		$this->assertTrue(isset($allData['data']), "Wrong response for member configuration data.");
98
+		$this->assertTrue(sizeof($allData['data'])>0, "Retrieved member data size <1");
99
+
100
+		$query = [
101
+			'config_key' => $allData['data'][0]['config_key']
102
+		];
103
+
104
+		$result = $memberConfiguration->GetConfigurationData($query);
105
+
106
+		$this->assertNotNull($result);
107
+		$this->assertTrue(isset($result['data']), "Wrong response for member configuration data.");
108
+		$this->assertTrue(sizeof($result['data'])==1, "Retrieved member data size != 1");
109
+		$this->assertEquals($result['data'][0]['config_key'], $allData['data'][0]['config_key']);
110
+	}
111
+
112
+	public function testCreateConfigurationData()
113
+	{
114
+		$memberConfiguration = new MemberConfiguration();
115
+
116
+		$memberConfiguration->config_key = 'Test My weight';
117
+		$memberConfiguration->config_value = '100';
118
+
119
+		$result = $memberConfiguration->CreateNewConfigurationData($memberConfiguration->toArray(), $errorText);
120
+
121
+		$this->assertNotNull($result);
122
+		$this->assertTrue(isset($result['result']), "Wrong response for member configuration data.");
123
+		$this->assertTrue(isset($result['affected']), "Wrong response for member configuration data.");
124
+		$this->assertEquals(1, $result['affected'], "Cannot create new member configuration data <br> $errorText");
125
+
126
+		if($result['affected']==1) {
127
+			self::$createdConfigurationKeys[] = 'Test My weight';
128
+		}
129
+	}
130
+
131
+	public function testUpdateConfigurationData()
132
+	{
133
+		$memberConfiguration = new MemberConfiguration();
134
+
135
+		$memberConfiguration->config_key = 'Test My height';
136
+		$memberConfiguration->config_value = '120';
137
+
138
+		$result = $memberConfiguration->UpdateConfigurationData($memberConfiguration->toArray(), $errorText);
139
+
140
+		$this->assertNotNull($result);
141
+		$this->assertTrue(isset($result['result']), "Wrong response for member configuration data.");
142
+		$this->assertTrue(isset($result['affected']), "Wrong response for member configuration data.");
143
+		$this->assertEquals(1, $result['affected'], "Cannot update member configuration data <br> $errorText");
144
+
145
+		$query = [
146
+			'config_key' => 'Test My height'
147
+		];
148
+
149
+		$updatedResult = $memberConfiguration->GetConfigurationData($query);
150
+
151
+		$this->assertNotNull($updatedResult);
152
+		$this->assertTrue(isset($updatedResult['data']), "Wrong response for member configuration data.");
153
+		$this->assertTrue(sizeof($updatedResult['data'])==1, "Retrieved member data size != 1");
154
+		$this->assertEquals('120', $updatedResult['data'][0]['config_value'], "The config value is not updated");
155
+	}
156
+
157
+	public function testRemoveConfigurationData()
158
+	{
159
+		$memberConfiguration = new MemberConfiguration();
160
+
161
+		$query = [
162
+			'config_key' => 'Test My height'
163
+		];
164 164
 
165
-        $removed = $memberConfiguration->RemoveConfigurationData($query, $errorText);
165
+		$removed = $memberConfiguration->RemoveConfigurationData($query, $errorText);
166 166
 
167
-        echo (isset($removed['affected']) && $removed['affected']==1)
168
-            ? "The config data with key 'Test My height' removed"
169
-            : "The config data with key 'Test My height' cannot remove - ".$errorText;
167
+		echo (isset($removed['affected']) && $removed['affected']==1)
168
+			? "The config data with key 'Test My height' removed"
169
+			: "The config data with key 'Test My height' cannot remove - ".$errorText;
170 170
 
171
-        $this->assertNotNull($removed);
172
-        $this->assertTrue(isset($removed['result']), "Wrong response for member configuration data.");
173
-        $this->assertTrue(isset($removed['affected']), "Wrong response for member configuration data.");
174
-        $this->assertEquals(1, $removed['affected'], "Cannot create new member configuration data");
171
+		$this->assertNotNull($removed);
172
+		$this->assertTrue(isset($removed['result']), "Wrong response for member configuration data.");
173
+		$this->assertTrue(isset($removed['affected']), "Wrong response for member configuration data.");
174
+		$this->assertEquals(1, $removed['affected'], "Cannot create new member configuration data");
175 175
 
176
-        if($removed['affected']==1) {
177
-            $key = array_search('Test My height', self::$createdConfigurationKeys);
178
-            array_splice(self::$createdConfigurationKeys, $key, 1);
179
-        }
180
-    }
176
+		if($removed['affected']==1) {
177
+			$key = array_search('Test My height', self::$createdConfigurationKeys);
178
+			array_splice(self::$createdConfigurationKeys, $key, 1);
179
+		}
180
+	}
181 181
 
182
-    public static function tearDownAfterClass()
183
-    {
184
-        $memberConfiguration = new MemberConfiguration();
182
+	public static function tearDownAfterClass()
183
+	{
184
+		$memberConfiguration = new MemberConfiguration();
185 185
 
186
-        if (sizeof(self::$createdConfigurationKeys)>0) {
187
-            foreach (self::$createdConfigurationKeys as $configKey) {
188
-                $removed = $memberConfiguration->RemoveConfigurationData(['config_key' => $configKey], $errorText);
186
+		if (sizeof(self::$createdConfigurationKeys)>0) {
187
+			foreach (self::$createdConfigurationKeys as $configKey) {
188
+				$removed = $memberConfiguration->RemoveConfigurationData(['config_key' => $configKey], $errorText);
189 189
 
190
-                echo (isset($removed['affected']) && $removed['affected']==1)
191
-                            ? "The config data with key '$configKey' removed"
192
-                            : "The config data with key '$configKey' cannot remove - ".$errorText;
193
-            }
194
-        }
195
-    }
190
+				echo (isset($removed['affected']) && $removed['affected']==1)
191
+							? "The config data with key '$configKey' removed"
192
+							: "The config data with key '$configKey' cannot remove - ".$errorText;
193
+			}
194
+		}
195
+	}
196 196
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
         $result = $memberConfiguration->CreateNewConfigurationData($memberConfiguration->toArray(), $errorText);
31 31
 
32
-        if(isset($result['affected']) && $result['affected']==1) {
32
+        if (isset($result['affected']) && $result['affected']==1) {
33 33
             self::$createdConfigurationKeys[] = 'Test My height';
34 34
         } else {
35 35
             echo "$errorText <br>";
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
             'config_value'  =>  'test_value'
45 45
         ]);
46 46
 
47
-        $this->assertEquals($memberConfiguration->member_id, 444444 ,"member_id != 444444");
48
-        $this->assertEquals($memberConfiguration->config_key, 'test_key' ,"config_key != 'test_key'");
49
-        $this->assertEquals($memberConfiguration->config_value, 'test_value' ,"config_value != 'test_value'");
47
+        $this->assertEquals($memberConfiguration->member_id, 444444, "member_id != 444444");
48
+        $this->assertEquals($memberConfiguration->config_key, 'test_key', "config_key != 'test_key'");
49
+        $this->assertEquals($memberConfiguration->config_value, 'test_value', "config_value != 'test_value'");
50 50
     }
51 51
 
52 52
     public function testToArray()
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         $this->assertTrue(isset($result['affected']), "Wrong response for member configuration data.");
124 124
         $this->assertEquals(1, $result['affected'], "Cannot create new member configuration data <br> $errorText");
125 125
 
126
-        if($result['affected']==1) {
126
+        if ($result['affected']==1) {
127 127
             self::$createdConfigurationKeys[] = 'Test My weight';
128 128
         }
129 129
     }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         $this->assertTrue(isset($removed['affected']), "Wrong response for member configuration data.");
174 174
         $this->assertEquals(1, $removed['affected'], "Cannot create new member configuration data");
175 175
 
176
-        if($removed['affected']==1) {
176
+        if ($removed['affected']==1) {
177 177
             $key = array_search('Test My height', self::$createdConfigurationKeys);
178 178
             array_splice(self::$createdConfigurationKeys, $key, 1);
179 179
         }
Please login to merge, or discard this patch.
UnitTestFiles/Test/CustomNoteTypeResponseUnitTests.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
 
7 7
 class CustomNoteTypeResponseUnitTests extends \PHPUnit\Framework\TestCase
8 8
 {
9
-    public function testFromArray()
10
-    {
11
-        $customNoteTypeResponse = CustomNoteTypeResponse::fromArray([
12
-            'note_custom_type_id'       => 10,
13
-            'note_custom_type'          => 'Dropoff Location',
14
-            'root_owner_member_id'      => 1,
15
-            'note_custom_type_values'   => [
16
-                'Front door',
17
-                'Backdoor',
18
-                'Roof'
19
-            ]
20
-        ]);
9
+	public function testFromArray()
10
+	{
11
+		$customNoteTypeResponse = CustomNoteTypeResponse::fromArray([
12
+			'note_custom_type_id'       => 10,
13
+			'note_custom_type'          => 'Dropoff Location',
14
+			'root_owner_member_id'      => 1,
15
+			'note_custom_type_values'   => [
16
+				'Front door',
17
+				'Backdoor',
18
+				'Roof'
19
+			]
20
+		]);
21 21
 
22
-        $this->assertEquals(10, $customNoteTypeResponse->note_custom_type_id);
23
-        $this->assertEquals('Dropoff Location', $customNoteTypeResponse->note_custom_type);
24
-        $this->assertEquals(1, $customNoteTypeResponse->root_owner_member_id);
25
-        $this->assertEquals([
26
-                'Front door',
27
-                'Backdoor',
28
-                'Roof'
29
-            ],
30
-            $customNoteTypeResponse->note_custom_type_values);
31
-    }
22
+		$this->assertEquals(10, $customNoteTypeResponse->note_custom_type_id);
23
+		$this->assertEquals('Dropoff Location', $customNoteTypeResponse->note_custom_type);
24
+		$this->assertEquals(1, $customNoteTypeResponse->root_owner_member_id);
25
+		$this->assertEquals([
26
+				'Front door',
27
+				'Backdoor',
28
+				'Roof'
29
+			],
30
+			$customNoteTypeResponse->note_custom_type_values);
31
+	}
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
UnitTestFiles/Test/GeocodingResponseUnitTests.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@
 block discarded – undo
6 6
 
7 7
 class GeocodingResponseUnitTests extends \PHPUnit\Framework\TestCase
8 8
 {
9
-    public function testFromArray()
10
-    {
11
-        $geocodingResponse = GeocodingResponse::fromArray([
12
-            'address'       =>  'Los Angeles International Airport (LAX), 1 World Way, Los Angeles, CA 90045, USA',
13
-            'lat'           =>  33.9415889,
14
-            'lng'           =>  -118.40853,
15
-            'type'          =>  'airport, establishment, point_of_interest',
16
-            'confidence'    =>  'medium',
17
-            'original'      =>  'Los%20Angeles%20International%20Airport,%20CA'
18
-        ]);
9
+	public function testFromArray()
10
+	{
11
+		$geocodingResponse = GeocodingResponse::fromArray([
12
+			'address'       =>  'Los Angeles International Airport (LAX), 1 World Way, Los Angeles, CA 90045, USA',
13
+			'lat'           =>  33.9415889,
14
+			'lng'           =>  -118.40853,
15
+			'type'          =>  'airport, establishment, point_of_interest',
16
+			'confidence'    =>  'medium',
17
+			'original'      =>  'Los%20Angeles%20International%20Airport,%20CA'
18
+		]);
19 19
 
20
-        $this->assertEquals('Los Angeles International Airport (LAX), 1 World Way, Los Angeles, CA 90045, USA', $geocodingResponse->address);
21
-        $this->assertEquals(33.9415889, $geocodingResponse->lat);
22
-        $this->assertEquals(-118.40853, $geocodingResponse->lng);
23
-        $this->assertEquals('airport, establishment, point_of_interest', $geocodingResponse->type);
24
-        $this->assertEquals('medium', $geocodingResponse->confidence);
25
-        $this->assertEquals('Los%20Angeles%20International%20Airport,%20CA', $geocodingResponse->original);
26
-    }
20
+		$this->assertEquals('Los Angeles International Airport (LAX), 1 World Way, Los Angeles, CA 90045, USA', $geocodingResponse->address);
21
+		$this->assertEquals(33.9415889, $geocodingResponse->lat);
22
+		$this->assertEquals(-118.40853, $geocodingResponse->lng);
23
+		$this->assertEquals('airport, establishment, point_of_interest', $geocodingResponse->type);
24
+		$this->assertEquals('medium', $geocodingResponse->confidence);
25
+		$this->assertEquals('Los%20Angeles%20International%20Airport,%20CA', $geocodingResponse->original);
26
+	}
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
UnitTestFiles/Test/OptimizationProblemParamsUnitTests.php 2 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -9,212 +9,212 @@
 block discarded – undo
9 9
 
10 10
 class OptimizationProblemParamsUnitTests extends \PHPUnit\Framework\TestCase
11 11
 {
12
-    public static $routeParameters = null;
13
-    public static $addresses = [];
14
-
15
-    public static function setUpBeforeClass()
16
-    {
17
-        //region Addresses
18
-        self::$addresses[] = Address::fromArray([
19
-            'address'           => '11497 Columbia Park Dr W, Jacksonville, FL 32258',
20
-            'is_depot'          => true,
21
-            'lat'               => 30.159341812134,
22
-            'lng'               => -81.538619995117,
23
-            'time'              => 300,
24
-            'time_window_start' => 28800,
25
-            'time_window_end'   => 32400,
26
-        ]);
27
-
28
-        self::$addresses[] = Address::fromArray([
29
-            'address'           => '214 Edgewater Branch Drive 32259',
30
-            'lat'               => 30.103567123413,
31
-            'lng'               => -81.595352172852,
32
-            'time'              => 300,
33
-            'time_window_start' => 36000,
34
-            'time_window_end'   => 37200,
35
-        ]);
36
-
37
-        self::$addresses[] = Address::fromArray([
38
-            'address'           => '756 eagle point dr 32092',
39
-            'lat'               => 30.046422958374,
40
-            'lng'               => -81.508758544922,
41
-            'time'              => 300,
42
-            'time_window_start' => 39600,
43
-            'time_window_end'   => 41400,
44
-        ]);
45
-        //endregion
46
-
47
-        self::$routeParameters = RouteParameters::fromArray([
48
-            'is_upload'                 => false,
49
-            'rt'                        => false,
50
-            'route_name'                => 'Saturday 25th of July 2020 04 => 00 => 00 AM UTC',
51
-            'route_date'                => 1595635200,
52
-            'route_time'                => 25200,
53
-            'disable_optimization'      => false,
54
-            'optimize'                  => 'Time',
55
-            'lock_last'                 => false,
56
-            'vehicle_capacity'          => null,
57
-            'vehicle_max_cargo_weight'  => null,
58
-            'vehicle_max_cargo_volume'  => null,
59
-            'vehicle_max_distance_mi'   => null,
60
-            'subtour_max_revenue'       => null,
61
-            'distance_unit'             => 'mi',
62
-            'travel_mode'               => 'Driving',
63
-            'avoid'                     => '',
64
-            'avoidance_zones'           => [],
65
-            'vehicle_id'                => null,
66
-            'driver_id'                 => null,
67
-            'dev_lat'                   => null,
68
-            'dev_lng'                   => null,
69
-            'route_max_duration'        => 86399,
70
-            'route_email'               => null,
71
-            'store_route'               => true,
72
-            'metric'                    => 4,
73
-            'algorithm_type'            => 1,
74
-            'member_id'                 => 444333,
75
-            'ip'                        => 199911333,
76
-            'dm'                        => 12,
77
-            'dirm'                      => 10,
78
-            'parts'                     => 10,
79
-            'parts_min'                 => 1,
80
-            'device_id'                 => null,
81
-            'device_type'               => 'web',
82
-            'first_drive_then_wait_between_stops' => false,
83
-            'has_trailer'               => false,
84
-            'trailer_weight_t'          => null,
85
-            'limited_weight_t'          => null,
86
-            'weight_per_axle_t'         => null,
87
-            'truck_height'              => null,
88
-            'truck_width'               => null,
89
-            'truck_length'              => null,
90
-            'truck_hazardous_goods'     => '',
91
-            'truck_axles'               => 0,
92
-            'truck_toll_road_usage'     => null,
93
-            'truck_avoid_ferries'       => null,
94
-            'truck_hwy_only'            => null,
95
-            'truck_lcv'                 => null,
96
-            'truck_borders'             => null,
97
-            'truck_side_street_adherence' => null,
98
-            'truck_config'              => null,
99
-            'truck_dim_unit'            => null,
100
-            'truck_type'                => null,
101
-            'truck_weight'              => 0,
102
-            'optimization_quality'      => 1,
103
-            'override_addresses'        => [],
104
-            'max_tour_size'             => null,
105
-            'min_tour_size'             => 0,
106
-            'uturn'                     => 1,
107
-            'leftturn'                  => 1,
108
-            'rightturn'                 => 1,
109
-            'route_time_multiplier'     => null,
110
-            'route_service_time_multiplier' => null,
111
-            'optimization_engine'       => '2',
112
-            'is_dynamic_start_time'     => false
113
-        ]);
114
-    }
115
-
116
-    public function testFromArray()
117
-    {
118
-        $routeParams = self::$routeParameters;
119
-        $optParams = OptimizationProblemParams::fromArray([
120
-            'addresses'     => self::$addresses,
121
-            'parameters'    => $routeParams
122
-        ]);
123
-
124
-        $this->assertNotNull($optParams);
125
-        $this->assertContainsOnlyInstancesOf(OptimizationProblemParams::class, [$optParams]);
126
-    }
127
-
128
-    public function testWithoutParameters()
129
-    {
130
-        $this->expectException(BadParam::class);
131
-
132
-        OptimizationProblemParams::fromArray([
133
-            'addresses' => self::$addresses,
134
-        ]);
135
-    }
136
-
137
-    public function testRedefineRedirectParam()
138
-    {
139
-        $optimizationParameters = OptimizationProblemParams::fromArray([
140
-            'addresses'     => self::$addresses,
141
-            'parameters'    => self::$routeParameters,
142
-            'redirect'      => false,
143
-        ]);
144
-
145
-        $this->assertObjectHasAttribute('redirect', $optimizationParameters);
146
-        $this->assertFalse($optimizationParameters->redirect);
147
-    }
148
-
149
-    public function testSetParameters()
150
-    {
151
-        $optimizationParameters = new OptimizationProblemParams();
152
-
153
-        $optimizationParameters->parameters = self::$routeParameters;
154
-
155
-        $this->assertObjectHasAttribute('parameters', $optimizationParameters);
156
-    }
157
-
158
-    public function testAddAddress()
159
-    {
160
-        $optimizationParameters = new OptimizationProblemParams();
161
-
162
-        $optimizationParameters->addAddress(self::$addresses[0]);
163
-
164
-        $address = $optimizationParameters->addresses[0];
165
-
166
-        $this->assertContainsOnlyInstancesOf(Address::class, [$address]);
167
-        $this->assertEquals(self::$addresses[0],$optimizationParameters->addresses[0]);
168
-    }
169
-
170
-    public function testGetAddressesArray()
171
-    {
172
-        $optimizationParameters = new OptimizationProblemParams();
173
-
174
-        $optimizationParameters->addresses = self::$addresses;
175
-
176
-        $addresses = $optimizationParameters->getAddressesArray();
177
-
178
-        $firstAddress = Address::fromArray(
179
-            $addresses[0]
180
-        );
181
-
182
-        $this->assertNotNull($addresses);
183
-        $this->assertTrue(sizeof($addresses)>0);
184
-        $this->assertContainsOnlyInstancesOf(Address::class, [$firstAddress]);
185
-    }
186
-
187
-    public function testGetParametersArray()
188
-    {
189
-        $optimizationParameters = new OptimizationProblemParams();
190
-
191
-        $optimizationParameters->parameters = self::$routeParameters;
192
-
193
-        $routeParameters = RouteParameters::fromArray(
194
-            $optimizationParameters->getParametersArray()
195
-        );
196
-
197
-        $this->assertNotNull($optimizationParameters);
198
-        $this->assertContainsOnlyInstancesOf(RouteParameters::class, [$routeParameters]);
199
-    }
200
-
201
-    public function testSetAddresses()
202
-    {
203
-        $optimizationParameters = new OptimizationProblemParams();
12
+	public static $routeParameters = null;
13
+	public static $addresses = [];
14
+
15
+	public static function setUpBeforeClass()
16
+	{
17
+		//region Addresses
18
+		self::$addresses[] = Address::fromArray([
19
+			'address'           => '11497 Columbia Park Dr W, Jacksonville, FL 32258',
20
+			'is_depot'          => true,
21
+			'lat'               => 30.159341812134,
22
+			'lng'               => -81.538619995117,
23
+			'time'              => 300,
24
+			'time_window_start' => 28800,
25
+			'time_window_end'   => 32400,
26
+		]);
27
+
28
+		self::$addresses[] = Address::fromArray([
29
+			'address'           => '214 Edgewater Branch Drive 32259',
30
+			'lat'               => 30.103567123413,
31
+			'lng'               => -81.595352172852,
32
+			'time'              => 300,
33
+			'time_window_start' => 36000,
34
+			'time_window_end'   => 37200,
35
+		]);
36
+
37
+		self::$addresses[] = Address::fromArray([
38
+			'address'           => '756 eagle point dr 32092',
39
+			'lat'               => 30.046422958374,
40
+			'lng'               => -81.508758544922,
41
+			'time'              => 300,
42
+			'time_window_start' => 39600,
43
+			'time_window_end'   => 41400,
44
+		]);
45
+		//endregion
46
+
47
+		self::$routeParameters = RouteParameters::fromArray([
48
+			'is_upload'                 => false,
49
+			'rt'                        => false,
50
+			'route_name'                => 'Saturday 25th of July 2020 04 => 00 => 00 AM UTC',
51
+			'route_date'                => 1595635200,
52
+			'route_time'                => 25200,
53
+			'disable_optimization'      => false,
54
+			'optimize'                  => 'Time',
55
+			'lock_last'                 => false,
56
+			'vehicle_capacity'          => null,
57
+			'vehicle_max_cargo_weight'  => null,
58
+			'vehicle_max_cargo_volume'  => null,
59
+			'vehicle_max_distance_mi'   => null,
60
+			'subtour_max_revenue'       => null,
61
+			'distance_unit'             => 'mi',
62
+			'travel_mode'               => 'Driving',
63
+			'avoid'                     => '',
64
+			'avoidance_zones'           => [],
65
+			'vehicle_id'                => null,
66
+			'driver_id'                 => null,
67
+			'dev_lat'                   => null,
68
+			'dev_lng'                   => null,
69
+			'route_max_duration'        => 86399,
70
+			'route_email'               => null,
71
+			'store_route'               => true,
72
+			'metric'                    => 4,
73
+			'algorithm_type'            => 1,
74
+			'member_id'                 => 444333,
75
+			'ip'                        => 199911333,
76
+			'dm'                        => 12,
77
+			'dirm'                      => 10,
78
+			'parts'                     => 10,
79
+			'parts_min'                 => 1,
80
+			'device_id'                 => null,
81
+			'device_type'               => 'web',
82
+			'first_drive_then_wait_between_stops' => false,
83
+			'has_trailer'               => false,
84
+			'trailer_weight_t'          => null,
85
+			'limited_weight_t'          => null,
86
+			'weight_per_axle_t'         => null,
87
+			'truck_height'              => null,
88
+			'truck_width'               => null,
89
+			'truck_length'              => null,
90
+			'truck_hazardous_goods'     => '',
91
+			'truck_axles'               => 0,
92
+			'truck_toll_road_usage'     => null,
93
+			'truck_avoid_ferries'       => null,
94
+			'truck_hwy_only'            => null,
95
+			'truck_lcv'                 => null,
96
+			'truck_borders'             => null,
97
+			'truck_side_street_adherence' => null,
98
+			'truck_config'              => null,
99
+			'truck_dim_unit'            => null,
100
+			'truck_type'                => null,
101
+			'truck_weight'              => 0,
102
+			'optimization_quality'      => 1,
103
+			'override_addresses'        => [],
104
+			'max_tour_size'             => null,
105
+			'min_tour_size'             => 0,
106
+			'uturn'                     => 1,
107
+			'leftturn'                  => 1,
108
+			'rightturn'                 => 1,
109
+			'route_time_multiplier'     => null,
110
+			'route_service_time_multiplier' => null,
111
+			'optimization_engine'       => '2',
112
+			'is_dynamic_start_time'     => false
113
+		]);
114
+	}
115
+
116
+	public function testFromArray()
117
+	{
118
+		$routeParams = self::$routeParameters;
119
+		$optParams = OptimizationProblemParams::fromArray([
120
+			'addresses'     => self::$addresses,
121
+			'parameters'    => $routeParams
122
+		]);
123
+
124
+		$this->assertNotNull($optParams);
125
+		$this->assertContainsOnlyInstancesOf(OptimizationProblemParams::class, [$optParams]);
126
+	}
127
+
128
+	public function testWithoutParameters()
129
+	{
130
+		$this->expectException(BadParam::class);
131
+
132
+		OptimizationProblemParams::fromArray([
133
+			'addresses' => self::$addresses,
134
+		]);
135
+	}
136
+
137
+	public function testRedefineRedirectParam()
138
+	{
139
+		$optimizationParameters = OptimizationProblemParams::fromArray([
140
+			'addresses'     => self::$addresses,
141
+			'parameters'    => self::$routeParameters,
142
+			'redirect'      => false,
143
+		]);
144
+
145
+		$this->assertObjectHasAttribute('redirect', $optimizationParameters);
146
+		$this->assertFalse($optimizationParameters->redirect);
147
+	}
148
+
149
+	public function testSetParameters()
150
+	{
151
+		$optimizationParameters = new OptimizationProblemParams();
152
+
153
+		$optimizationParameters->parameters = self::$routeParameters;
154
+
155
+		$this->assertObjectHasAttribute('parameters', $optimizationParameters);
156
+	}
157
+
158
+	public function testAddAddress()
159
+	{
160
+		$optimizationParameters = new OptimizationProblemParams();
161
+
162
+		$optimizationParameters->addAddress(self::$addresses[0]);
163
+
164
+		$address = $optimizationParameters->addresses[0];
165
+
166
+		$this->assertContainsOnlyInstancesOf(Address::class, [$address]);
167
+		$this->assertEquals(self::$addresses[0],$optimizationParameters->addresses[0]);
168
+	}
169
+
170
+	public function testGetAddressesArray()
171
+	{
172
+		$optimizationParameters = new OptimizationProblemParams();
173
+
174
+		$optimizationParameters->addresses = self::$addresses;
175
+
176
+		$addresses = $optimizationParameters->getAddressesArray();
177
+
178
+		$firstAddress = Address::fromArray(
179
+			$addresses[0]
180
+		);
181
+
182
+		$this->assertNotNull($addresses);
183
+		$this->assertTrue(sizeof($addresses)>0);
184
+		$this->assertContainsOnlyInstancesOf(Address::class, [$firstAddress]);
185
+	}
186
+
187
+	public function testGetParametersArray()
188
+	{
189
+		$optimizationParameters = new OptimizationProblemParams();
190
+
191
+		$optimizationParameters->parameters = self::$routeParameters;
192
+
193
+		$routeParameters = RouteParameters::fromArray(
194
+			$optimizationParameters->getParametersArray()
195
+		);
196
+
197
+		$this->assertNotNull($optimizationParameters);
198
+		$this->assertContainsOnlyInstancesOf(RouteParameters::class, [$routeParameters]);
199
+	}
200
+
201
+	public function testSetAddresses()
202
+	{
203
+		$optimizationParameters = new OptimizationProblemParams();
204 204
 
205
-        $optimizationParameters->setAddresses(self::$addresses);
205
+		$optimizationParameters->setAddresses(self::$addresses);
206 206
 
207
-        $this->assertEquals(self::$addresses,$optimizationParameters->addresses);
207
+		$this->assertEquals(self::$addresses,$optimizationParameters->addresses);
208 208
 
209
-        $address = $optimizationParameters->addresses[0];
209
+		$address = $optimizationParameters->addresses[0];
210 210
 
211
-        $this->assertContainsOnlyInstancesOf(Address::class, [$address]);
211
+		$this->assertContainsOnlyInstancesOf(Address::class, [$address]);
212 212
 
213
-    }
213
+	}
214 214
 
215
-    public static function tearDownAfterClass()
216
-    {
217
-        self::$addresses[] = null;
218
-        self::$routeParameters = null;
219
-    }
215
+	public static function tearDownAfterClass()
216
+	{
217
+		self::$addresses[] = null;
218
+		self::$routeParameters = null;
219
+	}
220 220
 }
221 221
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         $address = $optimizationParameters->addresses[0];
165 165
 
166 166
         $this->assertContainsOnlyInstancesOf(Address::class, [$address]);
167
-        $this->assertEquals(self::$addresses[0],$optimizationParameters->addresses[0]);
167
+        $this->assertEquals(self::$addresses[0], $optimizationParameters->addresses[0]);
168 168
     }
169 169
 
170 170
     public function testGetAddressesArray()
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
         $optimizationParameters->setAddresses(self::$addresses);
206 206
 
207
-        $this->assertEquals(self::$addresses,$optimizationParameters->addresses);
207
+        $this->assertEquals(self::$addresses, $optimizationParameters->addresses);
208 208
 
209 209
         $address = $optimizationParameters->addresses[0];
210 210
 
Please login to merge, or discard this patch.