-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtest.php
100 lines (87 loc) · 2.76 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
require_once(__DIR__ . '/php-tracking-urls.php');
$errors = false;
$numbers = [
//TEST UPS
'1Z9999W99999999999' => 'ups.com',
'1Z12345E1512345676' => 'ups.com',
'1Z12345E0205271688' => 'ups.com',
'1Z12345E6605272234' => 'ups.com',
'1Z12345E0305271640' => 'ups.com',
'1Z12345E0393657226' => 'ups.com',
'1Z12345E1305277940' => 'ups.com',
'1Z12345E6205277936' => 'ups.com',
'1Z12345E1505270452' => 'ups.com',
'1Z648616E192760718' => 'ups.com',
'1ZWX0692YP40636269' => 'ups.com',
'T9999999999' => 'ups.com',
//TEST FEDEX
'9999 9999 9999' => 'fedex.com',
'9999 9999 9999 999' => 'fedex.com',
'999999999999' => 'fedex.com',
'999999999999999' => 'fedex.com',
'661377569221' => 'fedex.com',
'624893691092' => 'fedex.com',
'61299995669352455464' => 'fedex.com',
'61299995669151880177' => 'fedex.com',
'00408017007469' => 'fedex.com',
//TEST USPS
'9400 1000 0000 0000 0000 00' => 'usps.com',
'9205 5000 0000 0000 0000 00' => 'usps.com',
'9407 3000 0000 0000 0000 00' => 'usps.com',
'9303 3000 0000 0000 0000 00' => 'usps.com',
'82 000 000 00' => 'usps.com',
'EC 000 000 000 US' => 'usps.com',
'9270 1000 0000 0000 0000 00' => 'usps.com',
'EA 000 000 000 US' => 'usps.com',
'CP 000 000 000 US' => 'usps.com',
'9208 8000 0000 0000 0000 00' => 'usps.com',
'9202 1000 0000 0000 0000 00' => 'usps.com',
'9400100000000000000000' => 'usps.com',
'9205500000000000000000' => 'usps.com',
'9407300000000000000000' => 'usps.com',
'9303300000000000000000' => 'usps.com',
'8200000000' => 'usps.com',
'EC000000000US' => 'usps.com',
'9270100000000000000000' => 'usps.com',
'EA000000000US' => 'usps.com',
'CP000000000US' => 'usps.com',
'9208800000000000000000' => 'usps.com',
'9202100000000000000000' => 'usps.com',
'92748963438592543475924253' => 'usps.com',
//TEST ONTRAC
'C00000000000000' => 'ontrac.com',
'C99999999999999' => 'ontrac.com',
//TEST DHL
'125-12345678' => 'dhl.com',
'125 12345678' => 'dhl.com',
'12512345678' => 'dhl.com',
'SEA1234567' => 'dhl.com',
'LAX1234567' => 'dhl.com',
//INVALID TRACKING NUMBERS
'INVALID TRACKING NUMBER' => false,
];
foreach ($numbers as $number => $service) {
echo 'TESTING: ' . $number;
if ($url = get_tracking_url($number)) {
echo "\n" . $url;
if (!strpos($url, $service)) {
echo "\n --- FAILED --- WRONG SERVICE DETECTED ---";
$errors = true;
}
} else {
if ($url === false && $service === false) {
echo "\n --- NO SERVICE AVAILABLE FOR THIS VALUE ---";
} else {
echo "\n --- FAILED --- NO SERVICE FOUND ---";
$errors = true;
}
}
echo "\n\n";
}
if ($errors) {
echo " --- ERROR FOUND --- TEST FAILED ---\n\n";
exit(1);
} else {
echo " !!! ALL GOOD !!!\n\n";
}