mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
uri: Unify exception testing for modification tests (#20368)
Catch any Throwable and print the exact class name.
This commit is contained in:
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withFragment("#fragment");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified fragment is malformed
|
||||
Uri\InvalidUriException: The specified fragment is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withFragment("ő");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified fragment is malformed
|
||||
Uri\InvalidUriException: The specified fragment is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withHost("ex#mple.com");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified host is malformed
|
||||
Uri\InvalidUriException: The specified host is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withPath("/[foo]");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified path is malformed
|
||||
Uri\InvalidUriException: The specified path is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withPath("/ő");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified path is malformed
|
||||
Uri\InvalidUriException: The specified path is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withPath("foo");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified path is malformed
|
||||
Uri\InvalidUriException: The specified path is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withPort(-1);
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified port is malformed
|
||||
Uri\InvalidUriException: The specified port is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withQuery("#foo");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified query is malformed
|
||||
Uri\InvalidUriException: The specified query is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withQuery("ő");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified query is malformed
|
||||
Uri\InvalidUriException: The specified query is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withScheme("");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified scheme is malformed
|
||||
Uri\InvalidUriException: The specified scheme is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withScheme("http%73");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified scheme is malformed
|
||||
Uri\InvalidUriException: The specified scheme is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withScheme("https:");
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified scheme is malformed
|
||||
Uri\InvalidUriException: The specified scheme is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $uri = Uri\Rfc3986\Uri::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$uri->withUserInfo("us/r:password"); // us/r:password
|
||||
} catch (Uri\InvalidUriException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified userinfo is malformed
|
||||
Uri\InvalidUriException: The specified userinfo is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url->withHost("");
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified host is malformed (HostMissing)
|
||||
Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostMissing)
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("foo://example.com");
|
||||
|
||||
try {
|
||||
$url = $url->withHost("ex@mple.com");
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified host is malformed (HostInvalidCodePoint)
|
||||
Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostInvalidCodePoint)
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url = $url->withHost("ex@mple.com");
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified host is malformed (DomainInvalidCodePoint)
|
||||
Uri\WhatWg\InvalidUrlException: The specified host is malformed (DomainInvalidCodePoint)
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url = $url->withHost("ex:mple.com");
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified host is malformed
|
||||
Uri\WhatWg\InvalidUrlException: The specified host is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url = $url->withHost("ex:mple.com");
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified host is malformed
|
||||
Uri\WhatWg\InvalidUrlException: The specified host is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url = $url->withHost(null);
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified host is malformed (HostMissing)
|
||||
Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostMissing)
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url->withPort(-1);
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified port is malformed
|
||||
Uri\WhatWg\InvalidUrlException: The specified port is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url->withPort(65536);
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified port is malformed (PortOutOfRange)
|
||||
Uri\WhatWg\InvalidUrlException: The specified port is malformed (PortOutOfRange)
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url->withScheme("");
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified scheme is malformed
|
||||
Uri\WhatWg\InvalidUrlException: The specified scheme is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url->withScheme("http%73");
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified scheme is malformed
|
||||
Uri\WhatWg\InvalidUrlException: The specified scheme is malformed
|
||||
|
||||
@@ -9,10 +9,10 @@ $url = Uri\WhatWg\Url::parse("https://example.com");
|
||||
|
||||
try {
|
||||
$url->withScheme("http?");
|
||||
} catch (Uri\WhatWg\InvalidUrlException $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
} catch (Throwable $e) {
|
||||
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
The specified scheme is malformed
|
||||
Uri\WhatWg\InvalidUrlException: The specified scheme is malformed
|
||||
|
||||
Reference in New Issue
Block a user