Skip to content

Commit cf3b305

Browse files
authored
Reorganize ext/uri tests - parsing (#20340)
1 parent afb7b97 commit cf3b305

File tree

88 files changed

+2079
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2079
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - basic - multibyte character
3+
--FILE--
4+
<?php
5+
6+
try {
7+
new Uri\Rfc3986\Uri("🐘");
8+
} catch (Throwable $e) {
9+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
10+
}
11+
12+
?>
13+
--EXPECT--
14+
Uri\InvalidUriException: The specified URI is malformed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - basic - URI contains null byte
3+
--FILE--
4+
<?php
5+
6+
try {
7+
new Uri\Rfc3986\Uri("https://exam\0ple.com");
8+
} catch (ValueError $e) {
9+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
10+
}
11+
12+
?>
13+
--EXPECT--
14+
ValueError: Uri\Rfc3986\Uri::__construct(): Argument #1 ($uri) must not contain any null bytes
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - basic - URI contains null byte
3+
--FILE--
4+
<?php
5+
6+
try {
7+
Uri\Rfc3986\Uri::parse("https://exam\0ple.com");
8+
} catch (ValueError $e) {
9+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
10+
}
11+
12+
?>
13+
--EXPECT--
14+
ValueError: Uri\Rfc3986\Uri::parse(): Argument #1 ($uri) must not contain any null bytes
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - basic - all components
3+
--FILE--
4+
<?php
5+
6+
$uri = Uri\Rfc3986\Uri::parse("https://user:[email protected]:443/foo/bar?abc=123&def=ghi#hashmark");
7+
8+
var_dump($uri);
9+
var_dump($uri->toRawString());
10+
var_dump($uri->toString());
11+
12+
?>
13+
--EXPECTF--
14+
object(Uri\Rfc3986\Uri)#%d (%d) {
15+
["scheme"]=>
16+
string(5) "https"
17+
["username"]=>
18+
string(4) "user"
19+
["password"]=>
20+
string(4) "info"
21+
["host"]=>
22+
string(11) "example.com"
23+
["port"]=>
24+
int(443)
25+
["path"]=>
26+
string(8) "/foo/bar"
27+
["query"]=>
28+
string(15) "abc=123&def=ghi"
29+
["fragment"]=>
30+
string(8) "hashmark"
31+
}
32+
string(66) "https://user:[email protected]:443/foo/bar?abc=123&def=ghi#hashmark"
33+
string(66) "https://user:[email protected]:443/foo/bar?abc=123&def=ghi#hashmark"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - basic - mailto email
3+
--FILE--
4+
<?php
5+
6+
$uri = Uri\Rfc3986\Uri::parse("mailto:[email protected]");
7+
8+
var_dump($uri);
9+
var_dump($uri->toRawString());
10+
var_dump($uri->toString());
11+
12+
?>
13+
--EXPECTF--
14+
object(Uri\Rfc3986\Uri)#%d (%d) {
15+
["scheme"]=>
16+
string(6) "mailto"
17+
["username"]=>
18+
NULL
19+
["password"]=>
20+
NULL
21+
["host"]=>
22+
NULL
23+
["port"]=>
24+
NULL
25+
["path"]=>
26+
string(16) "[email protected]"
27+
["query"]=>
28+
NULL
29+
["fragment"]=>
30+
NULL
31+
}
32+
string(23) "mailto:[email protected]"
33+
string(23) "mailto:[email protected]"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - basic - empty string
3+
--FILE--
4+
<?php
5+
6+
$uri = Uri\Rfc3986\Uri::parse("");
7+
8+
var_dump($uri);
9+
var_dump($uri->toRawString());
10+
var_dump($uri->toString());
11+
12+
?>
13+
--EXPECTF--
14+
object(Uri\Rfc3986\Uri)#%d (%d) {
15+
["scheme"]=>
16+
NULL
17+
["username"]=>
18+
NULL
19+
["password"]=>
20+
NULL
21+
["host"]=>
22+
NULL
23+
["port"]=>
24+
NULL
25+
["path"]=>
26+
string(0) ""
27+
["query"]=>
28+
NULL
29+
["fragment"]=>
30+
NULL
31+
}
32+
string(0) ""
33+
string(0) ""
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - basic - file
3+
--FILE--
4+
<?php
5+
6+
$uri = Uri\Rfc3986\Uri::parse("file:///E:/Documents%20and%20Settings");
7+
8+
var_dump($uri);
9+
var_dump($uri->toRawString());
10+
var_dump($uri->toString());
11+
12+
?>
13+
--EXPECTF--
14+
object(Uri\Rfc3986\Uri)#%d (%d) {
15+
["scheme"]=>
16+
string(4) "file"
17+
["username"]=>
18+
NULL
19+
["password"]=>
20+
NULL
21+
["host"]=>
22+
string(0) ""
23+
["port"]=>
24+
NULL
25+
["path"]=>
26+
string(30) "/E:/Documents%20and%20Settings"
27+
["query"]=>
28+
NULL
29+
["fragment"]=>
30+
NULL
31+
}
32+
string(37) "file:///E:/Documents%20and%20Settings"
33+
string(37) "file:///E:/Documents%20and%20Settings"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - basic - URN
3+
--FILE--
4+
<?php
5+
6+
$uri = Uri\Rfc3986\Uri::parse("urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66");
7+
8+
var_dump($uri);
9+
var_dump($uri->toRawString());
10+
var_dump($uri->toString());
11+
12+
?>
13+
--EXPECTF--
14+
object(Uri\Rfc3986\Uri)#%d (%d) {
15+
["scheme"]=>
16+
string(3) "urn"
17+
["username"]=>
18+
NULL
19+
["password"]=>
20+
NULL
21+
["host"]=>
22+
NULL
23+
["port"]=>
24+
NULL
25+
["path"]=>
26+
string(41) "uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66"
27+
["query"]=>
28+
NULL
29+
["fragment"]=>
30+
NULL
31+
}
32+
string(45) "urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66"
33+
string(45) "urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - host - multibyte character
3+
--FILE--
4+
<?php
5+
6+
try {
7+
new Uri\Rfc3986\Uri("https://exḁmple.com");
8+
} catch (Throwable $e) {
9+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
10+
}
11+
12+
?>
13+
--EXPECT--
14+
Uri\InvalidUriException: The specified URI is malformed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri parsing - host - reserved character
3+
--FILE--
4+
<?php
5+
6+
try {
7+
new Uri\Rfc3986\Uri("https://ex[a]mple.com");
8+
} catch (Throwable $e) {
9+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
10+
}
11+
12+
?>
13+
--EXPECT--
14+
Uri\InvalidUriException: The specified URI is malformed

0 commit comments

Comments
 (0)