Prepended constants with C_ to avoid reserved words as per https://www.php.net/manual...
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / URIParserTest.php
blob4bc21b7602530e84fce96946283e0f12721b9dbd
1 <?php
3 class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
6 protected function assertParsing(
7 $uri, $scheme, $userinfo, $host, $port, $path, $query, $fragment, $config = null, $context = null
8 ) {
9 $this->prepareCommon($config, $context);
10 $parser = new HTMLPurifier_URIParser();
11 $result = $parser->parse($uri, $config, $context);
12 $expect = new HTMLPurifier_URI($scheme, $userinfo, $host, $port, $path, $query, $fragment);
13 $this->assertEqual($result, $expect);
16 public function testPercentNormalization()
18 $this->assertParsing(
19 '%G',
20 null, null, null, null, '%25G', null, null
24 public function testRegular()
26 $this->assertParsing(
27 'http://www.example.com/webhp?q=foo#result2',
28 'http', null, 'www.example.com', null, '/webhp', 'q=foo', 'result2'
32 public function testPortAndUsername()
34 $this->assertParsing(
35 'http://user@authority.part:80/now/the/path?query#fragment',
36 'http', 'user', 'authority.part', 80, '/now/the/path', 'query', 'fragment'
40 public function testPercentEncoding()
42 $this->assertParsing(
43 'http://en.wikipedia.org/wiki/Clich%C3%A9',
44 'http', null, 'en.wikipedia.org', null, '/wiki/Clich%C3%A9', null, null
48 public function testEmptyQuery()
50 $this->assertParsing(
51 'http://www.example.com/?#',
52 'http', null, 'www.example.com', null, '/', '', null
56 public function testEmptyPath()
58 $this->assertParsing(
59 'http://www.example.com',
60 'http', null, 'www.example.com', null, '', null, null
64 public function testOpaqueURI()
66 $this->assertParsing(
67 'mailto:bob@example.com',
68 'mailto', null, null, null, 'bob@example.com', null, null
72 public function testTelURI()
74 $this->assertParsing(
75 'tel:+1 (555) 555-5555',
76 'tel', null, null, null, '+1 (555) 555-5555', null, null
80 public function testIPv4Address()
82 $this->assertParsing(
83 'http://192.0.34.166/',
84 'http', null, '192.0.34.166', null, '/', null, null
88 public function testFakeIPv4Address()
90 $this->assertParsing(
91 'http://333.123.32.123/',
92 'http', null, '333.123.32.123', null, '/', null, null
96 public function testIPv6Address()
98 $this->assertParsing(
99 'http://[2001:db8::7]/c=GB?objectClass?one',
100 'http', null, '[2001:db8::7]', null, '/c=GB', 'objectClass?one', null
104 public function testInternationalizedDomainName()
106 $this->assertParsing(
107 "http://t\xC5\xABdali\xC5\x86.lv",
108 'http', null, "t\xC5\xABdali\xC5\x86.lv", null, '', null, null
112 public function testInvalidPort()
114 $this->assertParsing(
115 'http://example.com:foobar',
116 'http', null, 'example.com', null, '', null, null
120 public function testPathAbsolute()
122 $this->assertParsing(
123 'http:/this/is/path',
124 'http', null, null, null, '/this/is/path', null, null
128 public function testPathRootless()
130 // this should not be used but is allowed
131 $this->assertParsing(
132 'http:this/is/path',
133 'http', null, null, null, 'this/is/path', null, null
137 public function testPathEmpty()
139 $this->assertParsing(
140 'http:',
141 'http', null, null, null, '', null, null
145 public function testRelativeURI()
147 $this->assertParsing(
148 '/a/b',
149 null, null, null, null, '/a/b', null, null
153 public function testMalformedTag()
155 $this->assertParsing(
156 'http://www.example.com/>',
157 'http', null, 'www.example.com', null, '/', null, null
161 public function testEmpty()
163 $this->assertParsing(
165 null, null, null, null, '', null, null
169 public function testEmbeddedColon()
171 $this->assertParsing(
172 '{:test:}',
173 null, null, null, null, '{:test:}', null, null
179 // vim: et sw=4 sts=4