-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathparser.test
More file actions
113 lines (109 loc) · 9.52 KB
/
parser.test
File metadata and controls
113 lines (109 loc) · 9.52 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
class ParserUnitTestCase extends DrupalUnitTestCase {
public static function getInfo() {
return array(
'name' => 'Parser module unit tests',
'description' => 'Parser module unit tests',
'group' => 'Parser',
);
}
public function testAbsoluteUrl() {
module_load_include('inc', 'parser');
$test_data = array(
array('http://example.com', '/', 'http://example.com/'),
array('http://example.com', '?a=b', 'http://example.com/?a=b'),
array('http://example.com', 'index.php', 'http://example.com/index.php'),
array('http://example.com', 'index.php', 'http://example.com/index.php'),
array('http://example.com', '/index.php', 'http://example.com/index.php'),
array('http://example.com', './index.php', 'http://example.com/index.php'),
array('http://example.com', '../index.php', 'http://example.com/index.php'),
array('http://example.com', 'bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com', '/bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com', '/bar/индекс.php', 'http://example.com/bar/индекс.php'),
array('http://example.com', '/bar/index.php?a=b', 'http://example.com/bar/index.php?a=b'),
array('http://example.com', '/bar/index.php?a=b b', 'http://example.com/bar/index.php?a=b b'),
array('http://example.com', '/bar/индекс.php?a=b b', 'http://example.com/bar/индекс.php?a=b b'),
array('http://example.com', '//test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com', 'http://test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/', '/', 'http://example.com/'),
array('http://example.com/', '?a=b', 'http://example.com/?a=b'),
array('http://example.com/', 'index.php', 'http://example.com/index.php'),
array('http://example.com/', 'index.php', 'http://example.com/index.php'),
array('http://example.com/', '/index.php', 'http://example.com/index.php'),
array('http://example.com/', './index.php', 'http://example.com/index.php'),
array('http://example.com/', '../index.php', 'http://example.com/index.php'),
array('http://example.com/', 'bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/', '/bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/', '/bar/index.php?a=b', 'http://example.com/bar/index.php?a=b'),
array('http://example.com/', '//test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/', 'http://test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/foo', '?a=b', 'http://example.com/foo?a=b'),
array('http://example.com/foo', 'index.php', 'http://example.com/index.php'),
array('http://example.com/foo', '/index.php', 'http://example.com/index.php'),
array('http://example.com/foo', './index.php', 'http://example.com/index.php'),
array('http://example.com/foo', '../index.php', 'http://example.com/index.php'),
array('http://example.com/foo', '../../index.php', 'http://example.com/index.php'),
array('http://example.com/foo', 'bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/foo', '/bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/foo', '/bar/index.php?a=b', 'http://example.com/bar/index.php?a=b'),
array('http://example.com/foo', '/бар/index.php?a=b', 'http://example.com/бар/index.php?a=b'),
array('http://example.com/foo', '//test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/foo', 'http://test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/foo/', '?a=b', 'http://example.com/foo/?a=b'),
array('http://example.com/foo/', 'index.php', 'http://example.com/foo/index.php'),
array('http://example.com/foo/', '/index.php', 'http://example.com/index.php'),
array('http://example.com/foo/', './index.php', 'http://example.com/foo/index.php'),
array('http://example.com/foo/', '../index.php', 'http://example.com/index.php'),
array('http://example.com/foo/', '../../index.php', 'http://example.com/index.php'),
array('http://example.com/foo/', 'bar/index.php', 'http://example.com/foo/bar/index.php'),
array('http://example.com/foo/', '/bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/foo/', '/bar/index.php?a=b', 'http://example.com/bar/index.php?a=b'),
array('http://example.com/foo/', '//test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/foo/', 'http://test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/foo/bar/', '/', 'http://example.com/'),
array('http://example.com/foo/bar/', '?a=b', 'http://example.com/foo/bar/?a=b'),
array('http://example.com/foo/bar/', 'index.php', 'http://example.com/foo/bar/index.php'),
array('http://example.com/foo/bar/', '/index.php', 'http://example.com/index.php'),
array('http://example.com/foo/bar/', './index.php', 'http://example.com/foo/bar/index.php'),
array('http://example.com/foo/bar/', '../index.php', 'http://example.com/foo/index.php'),
array('http://example.com/foo/bar/', '../../index.php', 'http://example.com/index.php'),
array('http://example.com/foo bar/', '/', 'http://example.com/'),
array('http://example.com/foo bar/', '?a=b', 'http://example.com/foo bar/?a=b'),
array('http://example.com/foo bar/', 'index.php', 'http://example.com/foo bar/index.php'),
array('http://example.com/foo bar/', '/index.php', 'http://example.com/index.php'),
array('http://example.com/foo bar/', './index.php', 'http://example.com/foo bar/index.php'),
array('http://example.com/foo bar/', '../index.php', 'http://example.com/index.php'),
array('http://example.com/foo bar/', '../../index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b', '?c=d', 'http://example.com/foo?c=d'),
array('http://example.com/foo?a=b', 'index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b', '/index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b', './index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b', '../index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b', '../../index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b', 'bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/foo?a=b', '/bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/foo?a=b', '/bar/index.php?a=b', 'http://example.com/bar/index.php?a=b'),
array('http://example.com/foo?a=b', '//test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/foo?a=b', 'http://test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/foo?a=b/', '?c=d', 'http://example.com/foo?c=d'),
array('http://example.com/foo?a=b/', 'index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b/', '/index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b/', './index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b/', '../index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b/', '../../index.php', 'http://example.com/index.php'),
array('http://example.com/foo?a=b/', 'bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/foo?a=b/', '/bar/index.php', 'http://example.com/bar/index.php'),
array('http://example.com/foo?a=b/', '/bar/index.php?a=b', 'http://example.com/bar/index.php?a=b'),
array('http://example.com/foo?a=b/', '//test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/foo?a=b/', 'http://test.ru/index.php', 'http://test.ru/index.php'),
array('http://example.com/', 'http://test.ru/index.php', 'http://test.ru/index.php'),
);
foreach ($test_data as $urls) {
$this->assertEqual(
parser_get_absolute_url($urls[0], $urls[1]),
$urls[2],
'"' . $urls[0] . '" + "' . $urls[1] . '" = "' . $urls[2] . '"'
);
}
}
}