Skip to content

Commit 179f176

Browse files
committed
ext/uri: applied fixers to improve test robustness
1 parent 9dc4e19 commit 179f176

91 files changed

Lines changed: 182 additions & 182 deletions

File tree

Some content is hidden

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

ext/uri/tests/004.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var_dump(Uri\Rfc3986\Uri::parse(""));
1111
try {
1212
new Uri\WhatWg\Url("");
1313
} catch (Uri\WhatWg\InvalidUrlException $e) {
14-
echo $e->getMessage() . "\n";
14+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
1515
}
1616

1717
var_dump(Uri\WhatWg\Url::parse(""));
@@ -60,7 +60,7 @@ object(Uri\Rfc3986\Uri)#%d (%d) {
6060
["fragment"]=>
6161
NULL
6262
}
63-
The specified URI is malformed (MissingSchemeNonRelativeUrl)
63+
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)
6464
NULL
6565
object(Uri\Rfc3986\Uri)#%d (%d) {
6666
["scheme"]=>

ext/uri/tests/007.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ uri
88
try {
99
new Uri\Rfc3986\Uri("https://example.com:8080@username:password/path?q=r#fragment");
1010
} catch (Uri\InvalidUriException $e) {
11-
echo $e->getMessage() . "\n";
11+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
1212
}
1313

1414
try {
1515
new Uri\WhatWg\Url("https://example.com:8080@username:password/path?q=r#fragment");
1616
} catch (Uri\WhatWg\InvalidUrlException $e) {
17-
echo $e->getMessage() . "\n";
17+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
1818
var_dump($e->errors);
1919
}
2020

@@ -25,8 +25,8 @@ var_dump($failures);
2525

