Skip to content

Commit e3d68a9

Browse files
committed
ext/uri: applied fixers to improve test robustness
1 parent 5332ab0 commit e3d68a9

18 files changed

Lines changed: 106 additions & 106 deletions

ext/uri/tests/004.phpt

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

1515
var_dump(Uri\WhatWg\Url::parse(""));
@@ -58,7 +58,7 @@ object(Uri\Rfc3986\Uri)#%d (%d) {
5858
["fragment"]=>
5959
NULL
6060
}
61-
The specified URI is malformed (MissingSchemeNonRelativeUrl)
61+
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl)
6262
NULL
6363
object(Uri\Rfc3986\Uri)#%d (%d) {
6464
["scheme"]=>

ext/uri/tests/007.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Test URI creation errors
66
try {
77
new Uri\Rfc3986\Uri("https://example.com:8080@username:password/path?q=r#fragment");
88
} catch (Uri\InvalidUriException $e) {
9-
echo $e->getMessage() . "\n";
9+
echo $e::class, ': ', $e->getMessage(), "\n";
1010
}
1111

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

@@ -23,8 +23,8 @@ var_dump($failures);
2323

2424
?>
2525
--EXPECTF--
26-
The specified URI is malformed
27-
The specified URI is malformed (PortInvalid)
26+
Uri\InvalidUriException: The specified URI is malformed
27+
Uri\WhatWg\InvalidUrlException: The specified URI is malformed (PortInvalid)
2828
array(%d) {
2929
[0]=>
3030
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(), "\n";
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(), "\n";
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
@@ -18,13 +18,13 @@ var_dump($uri3->getScheme());
1818
try {
1919
$uri3->withScheme("");
2020
} catch (Uri\InvalidUriException $e) {
21-
echo $e->getMessage() . "\n";
21+
echo $e::class, ': ', $e->getMessage(), "\n";
2222
}
2323

2424
try {
2525
$uri3->withScheme("http%73");
2626
} catch (Uri\InvalidUriException $e) {
27-
echo $e->getMessage() . "\n";
27+
echo $e::class, ': ', $e->getMessage(), "\n";
2828
}
2929

3030
$url1 = Uri\WhatWg\Url::parse("https://example.com");
@@ -36,13 +36,13 @@ var_dump($url2->getScheme());
3636
try {
3737
$url2->withScheme("");
3838
} catch (Uri\WhatWg\InvalidUrlException $e) {
39-
echo $e->getMessage() . "\n";
39+
echo $e::class, ': ', $e->getMessage(), "\n";
4040
}
4141

4242
try {
4343
$url2->withScheme("http%73");
4444
} catch (Uri\WhatWg\InvalidUrlException $e) {
45-
echo $e->getMessage() . "\n";
45+
echo $e::class, ': ', $e->getMessage(), "\n";
4646
}
4747

4848
?>
@@ -53,9 +53,9 @@ string(4) "http"
5353
string(4) "http"
5454
NULL
5555
NULL
56-
The specified scheme is malformed
57-
The specified scheme is malformed
56+
Uri\InvalidUriException: The specified scheme is malformed
57+
Uri\InvalidUriException: The specified scheme is malformed
5858
string(5) "https"
5959
string(4) "http"
60-
The specified scheme is malformed
61-
The specified scheme is malformed
60+
Uri\WhatWg\InvalidUrlException: The specified scheme is malformed
61+
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
@@ -30,25 +30,25 @@ var_dump($uri6->getHost());
3030
try {
3131
$uri3->withHost("test.com:8080");
3232
} catch (Uri\InvalidUriException $e) {
33-
echo $e->getMessage() . "\n";
33+
echo $e::class, ': ', $e->getMessage(), "\n";
3434
}
3535

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

4242
try {
4343
$uri3->withHost("t:s/t.com");
4444
} catch (Uri\InvalidUriException $e) {
45-
echo $e->getMessage() . "\n";
45+
echo $e::class, ': ', $e->getMessage(), "\n";
4646
}
4747

4848
try {
4949
$uri2->withHost("");
5050
} catch (Uri\InvalidUriException $e) {
51-
echo $e->getMessage() . "\n";
51+
echo $e::class, ': ', $e->getMessage(), "\n";
5252
}
5353

5454
$uri1 = Uri\Rfc3986\Uri::parse("ftp://user:pass@foo.com?query=abc#foo");
@@ -60,7 +60,7 @@ var_dump($uri2->getHost());
6060
try {
6161
$uri1->withHost(null);
6262
} catch (Uri\InvalidUriException $e) {
63-
echo $e->getMessage() . "\n";
63+
echo $e::class, ': ', $e->getMessage(), "\n";
6464
}
6565

6666
$url1 = Uri\WhatWg\Url::parse("https://example.com");
@@ -78,25 +78,25 @@ var_dump($url5->getAsciiHost());
7878
try {
7979
$url3->withHost("test.com:8080");
8080
} catch (Uri\WhatWg\InvalidUrlException $e) {
81-
echo $e->getMessage() . "\n";
81+
echo $e::class, ': ', $e->getMessage(), "\n";
8282
}
8383

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

9090
try {
9191
$url3->withHost("t:s/t.com"); // t:s/t.com
9292
} catch (Uri\WhatWg\InvalidUrlException $e) {
93-
echo $e->getMessage() . "\n";
93+
echo $e::class, ': ', $e->getMessage(), "\n";
9494
}
9595

9696
try {
9797
$url2->withHost(null);
9898
} catch (Uri\WhatWg\InvalidUrlException $e) {
99-
echo $e->getMessage() . "\n";
99+
echo $e::class, ': ', $e->getMessage(), "\n";
100100
}
101101

102102
$url1 = Uri\WhatWg\Url::parse("ftp://foo.com?query=abc#foo");
@@ -119,19 +119,19 @@ string(11) "192.168.0.1"
119119
string(11) "192.168.0.1"
120120
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
121121
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
122-
The specified host is malformed
123-
The specified host is malformed
122+
Uri\InvalidUriException: The specified host is malformed
123+
Uri\InvalidUriException: The specified host is malformed
124124
string(7) "foo.com"
125125
string(8) "test.com"
126-
Cannot remove the host from a URI that has a userinfo
126+
Uri\InvalidUriException: Cannot remove the host from a URI that has a userinfo
127127
string(11) "example.com"
128128
string(8) "test.com"
129129
string(8) "test.com"
130130
string(11) "192.168.0.1"
131131
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
132-
The specified host is malformed
133-
The specified host is malformed (DomainInvalidCodePoint)
134-
The specified host is malformed
135-
The specified host is malformed (HostMissing)
132+
Uri\WhatWg\InvalidUrlException: The specified host is malformed
133+
Uri\WhatWg\InvalidUrlException: The specified host is malformed (DomainInvalidCodePoint)
134+
Uri\WhatWg\InvalidUrlException: The specified host is malformed
135+
Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostMissing)
136136
string(7) "foo.com"
137137
string(8) "test.com"

