superp-phone 1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,75 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ ## Croatia
4
+ class HRTest < Phoner::TestCase
5
+
6
+ def test_zagreb
7
+ parse_test('+38513668734', '385', '1', '3668734', 'Croatia', false)
8
+ end
9
+
10
+ def test_mobile
11
+ parse_test('+385915125486', '385', '91', '5125486', 'Croatia', true)
12
+ end
13
+
14
+ def test_long_without_special_characters
15
+ parse_test('+385915125486', '385', '91', '5125486')
16
+ end
17
+
18
+ def test_long_with_special_characters
19
+ parse_test('+ 385 (91) 512 / 5486 ', '385', '91', '5125486')
20
+ end
21
+
22
+ def test_long_with_leading_zeros
23
+ parse_test('00385915125486', '385', '91', '5125486')
24
+ end
25
+
26
+ def test_zagreb_long_with_leading_zeros
27
+ parse_test('0038513668734', '385', '1', '3668734')
28
+ end
29
+
30
+ def test_short_without_special_characters_with_country
31
+ Phoner::Phone.default_country_code = '385'
32
+ parse_test('044885047', '385', '44', '885047')
33
+ end
34
+
35
+ def test_zagreb_short_without_special_characters_with_country
36
+ Phoner::Phone.default_country_code = '385'
37
+ parse_test('013668734', '385', '1', '3668734')
38
+ end
39
+
40
+ def test_long_with_zero_in_brackets
41
+ Phoner::Phone.default_country_code = nil
42
+ parse_test('+385 (0)1 366 8111', '385', '1', '3668111')
43
+ end
44
+
45
+ def test_has_default_country_code
46
+ Phoner::Phone.default_country_code = '385'
47
+
48
+ assert_equal Phoner::Phone.parse('+38547451588').has_default_country_code?, true
49
+ assert_equal Phoner::Phone.parse('+16472228242').has_default_country_code?, false
50
+ end
51
+
52
+ def test_has_default_area_code
53
+ Phoner::Phone.default_country_code = '385'
54
+ Phoner::Phone.default_area_code = '47'
55
+
56
+ assert_equal Phoner::Phone.parse('047/451-588').has_default_area_code?, true
57
+ assert_equal Phoner::Phone.parse('032/336-1456').has_default_area_code?, false
58
+ end
59
+
60
+ def test_validates
61
+ Phoner::Phone.default_country_code = nil
62
+ assert_equal Phoner::Phone.valid?('00385915125486'), true
63
+ assert_equal Phoner::Phone.valid?('+385915125486'), true
64
+ assert_equal Phoner::Phone.valid?('+385 (91) 512 5486'), true
65
+ assert_equal Phoner::Phone.valid?('+38547451588'), true
66
+
67
+ Phoner::Phone.default_country_code = '385'
68
+ assert_equal Phoner::Phone.valid?('0915125486'), true
69
+ assert_equal Phoner::Phone.valid?('091/512-5486'), true
70
+ assert_equal Phoner::Phone.valid?('091/512-5486'), true
71
+ assert_equal Phoner::Phone.valid?('091 512 54 86'), true
72
+ assert_equal Phoner::Phone.valid?('091-512-54-86'), true
73
+ assert_equal Phoner::Phone.valid?('047/451-588'), true
74
+ end
75
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ ## Hungary
4
+ class HUTest < Phoner::TestCase
5
+ def test_mobile
6
+ parse_test('+36 30 5517999', '36', '30', '5517999', "Hungary", true)
7
+ end
8
+
9
+ def test_capital
10
+ parse_test('+36 1 5517999', '36', '1', '5517999', "Hungary", false)
11
+ end
12
+ end
@@ -0,0 +1,45 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ ## India
4
+ class INTest < Phoner::TestCase
5
+ def test_local
6
+ parse_test('+91.124.4529000', '91', '124', '4529000')
7
+ parse_test('+91 124 4529000', '91', '124', '4529000')
8
+ parse_test('+911244529000', '91', '124', '4529000')
9
+ parse_test('911244529000', '91', '124', '4529000', "India", false)
10
+ end
11
+
12
+ def test_mobile
13
+ parse_test('918124452900', '91', '8124', '452900', "India", true)
14
+ end
15
+
16
+ def test_long_with_default_country_code
17
+ Phoner::Phone.default_country_code = '91'
18
+ parse_test('9124459000', '91', '9124', '459000')
19
+ end
20
+
21
+ def test_short_with_default_country_code_and_area_code
22
+ Phoner::Phone.default_country_code = '91'
23
+ Phoner::Phone.default_area_code = '9124'
24
+ parse_test('4529000', '91', '9124', '4529000')
25
+ end
26
+
27
+ def test_lengths
28
+ Phoner::Phone.default_country_code = '91'
29
+
30
+ phone = Phoner::Phone.parse("919812344")
31
+ assert_nil phone
32
+
33
+ phone = Phoner::Phone.parse("9818147874")
34
+ assert phone
35
+
36
+ phone = Phoner::Phone.parse("91111111111")
37
+ assert_nil phone
38
+
39
+ phone = Phoner::Phone.parse("98111111111")
40
+ assert_nil phone
41
+
42
+ phone = Phoner::Phone.parse("98111111119")
43
+ assert_nil phone
44
+ end
45
+ end
@@ -0,0 +1,383 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
+
3
+ ## Netherlands
4
+ class NETest < Phoner::TestCase
5
+
6
+ # 06: mobile phone number
7
+ def test_mobile
8
+ parse_test('+31 6 12345678', '31', '6', '12345678', "Netherlands", true)
9
+ end
10
+
11
+ # 066: mobile pagers
12
+ def test_pagers
13
+ parse_test('+31 66 1234567', '31', '66', '1234567')
14
+ end
15
+
16
+ # 06760: internet access number
17
+ def test_internet_access
18
+ parse_test('+31 6760 12345', '31', '6760', '12345')
19
+ end
20
+
21
+ # 0800: toll free number
22
+ def test_toll_free
23
+ parse_test('+31 800 123456', '31', '800', '123456', "Netherlands", false)
24
+ end
25
+
26
+ # 084: location independent (used mostly for fax-to-email and voicemail services)
27
+ def test_location_independent_84
28
+ parse_test('+31 84 1234567', '31', '84', '1234567')
29
+ end
30
+
31
+ # 085: location independent
32
+ def test_location_independent_85
33
+ parse_test('+31 85 1234567', '31', '85', '1234567')
34
+ end
35
+
36
+ # 087: location independent
37
+ def test_location_independent_87
38
+ parse_test('+31 87 1234567', '31', '87', '1234567')
39
+ end
40
+
41
+ # 088: location independent (for companies)
42
+ def test_location_independent_88
43
+ parse_test('+31 88 1234567', '31', '88', '1234567')
44
+ end
45
+
46
+ # 0878: location independent (voice over IP)
47
+ def test_location_independent_878
48
+ parse_test('+31 878 123456', '31', '878', '123456')
49
+ end
50
+
51
+ # 0900: premium rate, information
52
+ def test_premium_900
53
+ parse_test('+31 900 123456', '31', '900', '123456')
54
+ end
55
+
56
+ # 0906: premium rate, erotic
57
+ def test_premium_906
58
+ parse_test('+31 906 123456', '31', '906', '123456')
59
+ end
60
+ # 0909: premium rate, entertainment
61
+
62
+ # 112: emergency services number
63
+ # 14xxx(x): public authorities, where xxxx is the three- or four-digit area-code of the municipality
64
+ # 18xx: number information
65
+
66
+ # 01x(x) to 05x(x): geographical area codes
67
+
68
+ ## two digit
69
+ # 010 Rotterdam
70
+ def test_rotterdam
71
+ parse_test('+31 10 1234567', '31', '10', '1234567')
72
+ end
73
+ # 013 Tilburg
74
+ def test_tilburg
75
+ parse_test('+31 13 1234567', '31', '13', '1234567')
76
+ end
77
+ # 015 Delft
78
+
79
+ # 020 Amsterdam
80
+ def test_amsterdam
81
+ parse_test('+31 20 1234567', '31', '20', '1234567')
82
+ end
83
+ # 023 Haarlem
84
+ # 024 Nijmegen
85
+ # 026 Arnhem
86
+
87
+ # 030 Utrecht
88
+ def test_utrecht
89
+ parse_test('+31 30 1234567', '31', '30', '1234567')
90
+ end
91
+ # 033 Amersfoort
92
+ def test_amersfoort
93
+ parse_test('+31 33 1234567', '31', '33', '1234567')
94
+ end
95
+ # 035 Hilversum
96
+ # 036 Almere
97
+ # 038 Zwolle
98
+
99
+ # 040 Eindhoven
100
+ # 043 Maastricht
101
+ # 045 Heerlen
102
+ def test_heerlen
103
+ parse_test('+31 45 1234567', '31', '45', '1234567')
104
+ end
105
+ # 046 Sittard
106
+
107
+ # 050 Groningen
108
+ def test_groningen
109
+ parse_test('+31 50 1234567', '31', '50', '1234567')
110
+ end
111
+ # 053 Enschede
112
+ # 055 Apeldoorn
113
+ # 058 Leeuwarden
114
+ def test_leeuwarden
115
+ parse_test('+31 58 1234567', '31', '58', '1234567')
116
+ end
117
+
118
+ # 07x: geographical area codes (cities all over the country)
119
+ # 070 The Hague
120
+ def test_the_hague
121
+ parse_test('+31 70 1234567', '31', '70', '1234567')
122
+ end
123
+ # 071 Leiden
124
+ def test_leiden
125
+ parse_test('+31 71 1234567', '31', '71', '1234567')
126
+ end
127
+ # 072 Alkmaar
128
+ # 073 's-Hertogenbosch
129
+ # 074 Hengelo
130
+ # 075 Zaandam
131
+ def test_zaandam
132
+ parse_test('+31 75 1234567', '31', '75', '1234567')
133
+ end
134
+ # 076 Breda
135
+ # 077 Venlo
136
+ # 078 Dordrecht
137
+ # 079 Zoetermeer
138
+ def test_zoetermeer
139
+ parse_test('+31 79 1234567', '31', '79', '1234567')
140
+ end
141
+
142
+
143
+ ## three digit
144
+ # 0111 Zierikzee
145
+ def test_zierikzee
146
+ parse_test('+31 111 123456', '31', '111', '123456')
147
+ end
148
+ # 0113 Goes
149
+ def test_goes
150
+ parse_test('+31 113 123456', '31', '113', '123456')
151
+ end
152
+ # 0114 Hulst
153
+ # 0115 Terneuzen
154
+ # 0117 Sluis
155
+ def test_sluis
156
+ parse_test('+31 117 123456', '31', '117', '123456')
157
+ end
158
+ # 0118 Middelburg
159
+
160
+ # 0161 Gilze-Rijen
161
+ def test_gilze
162
+ parse_test('+31 161 123456', '31', '161', '123456')
163
+ end
164
+ # 0162 Oosterhout
165
+ # 0164 Bergen op Zoom
166
+ def test_bergen
167
+ parse_test('+31 164 123456', '31', '164', '123456')
168
+ end
169
+ # 0165 Roosendaal
170
+ # 0166 Tholen
171
+ # 0167 Steenbergen
172
+ # 0168 Zevenbergen
173
+
174
+ # 0172 Alphen aan den Rijn
175
+ def test_alphen
176
+ parse_test('+31 172 123456', '31', '172', '123456')
177
+ end
178
+ # 0174 Naaldwijk
179
+
180
+ # 0180 Ridderkerk
181
+ def test_ridderkerk
182
+ parse_test('+31 180 123456', '31', '180', '123456')
183
+ end
184
+ # 0181 Spijkenisse
185
+ # 0182 Gouda
186
+ def test_gouda
187
+ parse_test('+31 182 123456', '31', '182', '123456')
188
+ end
189
+ # 0183 Gorinchem
190
+ # 0184 Sliedrecht
191
+ # 0186 Oud-Beijerland
192
+ # 0187 Middelharnis
193
+
194
+ # 0222 Texel
195
+ def test_texel
196
+ parse_test('+31 222 123456', '31', '222', '123456')
197
+ end
198
+ # 0223 Den Helder
199
+ # 0224 Schagen
200
+ def test_shagen
201
+ parse_test('+31 224 123456', '31', '224', '123456')
202
+ end
203
+ # 0226 Harenkarspel
204
+ # 0227 Medemblik, Middenmeer as well as Heerhugowaard
205
+ # 0228 Enkhuizen
206
+ # 0229 Hoorn
207
+ def test_hoorn
208
+ parse_test('+31 229 123456', '31', '229', '123456')
209
+ end
210
+
211
+ # 0251 Beverwijk
212
+ def test_beverwijk
213
+ parse_test('+31 251 123456', '31', '251', '123456')
214
+ end
215
+ # 0252 Hillegom
216
+ # 0255 IJmuiden
217
+
218
+ # 0294 Weesp
219
+ def test_weesp
220
+ parse_test('+31 294 123456', '31', '294', '123456')
221
+ end
222
+ # 0297 Aalsmeer
223
+ # 0299 Purmerend
224
+
225
+ # 0313 Dieren
226
+ def test_dieren
227
+ parse_test('+31 313 123456', '31', '313', '123456')
228
+ end
229
+ # 0314 Doetinchem
230
+ # 0315 Terborg
231
+ def test_terborg
232
+ parse_test('+31 315 123456', '31', '315', '123456')
233
+ end
234
+ # 0316 Zevenaar
235
+ # 0317 Wageningen
236
+ # 0318 Ede / Veenendaal
237
+
238
+ # 0320 Lelystad
239
+ def test_lelystad
240
+ parse_test('+31 320 123456', '31', '320', '123456')
241
+ end
242
+ # 0321 Dronten
243
+
244
+ # 0341 Harderwijk
245
+ def test_harderwijk
246
+ parse_test('+31 341 123456', '31', '341', '123456')
247
+ end
248
+ # 0342 Barneveld
249
+ # 0343 Doorn
250
+ # 0344 Tiel
251
+ def test_tiel
252
+ parse_test('+31 344 123456', '31', '344', '123456')
253
+ end
254
+ # 0345 Culemborg
255
+ # 0346 Maarssen
256
+ # 0347 Vianen
257
+ # 0348 Woerden
258
+
259
+ # 0411 Boxtel
260
+ def test_boxtel
261
+ parse_test('+31 411 123456', '31', '411', '123456')
262
+ end
263
+ # 0412 Oss
264
+ # 0413 Veghel
265
+ # 0416 Waalwijk
266
+ # 0418 Zaltbommel
267
+
268
+ # 0475 Roermond
269
+ def test_roermond
270
+ parse_test('+31 475 123456', '31', '475', '123456')
271
+ end
272
+ # 0478 Venray
273
+
274
+ # 0481 Bemmel
275
+ def test_bemmel
276
+ parse_test('+31 481 123456', '31', '481', '123456')
277
+ end
278
+ # 0485 Cuijk
279
+ # 0486 Grave
280
+ # 0487 Druten
281
+ def test_druten
282
+ parse_test('+31 487 123456', '31', '487', '123456')
283
+ end
284
+ # 0488 Zetten
285
+
286
+ # 0492 Helmond
287
+ def test_helmond
288
+ parse_test('+31 492 123456', '31', '492', '123456')
289
+ end
290
+ # 0493 Deurne
291
+ # 0495 Weert
292
+ def test_weert
293
+ parse_test('+31 495 123456', '31', '495', '123456')
294
+ end
295
+ # 0497 Eersel
296
+ # 0499 Best
297
+
298
+ # 0511 Veenwouden
299
+ def test_veenwouden
300
+ parse_test('+31 511 123456', '31', '511', '123456')
301
+ end
302
+ # 0512 Drachten
303
+ # 0513 Heerenveen
304
+ # 0514 Balk
305
+ # 0515 Sneek
306
+ def test_sneek
307
+ parse_test('+31 515 123456', '31', '515', '123456')
308
+ end
309
+ # 0516 Oosterwolde
310
+ # 0517 Franeker
311
+ # 0518 St. Annaparochie
312
+ # 0519 Dokkum
313
+
314
+ # 0521 Steenwijk
315
+ def test_steenwijk
316
+ parse_test('+31 521 123456', '31', '521', '123456')
317
+ end
318
+ # 0522 Meppel
319
+ # 0523 Hardenberg
320
+ # 0524 Coevorden
321
+ def tst_coevorden
322
+ parse_test('+31 524 123456', '31', '524', '123456')
323
+ end
324
+ # 0525 Elburg
325
+ # 0527 Emmeloord
326
+ # 0528 Hoogeveen
327
+ # 0529 Ommen
328
+
329
+ # 0541 Oldenzaal
330
+ def test_oldenzaal
331
+ parse_test('+31 541 123456', '31', '541', '123456')
332
+ end
333
+ # 0543 Winterswijk
334
+ # 0544 Groenlo
335
+ # 0545 Neede
336
+ def test_neede
337
+ parse_test('+31 545 123456', '31', '545', '123456')
338
+ end
339
+ # 0546 Almelo
340
+ # 0547 Goor
341
+ # 0548 Rijssen
342
+
343
+ # 0561 Wolvega
344
+ def test_wolvega
345
+ parse_test('+31 561 123456', '31', '561', '123456')
346
+ end
347
+ # 0562 Terschelling/Vlieland
348
+ # 0566 Irnsum
349
+
350
+ # 0570 Deventer
351
+ def test_deventer
352
+ parse_test('+31 570 123456', '31', '570', '123456')
353
+ end
354
+ # 0571 Voorst
355
+ # 0572 Raalte
356
+ # 0573 Lochem
357
+ def test_lochem
358
+ parse_test('+31 573 123456', '31', '573', '123456')
359
+ end
360
+ # 0575 Zutphen
361
+ # 0577 Uddel
362
+ # 0578 Epe
363
+
364
+ # 0591 Emmen
365
+ def test_emmen
366
+ parse_test('+31 591 123456', '31', '591', '123456')
367
+ end
368
+ # 0592 Assen
369
+ # 0593 Beilen
370
+ def test_beilen
371
+ parse_test('+31 593 123456', '31', '593', '123456')
372
+ end
373
+ # 0594 Zuidhorn
374
+ # 0595 Warffum
375
+ # 0596 Appingedam
376
+ # 0597 Winschoten
377
+ # 0598 Hoogezand
378
+ # 0599 Stadskanaal
379
+ def test_stadskanaal
380
+ parse_test('+31 599 123456', '31', '599', '123456')
381
+ end
382
+
383
+ end