ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ParseTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\Uri;
4 
6 
10  function testParse($in, $out) {
11 
12  $this->assertEquals(
13  $out,
14  parse($in)
15  );
16 
17  }
18 
22  function testParseFallback($in, $out) {
23 
25  $result = $result + [
26  'scheme' => null,
27  'host' => null,
28  'path' => null,
29  'port' => null,
30  'user' => null,
31  'query' => null,
32  'fragment' => null,
33  ];
34 
35  $this->assertEquals(
36  $out,
37  $result
38  );
39 
40  }
41 
42  function parseData() {
43 
44  return [
45  [
46  'http://example.org/hello?foo=bar#test',
47  [
48  'scheme' => 'http',
49  'host' => 'example.org',
50  'path' => '/hello',
51  'port' => null,
52  'user' => null,
53  'query' => 'foo=bar',
54  'fragment' => 'test'
55  ]
56  ],
57  // See issue #6. parse_url corrupts strings like this, but only on
58  // macs.
59  [
60  'http://example.org/有词法别名.zh',
61  [
62  'scheme' => 'http',
63  'host' => 'example.org',
64  'path' => '/%E6%9C%89%E8%AF%8D%E6%B3%95%E5%88%AB%E5%90%8D.zh',
65  'port' => null,
66  'user' => null,
67  'query' => null,
68  'fragment' => null
69  ]
70  ],
71  [
72  'ftp://user:password@ftp.example.org/',
73  [
74  'scheme' => 'ftp',
75  'host' => 'ftp.example.org',
76  'path' => '/',
77  'port' => null,
78  'user' => 'user',
79  'pass' => 'password',
80  'query' => null,
81  'fragment' => null,
82  ]
83  ],
84  // See issue #9, parse_url doesn't like colons followed by numbers even
85  // though they are allowed since RFC 3986
86  [
87  'http://example.org/hello:12?foo=bar#test',
88  [
89  'scheme' => 'http',
90  'host' => 'example.org',
91  'path' => '/hello:12',
92  'port' => null,
93  'user' => null,
94  'query' => 'foo=bar',
95  'fragment' => 'test'
96  ]
97  ],
98  [
99  '/path/to/colon:34',
100  [
101  'scheme' => null,
102  'host' => null,
103  'path' => '/path/to/colon:34',
104  'port' => null,
105  'user' => null,
106  'query' => null,
107  'fragment' => null,
108  ]
109  ],
110  // File scheme
111  [
112  'file:///foo/bar',
113  [
114  'scheme' => 'file',
115  'host' => '',
116  'path' => '/foo/bar',
117  'port' => null,
118  'user' => null,
119  'query' => null,
120  'fragment' => null,
121  ]
122  ],
123  // Weird scheme with triple-slash. See Issue #11.
124  [
125  'vfs:///somefile',
126  [
127  'scheme' => 'vfs',
128  'host' => '',
129  'path' => '/somefile',
130  'port' => null,
131  'user' => null,
132  'query' => null,
133  'fragment' => null,
134  ]
135  ],
136  // Examples from RFC3986
137  [
138  'ldap://[2001:db8::7]/c=GB?objectClass?one',
139  [
140  'scheme' => 'ldap',
141  'host' => '[2001:db8::7]',
142  'path' => '/c=GB',
143  'port' => null,
144  'user' => null,
145  'query' => 'objectClass?one',
146  'fragment' => null,
147  ]
148  ],
149  [
150  'news:comp.infosystems.www.servers.unix',
151  [
152  'scheme' => 'news',
153  'host' => null,
154  'path' => 'comp.infosystems.www.servers.unix',
155  'port' => null,
156  'user' => null,
157  'query' => null,
158  'fragment' => null,
159  ]
160  ],
161  // Port
162  [
163  'http://example.org:8080/',
164  [
165  'scheme' => 'http',
166  'host' => 'example.org',
167  'path' => '/',
168  'port' => 8080,
169  'user' => null,
170  'query' => null,
171  'fragment' => null,
172  ]
173  ],
174  // Parial url
175  [
176  '#foo',
177  [
178  'scheme' => null,
179  'host' => null,
180  'path' => null,
181  'port' => null,
182  'user' => null,
183  'query' => null,
184  'fragment' => 'foo',
185  ]
186 
187  ]
188 
189  ];
190 
191  }
192 
193 }
$result
_parse_fallback($uri)
This function is another implementation of parse_url, except this one is fully written in PHP...
Definition: functions.php:302
testParseFallback($in, $out)
parseData
Definition: ParseTest.php:22
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
parse($uri)
Parses a URI and returns its individual components.
Definition: functions.php:181
testParse($in, $out)
parseData
Definition: ParseTest.php:10