Skip to content

Commit a22793d

Browse files
authored
uri: Unify exception testing for modification tests (php#20368)
Catch any Throwable and print the exact class name.
1 parent 0e9c39d commit a22793d

24 files changed

+72
-72
lines changed

ext/uri/tests/rfc3986/modification/fragment_error_reserved.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withFragment("#fragment");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified fragment is malformed
18+
Uri\InvalidUriException: The specified fragment is malformed

ext/uri/tests/rfc3986/modification/fragment_error_unicode.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withFragment("ő");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified fragment is malformed
18+
Uri\InvalidUriException: The specified fragment is malformed

ext/uri/tests/rfc3986/modification/host_error_reserved.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withHost("ex#mple.com");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified host is malformed
18+
Uri\InvalidUriException: The specified host is malformed

ext/uri/tests/rfc3986/modification/path_error_reserved.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withPath("/[foo]");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified path is malformed
18+
Uri\InvalidUriException: The specified path is malformed

ext/uri/tests/rfc3986/modification/path_error_unicode.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withPath("");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified path is malformed
18+
Uri\InvalidUriException: The specified path is malformed

ext/uri/tests/rfc3986/modification/path_error_without_leading_slash.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withPath("foo");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified path is malformed
18+
Uri\InvalidUriException: The specified path is malformed

ext/uri/tests/rfc3986/modification/port_error_negative.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withPort(-1);
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified port is malformed
18+
Uri\InvalidUriException: The specified port is malformed

ext/uri/tests/rfc3986/modification/query_error_reserved.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withQuery("#foo");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified query is malformed
18+
Uri\InvalidUriException: The specified query is malformed

ext/uri/tests/rfc3986/modification/query_error_unicode.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withQuery("ő");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified query is malformed
18+
Uri\InvalidUriException: The specified query is malformed

ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
99

1010
try {
1111
$uri->withScheme("");
12-
} catch (Uri\InvalidUriException $e) {
13-
echo $e->getMessage() . "\n";
12+
} catch (Throwable $e) {
13+
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
1414
}
1515

1616
?>
1717
--EXPECT--
18-
The specified scheme is malformed
18+
Uri\InvalidUriException: The specified scheme is malformed

0 commit comments

Comments
 (0)