1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: babi |
5
|
|
|
* Date: 13/6/20 |
6
|
|
|
* Time: 11:35 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Tests; |
10
|
|
|
|
11
|
|
|
use Someshwer\WorldCountries\Facades\World; |
12
|
|
|
|
13
|
|
|
class TestLibrary extends TestCase |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** @test */ |
17
|
|
|
public function testCountries() |
18
|
|
|
{ |
19
|
|
|
// Arrange |
20
|
|
|
$countries = World::countries(); |
|
|
|
|
21
|
|
|
|
22
|
|
|
// Assert |
23
|
|
|
$this->assertGreaterThan(count($countries), 200); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** @test */ |
27
|
|
|
public function testSearchCountry() |
28
|
|
|
{ |
29
|
|
|
// Arrange |
30
|
|
|
$country = World::searchCountry('india'); |
|
|
|
|
31
|
|
|
|
32
|
|
|
// Assert |
33
|
|
|
$this->assertEquals(count($country) , 1); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** @test */ |
37
|
|
|
public function testCurrencies() |
38
|
|
|
{ |
39
|
|
|
// Arrange |
40
|
|
|
$currencies = World::currencies(); |
|
|
|
|
41
|
|
|
|
42
|
|
|
// Assert |
43
|
|
|
$this->assertGreaterThan(30, count($currencies)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** @test */ |
47
|
|
|
public function testSearchCurrency() |
48
|
|
|
{ |
49
|
|
|
// Arrange |
50
|
|
|
$currencies = World::searchCurrency('I'); |
|
|
|
|
51
|
|
|
|
52
|
|
|
// Assert |
53
|
|
|
$this->assertGreaterThan(2, count($currencies)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** @test */ |
57
|
|
|
public function testCurrencyByCountryName() |
58
|
|
|
{ |
59
|
|
|
// Arrange |
60
|
|
|
$currency = World::currencyByCountryName('India'); |
|
|
|
|
61
|
|
|
|
62
|
|
|
// Assert |
63
|
|
|
$this->assertEquals(1, count($currency)); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** @test */ |
67
|
|
|
public function testCurrencyByCountryCode() |
68
|
|
|
{ |
69
|
|
|
// Arrange |
70
|
|
|
$currency = World::currencyByCountryCode('AF'); |
|
|
|
|
71
|
|
|
|
72
|
|
|
// Assert |
73
|
|
|
$this->assertGreaterThan(0, count($currency)); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** @test */ |
77
|
|
|
public function testCurrencyByCurrencyName() |
78
|
|
|
{ |
79
|
|
|
// Arrange |
80
|
|
|
$currency = World::currencyByCurrencyName('Dollar'); |
|
|
|
|
81
|
|
|
|
82
|
|
|
// Assert |
83
|
|
|
$this->assertGreaterThan(20, count($currency)); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** @test */ |
87
|
|
|
public function testCurrencyByCurrencyCode() |
88
|
|
|
{ |
89
|
|
|
// Arrange |
90
|
|
|
$currency = World::currencyByCountryCode('US'); |
91
|
|
|
|
92
|
|
|
// Assert |
93
|
|
|
$this->assertEquals(1, count($currency)); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** @test */ |
97
|
|
|
public function testTimezones() |
98
|
|
|
{ |
99
|
|
|
// Arrange |
100
|
|
|
$timezones = World::timezones(); |
|
|
|
|
101
|
|
|
|
102
|
|
|
// Assert |
103
|
|
|
$this->assertGreaterThan(100, count($timezones)); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** @test */ |
107
|
|
|
public function testTimezoneRegions() |
108
|
|
|
{ |
109
|
|
|
// Arrange |
110
|
|
|
$timezoneRegions = World::timezoneRegions(); |
|
|
|
|
111
|
|
|
|
112
|
|
|
// Assert |
113
|
|
|
$this->assertGreaterThan(8, count($timezoneRegions)); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** @test */ |
117
|
|
|
public function testTimezonesByRegion() |
118
|
|
|
{ |
119
|
|
|
// Arrange |
120
|
|
|
$timezones = World::timezonesByRegion('Antarctica'); |
|
|
|
|
121
|
|
|
|
122
|
|
|
// Assert |
123
|
|
|
$this->assertGreaterThan(5, count($timezones)); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** @test */ |
127
|
|
|
public function testSearchTimezone() |
128
|
|
|
{ |
129
|
|
|
// Arrange |
130
|
|
|
$timezones = World::searchTimezone('UTC'); |
|
|
|
|
131
|
|
|
|
132
|
|
|
// Assert |
133
|
|
|
$this->assertGreaterThan(0, count($timezones)); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** @test */ |
137
|
|
|
public function testIsoCodes() |
138
|
|
|
{ |
139
|
|
|
// Arrange |
140
|
|
|
$isoCodes = World::isoCodes(); |
|
|
|
|
141
|
|
|
|
142
|
|
|
// Assert |
143
|
|
|
$this->assertGreaterThan(100, count($isoCodes)); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** @test */ |
147
|
|
|
public function testRegions() |
148
|
|
|
{ |
149
|
|
|
// Arrange |
150
|
|
|
$regions = World::regions(); |
|
|
|
|
151
|
|
|
|
152
|
|
|
// Assert |
153
|
|
|
$this->assertLessThan(11, count($regions)); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** @test */ |
157
|
|
|
public function testSearchIsoCodes() |
158
|
|
|
{ |
159
|
|
|
// Arrange |
160
|
|
|
$isoCodes = World::searchIsoCodes('91'); |
|
|
|
|
161
|
|
|
|
162
|
|
|
// Assert |
163
|
|
|
$this->assertGreaterThan(1, count($isoCodes)); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** @test */ |
167
|
|
|
public function testIsoInfoByCountryName() |
168
|
|
|
{ |
169
|
|
|
// Arrange |
170
|
|
|
$isoInfoByCountryName = World::isoInfoByCountryName('India'); |
|
|
|
|
171
|
|
|
|
172
|
|
|
// Assert |
173
|
|
|
$this->assertEquals(0, count($isoInfoByCountryName)); |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** @test */ |
177
|
|
|
public function testIsoInfoByCode() |
178
|
|
|
{ |
179
|
|
|
// Arrange |
180
|
|
|
$isoInfoByCode = World::isoInfoByCode('IN'); |
|
|
|
|
181
|
|
|
|
182
|
|
|
// Assert |
183
|
|
|
$this->assertEquals($isoInfoByCode->status(), 200); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** @test */ |
187
|
|
|
public function testIsoCodesByRegion() |
188
|
|
|
{ |
189
|
|
|
// Arrange |
190
|
|
|
$isoCodesByRegion = World::isoCodesByRegion('Europe'); |
|
|
|
|
191
|
|
|
|
192
|
|
|
// Assert |
193
|
|
|
$this->assertGreaterThan(0, count($isoCodesByRegion)); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** @test */ |
197
|
|
|
public function testStates() |
198
|
|
|
{ |
199
|
|
|
// Arrange |
200
|
|
|
$states = World::states(); |
|
|
|
|
201
|
|
|
|
202
|
|
|
// Assert |
203
|
|
|
$this->assertGreaterThan(4000, count($states)); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** @test */ |
207
|
|
|
public function testSearchStates() |
208
|
|
|
{ |
209
|
|
|
// Arrange |
210
|
|
|
$states = World::searchStates('tel'); |
|
|
|
|
211
|
|
|
|
212
|
|
|
// Assert |
213
|
|
|
$this->assertGreaterThan(5, count($states)); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
/** @test */ |
217
|
|
|
public function testCountriesForStates() |
218
|
|
|
{ |
219
|
|
|
// Arrange |
220
|
|
|
$countriesForStates = World::countriesForStates('UAE'); |
|
|
|
|
221
|
|
|
|
222
|
|
|
// Assert |
223
|
|
|
$this->assertGreaterThan(200, count($countriesForStates)); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** @test */ |
227
|
|
|
public function testGetStatesByCountry() |
228
|
|
|
{ |
229
|
|
|
// Arrange |
230
|
|
|
$states = World::getStatesByCountry('Taiwan'); |
|
|
|
|
231
|
|
|
|
232
|
|
|
// Assert |
233
|
|
|
$this->assertGreaterThan(25, count($states)); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** @test */ |
237
|
|
|
public function testStdCodes() |
238
|
|
|
{ |
239
|
|
|
// Arrange |
240
|
|
|
$stdCodes = World::stdCodes(); |
|
|
|
|
241
|
|
|
|
242
|
|
|
// Assert |
243
|
|
|
$this->assertGreaterThan(200, count($stdCodes)); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** @test */ |
247
|
|
|
public function testSearchStdCodes() |
248
|
|
|
{ |
249
|
|
|
// Arrange |
250
|
|
|
$stdCodes = World::searchStdCodes('44'); |
|
|
|
|
251
|
|
|
|
252
|
|
|
// Assert |
253
|
|
|
$this->assertLessThan(10, count($stdCodes)); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** @test */ |
257
|
|
|
public function testStdCodeByCountryName() |
258
|
|
|
{ |
259
|
|
|
// Arrange |
260
|
|
|
$stdCodeByCountryName = World::stdCodeByCountryName('Russia'); |
|
|
|
|
261
|
|
|
|
262
|
|
|
// Assert |
263
|
|
|
$this->assertEquals(count($stdCodeByCountryName), 1); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** @test */ |
267
|
|
|
public function testStdCodeByCountryCode() |
268
|
|
|
{ |
269
|
|
|
// Arrange |
270
|
|
|
$stdCodeByCountryCode = World::stdCodeByCountryCode('CH'); |
|
|
|
|
271
|
|
|
|
272
|
|
|
// Assert |
273
|
|
|
$this->assertEquals(count($stdCodeByCountryCode), 1); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** @test */ |
277
|
|
|
public function testCities() |
278
|
|
|
{ |
279
|
|
|
// Arrange |
280
|
|
|
$cities = World::cities(); |
|
|
|
|
281
|
|
|
|
282
|
|
|
// Assert |
283
|
|
|
$this->assertGreaterThan(5000, count($cities)); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** @test */ |
287
|
|
|
public function testSearchCities() |
288
|
|
|
{ |
289
|
|
|
// Arrange |
290
|
|
|
$cities = World::searchCities('hy'); |
|
|
|
|
291
|
|
|
|
292
|
|
|
// Assert |
293
|
|
|
$this->assertGreaterThan(15, count($cities)); |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** @test */ |
297
|
|
|
public function statesForCities() |
298
|
|
|
{ |
299
|
|
|
// Arrange |
300
|
|
|
$statesForCities = World::statesForCities(); |
|
|
|
|
301
|
|
|
|
302
|
|
|
// Assert |
303
|
|
|
$this->assertGreaterThan(4000, count($statesForCities)); |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** @test */ |
307
|
|
|
public function countriesForCities() |
308
|
|
|
{ |
309
|
|
|
// Arrange |
310
|
|
|
$countriesForCities = World::countriesForCities(); |
|
|
|
|
311
|
|
|
|
312
|
|
|
// Assert |
313
|
|
|
$this->assertGreaterThan(245, count($countriesForCities)); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** @test */ |
317
|
|
|
public function getCitiesByStateName() |
318
|
|
|
{ |
319
|
|
|
// Arrange |
320
|
|
|
$city = World::getCitiesByStateName('Karnataka'); |
|
|
|
|
321
|
|
|
|
322
|
|
|
// Assert |
323
|
|
|
$this->assertGreaterThan(323, count($city)); |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** @test */ |
327
|
|
|
public function getCitiesByCountryName() |
328
|
|
|
{ |
329
|
|
|
// Arrange |
330
|
|
|
$city = World::getCitiesByCountryName('China'); |
|
|
|
|
331
|
|
|
|
332
|
|
|
// Assert |
333
|
|
|
$this->assertGreaterThan(1300, count($city)); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
} |