ext/uri/tests/026_userinfo.phpt

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

3232
$uri5 = Uri\Rfc3986\Uri::parse("file:///foo/bar/");
@@ -46,6 +46,6 @@ NULL
4646
string(13) "%75s%2Fr:pass"
4747
string(11) "us%2Fr:pass"
4848
NULL
49-
The specified userinfo is malformed
49+
Uri\InvalidUriException: The specified userinfo is malformed
5050
NULL
5151
string(9) "user:pass"

ext/uri/tests/027.phpt

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

3636
$url1 = Uri\WhatWg\Url::parse("https://example.com:8080");
@@ -63,7 +63,7 @@ int(8080)
6363
NULL
6464
int(80)
6565
NULL
66-
Cannot set a port without having a host
66+
Uri\InvalidUriException: Cannot set a port without having a host
6767
int(8080)
6868
int(22)
6969
NULL

ext/uri/tests/028.phpt

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

3232
try {
3333
$uri5->withPath("/#");
3434
} catch (Uri\InvalidUriException $e) {
35-
echo $e->getMessage() . "\n";
35+
echo $e::class, ': ', $e->getMessage(), "\n";
3636
}
3737

3838
$uri1 = Uri\Rfc3986\Uri::parse("/foo");
@@ -73,8 +73,8 @@ string(10) "/foo%2Fbar"
7373
string(10) "/foo%2Fbar"
7474
string(0) ""
7575
string(0) ""
76-
The specified path is malformed
77-
The specified path is malformed
76+
Uri\InvalidUriException: The specified path is malformed
77+
Uri\InvalidUriException: The specified path is malformed
7878
string(4) "/foo"
7979
string(3) "bar"
8080
string(9) "/foo/bar/"

ext/uri/tests/029.phpt

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

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

ext/uri/tests/030.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ var_dump($uri3->getFragment());
1818
try {
1919
$uri3->withFragment(" ");
2020
} catch (Uri\InvalidUriException $e) {
21-
echo $e->getMessage() . "\n";
21+
echo $e::class, ': ', $e->getMessage(), "\n";
2222
}
2323

2424
try {
2525
$uri1->withFragment("#fragment2");
2626
} catch (Uri\InvalidUriException $e) {
27-
echo $e->getMessage() . "\n";
27+
echo $e::class, ': ', $e->getMessage(), "\n";
2828
}
2929

3030
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com?abc=def");
@@ -57,8 +57,8 @@ string(9) "fragment2"
5757
string(9) "fragment2"
5858
NULL
5959
NULL
60-
The specified fragment is malformed
61-
The specified fragment is malformed
60+
Uri\InvalidUriException: The specified fragment is malformed
61+
Uri\InvalidUriException: The specified fragment is malformed
6262
NULL
6363
string(8) "fragment"
6464
string(9) "fragment1"

0 commit comments

Comments
 (0)