2626
?>
2727
--EXPECTF--
28-
The specified URI is malformed
29-
The specified URI is malformed (PortInvalid)
28+
Uri\InvalidUriException: The specified URI is malformed
29+
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (PortInvalid)
3030
array(%d) {
3131
[0]=>
3232
object(Uri\WhatWg\UrlValidationError)#%d (%d) {

ext/uri/tests/015.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ try {
1010
$reflectionClass = new ReflectionClass(Uri\Rfc3986\Uri::class);
1111
$reflectionClass->newInstanceWithoutConstructor();
1212
} catch (ReflectionException $e) {
13-
echo $e->getMessage() . "\n";
13+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
1414
}
1515

1616
try {
1717
$reflectionClass = new ReflectionClass(Uri\WhatWg\Url::class);
1818
$reflectionClass->newInstanceWithoutConstructor();
1919
} catch (ReflectionException $e) {
20-
echo $e->getMessage() . "\n";
20+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
2121
}
2222

2323
?>
2424
--EXPECT--
25-
Class Uri\Rfc3986\Uri is an internal class marked as final that cannot be instantiated without invoking its constructor
26-
Class Uri\WhatWg\Url is an internal class marked as final that cannot be instantiated without invoking its constructor
25+
ReflectionException: Class Uri\Rfc3986\Uri is an internal class marked as final that cannot be instantiated without invoking its constructor
26+
ReflectionException: Class Uri\WhatWg\Url is an internal class marked as final that cannot be instantiated without invoking its constructor

ext/uri/tests/023.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ var_dump($uri3->getScheme());
2020
try {
2121
$uri3->withScheme("");
2222
} catch (Uri\InvalidUriException $e) {
23-
echo $e->getMessage() . "\n";
23+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
2424
}
2525

2626
try {
2727
$uri3->withScheme("http%73");
2828
} catch (Uri\InvalidUriException $e) {
29-
echo $e->getMessage() . "\n";
29+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
3030
}
3131

3232
$url1 = Uri\WhatWg\Url::parse("https://example.com");
@@ -38,13 +38,13 @@ var_dump($url2->getScheme());
3838
try {
3939
$url2->withScheme("");
4040
} catch (Uri\WhatWg\InvalidUrlException $e) {
41-
echo $e->getMessage() . "\n";
41+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
4242
}
4343

4444
try {
4545
$url2->withScheme("http%73");
4646
} catch (Uri\WhatWg\InvalidUrlException $e) {
47-
echo $e->getMessage() . "\n";
47+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
4848
}
4949

5050
?>
@@ -55,9 +55,9 @@ string(4) "http"
5555
string(4) "http"
5656
NULL
5757
NULL
58-
The specified scheme is malformed
59-
The specified scheme is malformed
58+
Uri\InvalidUriException: The specified scheme is malformed
59+
Uri\InvalidUriException: The specified scheme is malformed
6060
string(5) "https"
6161
string(4) "http"
62-
The specified scheme is malformed
63-
The specified scheme is malformed
62+
Uri\WhatWg\InvalidUrlException: The specified scheme is malformed
63+
Uri\WhatWg\InvalidUrlException: The specified scheme is malformed

ext/uri/tests/026.phpt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,25 @@ var_dump($uri6->getHost());
3232
try {
3333
$uri3->withHost("test.com:8080");
3434
} catch (Uri\InvalidUriException $e) {
35-
echo $e->getMessage() . "\n";
35+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
3636
}
3737

3838
try {
3939
$uri3->withHost("t%3As%2Ft.com"); // t:s/t.com
4040
} catch (Uri\InvalidUriException $e) {
41-
echo $e->getMessage() . "\n";
41+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
4242
}
4343

4444
try {
4545
$uri3->withHost("t:s/t.com");
4646
} catch (Uri\InvalidUriException $e) {
47-
echo $e->getMessage() . "\n";
47+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
4848
}
4949

5050
try {
5151
$uri2->withHost("");
5252
} catch (Uri\InvalidUriException $e) {
53-
echo $e->getMessage() . "\n";
53+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
5454
}
5555

5656
$uri1 = Uri\Rfc3986\Uri::parse("ftp://user:pass@foo.com?query=abc#foo");
@@ -62,7 +62,7 @@ var_dump($uri2->getHost());
6262
try {
6363
$uri1->withHost(null);
6464
} catch (Uri\InvalidUriException $e) {
65-
echo $e->getMessage() . "\n";
65+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
6666
}
6767

6868
$url1 = Uri\WhatWg\Url::parse("https://example.com");
@@ -80,25 +80,25 @@ var_dump($url5->getAsciiHost());
8080
try {
8181
$url3->withHost("test.com:8080");
8282
} catch (Uri\WhatWg\InvalidUrlException $e) {
83-
echo $e->getMessage() . "\n";
83+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
8484
}
8585

8686
try {
8787
$url3->withHost("t%3As%2Ft.com"); // t:s/t.com
8888
} catch (Uri\WhatWg\InvalidUrlException $e) {
89-
echo $e->getMessage() . "\n";
89+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
9090
}
9191

9292
try {
9393
$url3->withHost("t:s/t.com"); // t:s/t.com
9494
} catch (Uri\WhatWg\InvalidUrlException $e) {
95-
echo $e->getMessage() . "\n";
95+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
9696
}
9797

9898
try {
9999
$url2->withHost(null);
100100
} catch (Uri\WhatWg\InvalidUrlException $e) {
101-
echo $e->getMessage() . "\n";
101+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
102102
}
103103

104104
$url1 = Uri\WhatWg\Url::parse("ftp://foo.com?query=abc#foo");
@@ -121,19 +121,19 @@ string(11) "192.168.0.1"
121121
string(11) "192.168.0.1"
122122
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
123123
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
124-
The specified host is malformed
125-
The specified host is malformed
124+
Uri\InvalidUriException: The specified host is malformed
125+
Uri\InvalidUriException: The specified host is malformed
126126
string(7) "foo.com"
127127
string(8) "test.com"
128-
Cannot remove the host from a URI that has a userinfo
128+
Uri\InvalidUriException: Cannot remove the host from a URI that has a userinfo
129129
string(11) "example.com"
130130
string(8) "test.com"
131131
string(8) "test.com"
132132
string(11) "192.168.0.1"
133133
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
134-
The specified host is malformed
135-
The specified host is malformed (DomainInvalidCodePoint)
136-
The specified host is malformed
137-
The specified host is malformed (HostMissing)
134+
Uri\WhatWg\InvalidUrlException: The specified host is malformed
135+
Uri\WhatWg\InvalidUrlException: The specified host is malformed (DomainInvalidCodePoint)
136+
Uri\WhatWg\InvalidUrlException: The specified host is malformed
137+
Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostMissing)
138138
string(7) "foo.com"
139139
string(8) "test.com"

ext/uri/tests/026_userinfo.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var_dump($uri2->getPort());
2828
try {
2929
$uri4->withUserInfo("u:s/r");
3030
} catch (Uri\InvalidUriException $e) {
31-
echo $e->getMessage() . "\n";
31+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
3232
}
3333

3434
$uri5 = Uri\Rfc3986\Uri::parse("file:///foo/bar/");
@@ -48,6 +48,6 @@ NULL
4848
string(13) "%75s%2Fr:pass"
4949
string(11) "us%2Fr:pass"
5050
NULL
51-
The specified userinfo is malformed
51+
Uri\InvalidUriException: The specified userinfo is malformed
5252
NULL
5353
string(9) "user:pass"

ext/uri/tests/027.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var_dump($uri2->getPort());
3232
try {
3333
$uri1->withPort(1);
3434
} catch (Uri\InvalidUriException $e) {
35-
echo $e->getMessage() . "\n";
35+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
3636
}
3737

3838
$url1 = Uri\WhatWg\Url::parse("https://example.com:8080");
@@ -65,7 +65,7 @@ int(8080)
6565
NULL
6666
int(80)
6767
NULL
68-
Cannot set a port without having a host
68+
Uri\InvalidUriException: Cannot set a port without having a host
6969
int(8080)
7070
int(22)
7171
NULL

ext/uri/tests/028.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ var_dump($uri5->getPath());
2828
try {
2929
$uri5->withPath("test");
3030
} catch (Uri\InvalidUriException $e) {
31-
echo $e->getMessage() . "\n";
31+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
3232
}
3333

3434
try {
3535
$uri5->withPath("/#");
3636
} catch (Uri\InvalidUriException $e) {
37-
echo $e->getMessage() . "\n";
37+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
3838
}
3939

4040
$uri1 = Uri\Rfc3986\Uri::parse("/foo");
@@ -75,8 +75,8 @@ string(10) "/foo%2Fbar"
7575
string(10) "/foo%2Fbar"
7676
string(0) ""
7777
string(0) ""
78-
The specified path is malformed
79-
The specified path is malformed
78+
Uri\InvalidUriException: The specified path is malformed
79+
Uri\InvalidUriException: The specified path is malformed
8080
string(4) "/foo"
8181
string(3) "bar"
8282
string(9) "/foo/bar/"

ext/uri/tests/029.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var_dump($uri5->getQuery());
4040
try {
4141
$uri5->withQuery("#");
4242
} catch (Uri\InvalidUriException $e) {
43-
echo $e->getMessage() . "\n";
43+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
4444
}
4545

4646
$url1 = Uri\WhatWg\Url::parse("https://example.com?foo=bar");
@@ -83,7 +83,7 @@ string(6) "t%65st"
8383
string(4) "test"
8484
string(25) "foo=foo%26bar&baz=/qux%3D"
8585
string(25) "foo=foo%26bar&baz=/qux%3D"
86-
The specified query is malformed
86+
Uri\InvalidUriException: The specified query is malformed
8787
string(7) "foo=bar"
8888
string(7) "foo=baz"
8989
NULL

ext/uri/tests/030.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ var_dump($uri3->getFragment());
2020
try {
2121
$uri3->withFragment(" ");
2222
} catch (Uri\InvalidUriException $e) {
23-
echo $e->getMessage() . "\n";
23+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
2424
}
2525

2626
try {
2727
$uri1->withFragment("#fragment2");
2828
} catch (Uri\InvalidUriException $e) {
29-
echo $e->getMessage() . "\n";
29+
echo $e::class, ': ', $e->getMessage(), \PHP_EOL;
3030
}
3131

3232
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com?abc=def");
@@ -59,8 +59,8 @@ string(9) "fragment2"
5959
string(9) "fragment2"
6060
NULL
6161
NULL
62-
The specified fragment is malformed
63-
The specified fragment is malformed
62+
Uri\InvalidUriException: The specified fragment is malformed
63+
Uri\InvalidUriException: The specified fragment is malformed
6464
NULL
6565
string(8) "fragment"
6666
string(9) "fragment1"

0 commit comments

Comments
 (0)