From f7113b2fb980323feae8d5c4744524b2617405d7 Mon Sep 17 00:00:00 2001 From: NickSdot Date: Sat, 15 Aug 2026 01:52:45 +0700 Subject: [PATCH 1/5] ext/uri: removed superseded legacy tests --- ext/uri/tests/023.phpt | 61 --------------------- ext/uri/tests/026_userinfo.phpt | 51 ------------------ ext/uri/tests/028.phpt | 87 ------------------------------ ext/uri/tests/029.phpt | 93 --------------------------------- ext/uri/tests/030.phpt | 69 ------------------------ 5 files changed, 361 deletions(-) delete mode 100644 ext/uri/tests/023.phpt delete mode 100644 ext/uri/tests/026_userinfo.phpt delete mode 100644 ext/uri/tests/028.phpt delete mode 100644 ext/uri/tests/029.phpt delete mode 100644 ext/uri/tests/030.phpt diff --git a/ext/uri/tests/023.phpt b/ext/uri/tests/023.phpt deleted file mode 100644 index 8899abc16b6c..000000000000 --- a/ext/uri/tests/023.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -Test property mutation - scheme ---FILE-- -getRawScheme()); -var_dump($uri1->getScheme()); - -$uri2 = $uri1->withScheme("http"); -var_dump($uri2->getRawScheme()); -var_dump($uri2->getScheme()); - -$uri3 = $uri2->withScheme(null); -var_dump($uri3->getRawScheme()); -var_dump($uri3->getScheme()); - -try { - $uri3->withScheme(""); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $uri3->withScheme("http%73"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$url1 = Uri\WhatWg\Url::parse("https://example.com"); -$url2 = $url1->withScheme("http"); - -var_dump($url1->getScheme()); -var_dump($url2->getScheme()); - -try { - $url2->withScheme(""); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $url2->withScheme("http%73"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -?> ---EXPECT-- -string(5) "https" -string(5) "https" -string(4) "http" -string(4) "http" -NULL -NULL -Uri\InvalidUriException: The specified scheme is malformed -Uri\InvalidUriException: The specified scheme is malformed -string(5) "https" -string(4) "http" -Uri\WhatWg\InvalidUrlException: The specified scheme is malformed -Uri\WhatWg\InvalidUrlException: The specified scheme is malformed diff --git a/ext/uri/tests/026_userinfo.phpt b/ext/uri/tests/026_userinfo.phpt deleted file mode 100644 index a29abddf9720..000000000000 --- a/ext/uri/tests/026_userinfo.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -Test property mutation - userinfo ---FILE-- -getRawUserInfo()); -var_dump($uri1->getUserInfo()); - -$uri2 = $uri1->withUserInfo("user"); -var_dump($uri2->getRawUserInfo()); -var_dump($uri2->getUserInfo()); - -$uri3 = $uri2->withUserInfo(null); -var_dump($uri3->getRawUserInfo()); -var_dump($uri3->getUserInfo()); - -$uri4 = $uri3->withUserInfo("%75s%2Fr:pass"); // us/r:pass -var_dump($uri4->getRawUserInfo()); -var_dump($uri4->getUserInfo()); - -$uri1 = Uri\Rfc3986\Uri::parse("/foo"); -$uri2 = $uri1->withUserInfo(null); -var_dump($uri2->getPort()); - -try { - $uri4->withUserInfo("u:s/r"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$uri5 = Uri\Rfc3986\Uri::parse("file:///foo/bar/"); -$uri6 = $uri5->withUserinfo("user:pass"); - -var_dump($uri5->getUserInfo()); -var_dump($uri6->getUserInfo()); - -?> ---EXPECT-- -NULL -NULL -string(4) "user" -string(4) "user" -NULL -NULL -string(13) "%75s%2Fr:pass" -string(11) "us%2Fr:pass" -NULL -Uri\InvalidUriException: The specified userinfo is malformed -NULL -string(9) "user:pass" diff --git a/ext/uri/tests/028.phpt b/ext/uri/tests/028.phpt deleted file mode 100644 index 708a50d4f2ec..000000000000 --- a/ext/uri/tests/028.phpt +++ /dev/null @@ -1,87 +0,0 @@ ---TEST-- -Test property mutation - path ---FILE-- -getRawPath()); -var_dump($uri1->getPath()); - -$uri2 = $uri1->withPath("/foo"); -var_dump($uri2->getRawPath()); -var_dump($uri2->getPath()); - -$uri3 = $uri2->withPath("/t%65st"); -var_dump($uri3->getRawPath()); -var_dump($uri3->getPath()); - -$uri4 = $uri3->withPath("/foo%2Fbar"); -var_dump($uri4->getRawPath()); -var_dump($uri4->getPath()); - -$uri5 = $uri4->withPath(""); -var_dump($uri5->getRawPath()); -var_dump($uri5->getPath()); - -try { - $uri5->withPath("test"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $uri5->withPath("/#"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$uri1 = Uri\Rfc3986\Uri::parse("/foo"); -$uri2 = $uri1->withPath("bar"); - -var_dump($uri1->getPath()); -var_dump($uri2->getPath()); - -$url1 = Uri\WhatWg\Url::parse("https://example.com/foo/bar/"); -$url2 = $url1->withPath("/foo"); -$url3 = $url2->withPath(""); -$url4 = $url3->withPath("t%65st"); -$url5 = $url4->withPath("/foo%2Fbar"); -$url6 = $url5->withPath("/#"); - -var_dump($url1->getPath()); -var_dump($url2->getPath()); -var_dump($url3->getPath()); -var_dump($url4->getPath()); -var_dump($url5->getPath()); -var_dump($url6->getPath()); - -$url1 = Uri\WhatWg\Url::parse("https://example.com/"); -$uri2 = $url1->withPath("/foo"); - -var_dump($url1->getPath()); -var_dump($url2->getPath()); - -?> ---EXPECT-- -string(9) "/foo/bar/" -string(9) "/foo/bar/" -string(4) "/foo" -string(4) "/foo" -string(7) "/t%65st" -string(5) "/test" -string(10) "/foo%2Fbar" -string(10) "/foo%2Fbar" -string(0) "" -string(0) "" -Uri\InvalidUriException: The specified path is malformed -Uri\InvalidUriException: The specified path is malformed -string(4) "/foo" -string(3) "bar" -string(9) "/foo/bar/" -string(4) "/foo" -string(1) "/" -string(7) "/t%65st" -string(10) "/foo%2Fbar" -string(4) "/%23" -string(1) "/" -string(4) "/foo" diff --git a/ext/uri/tests/029.phpt b/ext/uri/tests/029.phpt deleted file mode 100644 index c1ce0e10d94c..000000000000 --- a/ext/uri/tests/029.phpt +++ /dev/null @@ -1,93 +0,0 @@ ---TEST-- -Test property mutation - query ---FILE-- -getRawQuery()); -var_dump($uri1->getQuery()); - -$uri2 = $uri1->withQuery("foo=baz"); -var_dump($uri2->getRawQuery()); -var_dump($uri2->getQuery()); - -$uri3 = $uri2->withQuery(null); -var_dump($uri3->getRawQuery()); -var_dump($uri3->getQuery()); - -$uri1 = Uri\Rfc3986\Uri::parse("https://example.com"); -var_dump($uri1->getRawQuery()); -var_dump($uri1->getQuery()); - -$uri2 = $uri1->withQuery("?foo=bar&foo=baz"); -var_dump($uri2->getRawQuery()); -var_dump($uri2->getQuery()); - -$uri3 = $uri1->withQuery("foo=bar&foo=baz"); -var_dump($uri3->getRawQuery()); -var_dump($uri3->getQuery()); - -$uri4 = $uri3->withQuery("t%65st"); -var_dump($uri4->getRawQuery()); -var_dump($uri4->getQuery()); - -$uri5 = $uri4->withQuery("foo=foo%26bar&baz=/qux%3D"); -var_dump($uri5->getRawQuery()); -var_dump($uri5->getQuery()); - -try { - $uri5->withQuery("#"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$url1 = Uri\WhatWg\Url::parse("https://example.com?foo=bar"); -$url2 = $url1->withQuery("?foo=baz"); -$url3 = $url2->withQuery(null); - -var_dump($url1->getQuery()); -var_dump($url2->getQuery()); -var_dump($url3->getQuery()); - -$url1 = Uri\WhatWg\Url::parse("https://example.com"); -$url2 = $url1->withQuery("?foo=bar&foo=baz"); -$url3 = $url1->withQuery("foo=bar&foo=baz"); -$url4 = $url3->withQuery("t%65st"); -$url5 = $url4->withQuery("foo=foo%26bar&baz=/qux%3D"); -$url6 = $url5->withQuery("#"); - -var_dump($url1->getQuery()); -var_dump($url2->getQuery()); -var_dump($url3->getQuery()); -var_dump($url4->getQuery()); -var_dump($url5->getQuery()); -var_dump($url6->getQuery()); - -?> ---EXPECT-- -string(7) "foo=bar" -string(7) "foo=bar" -string(7) "foo=baz" -string(7) "foo=baz" -NULL -NULL -NULL -NULL -string(16) "?foo=bar&foo=baz" -string(16) "?foo=bar&foo=baz" -string(15) "foo=bar&foo=baz" -string(15) "foo=bar&foo=baz" -string(6) "t%65st" -string(4) "test" -string(25) "foo=foo%26bar&baz=/qux%3D" -string(25) "foo=foo%26bar&baz=/qux%3D" -Uri\InvalidUriException: The specified query is malformed -string(7) "foo=bar" -string(7) "foo=baz" -NULL -NULL -string(15) "foo=bar&foo=baz" -string(15) "foo=bar&foo=baz" -string(6) "t%65st" -string(25) "foo=foo%26bar&baz=/qux%3D" -string(3) "%23" diff --git a/ext/uri/tests/030.phpt b/ext/uri/tests/030.phpt deleted file mode 100644 index e3df0f939980..000000000000 --- a/ext/uri/tests/030.phpt +++ /dev/null @@ -1,69 +0,0 @@ ---TEST-- -Test property mutation - fragment ---FILE-- -getRawFragment()); -var_dump($uri1->getFragment()); - -$uri2 = $uri1->withFragment("fragment2"); -var_dump($uri2->getRawFragment()); -var_dump($uri2->getFragment()); - -$uri3 = $uri2->withFragment(null); -var_dump($uri3->getRawFragment()); -var_dump($uri3->getFragment()); - -try { - $uri3->withFragment(" "); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $uri1->withFragment("#fragment2"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$uri1 = Uri\Rfc3986\Uri::parse("https://example.com?abc=def"); -$uri2 = $uri1->withFragment("fragment"); - -var_dump($uri1->getFragment()); -var_dump($uri2->getFragment()); - -$url1 = Uri\WhatWg\Url::parse("https://example.com#fragment1"); -$url2 = $url1->withFragment("#fragment2"); -$url3 = $url2->withFragment(null); -$url4 = $url3->withFragment(" "); - -var_dump($url1->getFragment()); -var_dump($url2->getFragment()); -var_dump($url3->getFragment()); -var_dump($url4->getFragment()); - -$url1 = Uri\WhatWg\Url::parse("https://example.com?abc=def"); -$url2 = $url1->withFragment("#fragment"); - -var_dump($url1->getFragment()); -var_dump($url2->getFragment()); - -?> ---EXPECT-- -string(9) "fragment1" -string(9) "fragment1" -string(9) "fragment2" -string(9) "fragment2" -NULL -NULL -Uri\InvalidUriException: The specified fragment is malformed -Uri\InvalidUriException: The specified fragment is malformed -NULL -string(8) "fragment" -string(9) "fragment1" -string(9) "fragment2" -NULL -string(3) "%20" -NULL -string(8) "fragment" From 1453b480dd52377f5ea1baf8341dd4796a6d6133 Mon Sep 17 00:00:00 2001 From: NickSdot Date: Sat, 15 Aug 2026 02:15:12 +0700 Subject: [PATCH 2/5] ext/uri: reorganised partially superseded legacy tests --- ext/uri/tests/004.phpt | 83 ----------- ext/uri/tests/007.phpt | 68 --------- ext/uri/tests/026.phpt | 137 ------------------ ext/uri/tests/027.phpt | 73 ---------- .../host_error_unset_with_userinfo.phpt | 16 ++ .../host_success_ipv4_to_ipv6.phpt | 21 +++ ...host_success_percent_encoded_reserved.phpt | 10 ++ .../modification/port_error_missing_host.phpt | 16 ++ .../modification/port_success_empty_host.phpt | 15 ++ .../port_success_unset_without_host.phpt | 13 ++ .../parsing/basic_error_returns_null.phpt | 10 ++ ...th_success_relative_reference_numeric.phpt | 29 ++++ .../port_success_file_scheme.phpt | 15 ++ .../parsing/basic_error_returns_null.phpt | 14 ++ ...sic_success_invalid_url_unit_warnings.phpt | 34 +++++ 15 files changed, 193 insertions(+), 361 deletions(-) delete mode 100644 ext/uri/tests/004.phpt delete mode 100644 ext/uri/tests/007.phpt delete mode 100644 ext/uri/tests/026.phpt delete mode 100644 ext/uri/tests/027.phpt create mode 100644 ext/uri/tests/rfc3986/modification/host_error_unset_with_userinfo.phpt create mode 100644 ext/uri/tests/rfc3986/modification/host_success_ipv4_to_ipv6.phpt create mode 100644 ext/uri/tests/rfc3986/modification/host_success_percent_encoded_reserved.phpt create mode 100644 ext/uri/tests/rfc3986/modification/port_error_missing_host.phpt create mode 100644 ext/uri/tests/rfc3986/modification/port_success_empty_host.phpt create mode 100644 ext/uri/tests/rfc3986/modification/port_success_unset_without_host.phpt create mode 100644 ext/uri/tests/rfc3986/parsing/basic_error_returns_null.phpt create mode 100644 ext/uri/tests/rfc3986/parsing/path_success_relative_reference_numeric.phpt create mode 100644 ext/uri/tests/whatwg/modification/port_success_file_scheme.phpt create mode 100644 ext/uri/tests/whatwg/parsing/basic_error_returns_null.phpt create mode 100644 ext/uri/tests/whatwg/parsing/basic_success_invalid_url_unit_warnings.phpt diff --git a/ext/uri/tests/004.phpt b/ext/uri/tests/004.phpt deleted file mode 100644 index c6ad96ce99a7..000000000000 --- a/ext/uri/tests/004.phpt +++ /dev/null @@ -1,83 +0,0 @@ ---TEST-- -Parse invalid URLs ---FILE-- -getMessage(), "\n"; -} - -var_dump(Uri\WhatWg\Url::parse("")); - -var_dump(Uri\Rfc3986\Uri::parse("192.168/contact.html")); -var_dump(Uri\WhatWg\Url::parse("192.168/contact.html", null)); - -var_dump(Uri\Rfc3986\Uri::parse("http://RuPaul's Drag Race All Stars 7 Winners Cast on This Season's")); -var_dump(Uri\WhatWg\Url::parse("http://RuPaul's Drag Race All Stars 7 Winners Cast on This Season's", null)); - -?> ---EXPECTF-- -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - NULL - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - NULL - ["port"]=> - NULL - ["path"]=> - string(0) "" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - NULL - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - NULL - ["port"]=> - NULL - ["path"]=> - string(0) "" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -Uri\WhatWg\InvalidUrlException: The specified URI is malformed (MissingSchemeNonRelativeUrl) -NULL -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - NULL - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - NULL - ["port"]=> - NULL - ["path"]=> - string(20) "192.168/contact.html" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -NULL -NULL -NULL diff --git a/ext/uri/tests/007.phpt b/ext/uri/tests/007.phpt deleted file mode 100644 index 9d2f389e2513..000000000000 --- a/ext/uri/tests/007.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -Test URI creation errors ---FILE-- -getMessage(), "\n"; -} - -try { - new Uri\WhatWg\Url("https://example.com:8080@username:password/path?q=r#fragment"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; - var_dump($e->errors); -} - -$failures = []; -$url = new Uri\WhatWg\Url(" https://example.org ", null, $failures); -var_dump($url->toAsciiString()); -var_dump($failures); - -?> ---EXPECTF-- -Uri\InvalidUriException: The specified URI is malformed -Uri\WhatWg\InvalidUrlException: The specified URI is malformed (PortInvalid) -array(%d) { - [0]=> - object(Uri\WhatWg\UrlValidationError)#%d (%d) { - ["context"]=> - string(26) "password/path?q=r#fragment" - ["type"]=> - enum(Uri\WhatWg\UrlValidationErrorType::PortInvalid) - ["failure"]=> - bool(true) - } - [1]=> - object(Uri\WhatWg\UrlValidationError)#%d (%d) { - ["context"]=> - string(36) "@username:password/path?q=r#fragment" - ["type"]=> - enum(Uri\WhatWg\UrlValidationErrorType::InvalidCredentials) - ["failure"]=> - bool(false) - } -} -string(20) "https://example.org/" -array(2) { - [0]=> - object(Uri\WhatWg\UrlValidationError)#%d (%d) { - ["context"]=> - string(1) " " - ["type"]=> - enum(Uri\WhatWg\UrlValidationErrorType::InvalidUrlUnit) - ["failure"]=> - bool(false) - } - [1]=> - object(Uri\WhatWg\UrlValidationError)#%d (%d) { - ["context"]=> - string(21) " https://example.org " - ["type"]=> - enum(Uri\WhatWg\UrlValidationErrorType::InvalidUrlUnit) - ["failure"]=> - bool(false) - } -} diff --git a/ext/uri/tests/026.phpt b/ext/uri/tests/026.phpt deleted file mode 100644 index 179b00d38572..000000000000 --- a/ext/uri/tests/026.phpt +++ /dev/null @@ -1,137 +0,0 @@ ---TEST-- -Test property mutation - host ---FILE-- -getRawHost()); -var_dump($uri1->getHost()); - -$uri2 = $uri1->withHost("test.com"); -var_dump($uri2->getRawHost()); -var_dump($uri2->getHost()); - -$uri3 = $uri2->withHost("t%65st.com"); // test.com -var_dump($uri3->getRawHost()); -var_dump($uri3->getHost()); - -$uri4 = $uri3->withHost(null); -var_dump($uri4->getRawHost()); -var_dump($uri4->getHost()); - -$uri5 = $uri4->withHost("192.168.0.1"); -var_dump($uri5->getRawHost()); -var_dump($uri5->getHost()); - -$uri6 = $uri5->withHost("[2001:db8:3333:4444:5555:6666:7777:8888]"); -var_dump($uri6->getRawHost()); -var_dump($uri6->getHost()); - -try { - $uri3->withHost("test.com:8080"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $uri3->withHost("t%3As%2Ft.com"); // t:s/t.com -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $uri3->withHost("t:s/t.com"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $uri2->withHost(""); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$uri1 = Uri\Rfc3986\Uri::parse("ftp://user:pass@foo.com?query=abc#foo"); -$uri2 = $uri1->withHost("test.com"); - -var_dump($uri1->getHost()); -var_dump($uri2->getHost()); - -try { - $uri1->withHost(null); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$url1 = Uri\WhatWg\Url::parse("https://example.com"); -$url2 = $url1->withHost("test.com"); -$url3 = $url2->withHost("t%65st.com"); // test.com -$url4 = $url3->withHost("192.168.0.1"); -$url5 = $url4->withHost("[2001:db8:3333:4444:5555:6666:7777:8888]"); - -var_dump($url1->getAsciiHost()); -var_dump($url2->getAsciiHost()); -var_dump($url3->getAsciiHost()); -var_dump($url4->getAsciiHost()); -var_dump($url5->getAsciiHost()); - -try { - $url3->withHost("test.com:8080"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $url3->withHost("t%3As%2Ft.com"); // t:s/t.com -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $url3->withHost("t:s/t.com"); // t:s/t.com -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - $url2->withHost(null); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$url1 = Uri\WhatWg\Url::parse("ftp://foo.com?query=abc#foo"); -$url2 = $url1->withHost("test.com"); - -var_dump($url1->getAsciiHost()); -var_dump($url2->getAsciiHost()); - -?> ---EXPECTF-- -string(11) "example.com" -string(11) "example.com" -string(8) "test.com" -string(8) "test.com" -string(10) "t%65st.com" -string(8) "test.com" -NULL -NULL -string(11) "192.168.0.1" -string(11) "192.168.0.1" -string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]" -string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]" -Uri\InvalidUriException: The specified host is malformed -Uri\InvalidUriException: The specified host is malformed -string(7) "foo.com" -string(8) "test.com" -Uri\InvalidUriException: Cannot remove the host from a URI that has a userinfo -string(11) "example.com" -string(8) "test.com" -string(8) "test.com" -string(11) "192.168.0.1" -string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]" -Uri\WhatWg\InvalidUrlException: The specified host is malformed -Uri\WhatWg\InvalidUrlException: The specified host is malformed (DomainInvalidCodePoint) -Uri\WhatWg\InvalidUrlException: The specified host is malformed -Uri\WhatWg\InvalidUrlException: The specified host is malformed (HostMissing) -string(7) "foo.com" -string(8) "test.com" diff --git a/ext/uri/tests/027.phpt b/ext/uri/tests/027.phpt deleted file mode 100644 index 2309cace93d9..000000000000 --- a/ext/uri/tests/027.phpt +++ /dev/null @@ -1,73 +0,0 @@ ---TEST-- -Test property mutation - port ---FILE-- -withPort(22); -$uri3 = $uri2->withPort(null); - -var_dump($uri1->getPort()); -var_dump($uri2->getPort()); -var_dump($uri3->getPort()); - -$uri1 = Uri\Rfc3986\Uri::parse("ftp://foo.com:443?query=abc#foo"); -$uri2 = $uri1->withPort(8080); - -var_dump($uri1->getPort()); -var_dump($uri2->getPort()); - -$uri1 = Uri\Rfc3986\Uri::parse("file:///foo/bar"); -$uri2 = $uri1->withPort(80); - -var_dump($uri1->getPort()); -var_dump($uri2->getPort()); - -$uri1 = Uri\Rfc3986\Uri::parse("/foo"); -$uri2 = $uri1->withPort(null); -var_dump($uri2->getPort()); - -try { - $uri1->withPort(1); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$url1 = Uri\WhatWg\Url::parse("https://example.com:8080"); -$url2 = $url1->withPort(22); -$url3 = $url2->withPort(null); - -var_dump($url1->getPort()); -var_dump($url2->getPort()); -var_dump($url3->getPort()); - -$url1 = Uri\WhatWg\Url::parse("ftp://foo.com:443?query=abc#foo"); -$url2 = $url1->withPort(8080); - -var_dump($url1->getPort()); -var_dump($url2->getPort()); - -$url1 = Uri\WhatWg\Url::parse("file:///foo/bar"); -$url2 = $url1->withPort(80); - -var_dump($url1->getPort()); -var_dump($url2->getPort()); - -?> ---EXPECT-- -int(8080) -int(22) -NULL -int(443) -int(8080) -NULL -int(80) -NULL -Uri\InvalidUriException: Cannot set a port without having a host -int(8080) -int(22) -NULL -int(443) -int(8080) -NULL -NULL diff --git a/ext/uri/tests/rfc3986/modification/host_error_unset_with_userinfo.phpt b/ext/uri/tests/rfc3986/modification/host_error_unset_with_userinfo.phpt new file mode 100644 index 000000000000..dd3a527ff9ed --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_error_unset_with_userinfo.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - unsetting with userinfo +--FILE-- +withHost(null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Uri\InvalidUriException: Cannot remove the host from a URI that has a userinfo diff --git a/ext/uri/tests/rfc3986/modification/host_success_ipv4_to_ipv6.phpt b/ext/uri/tests/rfc3986/modification/host_success_ipv4_to_ipv6.phpt new file mode 100644 index 000000000000..b91cefeb087d --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_ipv4_to_ipv6.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - changing IPv4 to IPv6 +--FILE-- +withHost(null); +$uri3 = $uri2->withHost("192.168.0.1"); +$uri4 = $uri3->withHost("[2001:db8:3333:4444:5555:6666:7777:8888]"); + +var_dump($uri3->getRawHost()); +var_dump($uri3->getHost()); +var_dump($uri4->getRawHost()); +var_dump($uri4->getHost()); + +?> +--EXPECT-- +string(11) "192.168.0.1" +string(11) "192.168.0.1" +string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]" +string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]" diff --git a/ext/uri/tests/rfc3986/modification/host_success_percent_encoded_reserved.phpt b/ext/uri/tests/rfc3986/modification/host_success_percent_encoded_reserved.phpt new file mode 100644 index 000000000000..26f12942ef42 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_percent_encoded_reserved.phpt @@ -0,0 +1,10 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - URL encoded reserved characters +--FILE-- +withHost("t%3As%2Ft.com"); + +?> +--EXPECT-- diff --git a/ext/uri/tests/rfc3986/modification/port_error_missing_host.phpt b/ext/uri/tests/rfc3986/modification/port_error_missing_host.phpt new file mode 100644 index 000000000000..51ab43185a4b --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/port_error_missing_host.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - port - missing host +--FILE-- +withPort(1); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Uri\InvalidUriException: Cannot set a port without having a host diff --git a/ext/uri/tests/rfc3986/modification/port_success_empty_host.phpt b/ext/uri/tests/rfc3986/modification/port_success_empty_host.phpt new file mode 100644 index 000000000000..91fc56fc488f --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/port_success_empty_host.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - port - adding with an empty host +--FILE-- +withPort(80); + +var_dump($uri1->getPort()); +var_dump($uri2->getPort()); + +?> +--EXPECT-- +NULL +int(80) diff --git a/ext/uri/tests/rfc3986/modification/port_success_unset_without_host.phpt b/ext/uri/tests/rfc3986/modification/port_success_unset_without_host.phpt new file mode 100644 index 000000000000..6d5ead807167 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/port_success_unset_without_host.phpt @@ -0,0 +1,13 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - port - unsetting without a host +--FILE-- +withPort(null); + +var_dump($uri2->getPort()); + +?> +--EXPECT-- +NULL diff --git a/ext/uri/tests/rfc3986/parsing/basic_error_returns_null.phpt b/ext/uri/tests/rfc3986/parsing/basic_error_returns_null.phpt new file mode 100644 index 000000000000..bb4992b7d175 --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/basic_error_returns_null.phpt @@ -0,0 +1,10 @@ +--TEST-- +Test Uri\Rfc3986\Uri::parse() returns null for a malformed URI +--FILE-- + +--EXPECT-- +NULL diff --git a/ext/uri/tests/rfc3986/parsing/path_success_relative_reference_numeric.phpt b/ext/uri/tests/rfc3986/parsing/path_success_relative_reference_numeric.phpt new file mode 100644 index 000000000000..ae014b2b9fd2 --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/path_success_relative_reference_numeric.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - path - numeric relative reference +--FILE-- + +--EXPECTF-- +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + NULL + ["username"]=> + NULL + ["password"]=> + NULL + ["host"]=> + NULL + ["port"]=> + NULL + ["path"]=> + string(20) "192.168/contact.html" + ["query"]=> + NULL + ["fragment"]=> + NULL +} diff --git a/ext/uri/tests/whatwg/modification/port_success_file_scheme.phpt b/ext/uri/tests/whatwg/modification/port_success_file_scheme.phpt new file mode 100644 index 000000000000..0d7241fb97cd --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_success_file_scheme.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - file scheme +--FILE-- +withPort(80); + +var_dump($url1->getPort()); +var_dump($url2->getPort()); + +?> +--EXPECT-- +NULL +NULL diff --git a/ext/uri/tests/whatwg/parsing/basic_error_returns_null.phpt b/ext/uri/tests/whatwg/parsing/basic_error_returns_null.phpt new file mode 100644 index 000000000000..8ce6c2e96fb0 --- /dev/null +++ b/ext/uri/tests/whatwg/parsing/basic_error_returns_null.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test Uri\WhatWg\Url::parse() returns null for malformed URLs +--FILE-- + +--EXPECT-- +NULL +NULL +NULL diff --git a/ext/uri/tests/whatwg/parsing/basic_success_invalid_url_unit_warnings.phpt b/ext/uri/tests/whatwg/parsing/basic_success_invalid_url_unit_warnings.phpt new file mode 100644 index 000000000000..9ee858362b97 --- /dev/null +++ b/ext/uri/tests/whatwg/parsing/basic_success_invalid_url_unit_warnings.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test Uri\WhatWg\Url parsing reports invalid URL unit warnings +--FILE-- +toAsciiString()); +var_dump($errors); + +?> +--EXPECTF-- +string(20) "https://example.org/" +array(2) { + [0]=> + object(Uri\WhatWg\UrlValidationError)#%d (%d) { + ["context"]=> + string(1) " " + ["type"]=> + enum(Uri\WhatWg\UrlValidationErrorType::InvalidUrlUnit) + ["failure"]=> + bool(false) + } + [1]=> + object(Uri\WhatWg\UrlValidationError)#%d (%d) { + ["context"]=> + string(21) " https://example.org " + ["type"]=> + enum(Uri\WhatWg\UrlValidationErrorType::InvalidUrlUnit) + ["failure"]=> + bool(false) + } +} From 26c3e2f45b786aa3f4b2049daa0c85bc9a3946c4 Mon Sep 17 00:00:00 2001 From: NickSdot Date: Sat, 15 Aug 2026 03:24:38 +0700 Subject: [PATCH 3/5] ext/uri: reorganised remaining legacy tests --- ext/uri/tests/031.phpt | 178 ------------------ ext/uri/tests/051.phpt | 42 ----- .../parsing/basic_error_relative_base.phpt} | 3 +- ...nstantiate_without_constructor_error.phpt} | 10 +- .../resolve_error_unicode.phpt | 16 ++ .../rfc3986/serialization/basic_success.phpt | 33 ++++ .../rfc3986/serialization/invalid_data.phpt | 63 +++++++ ...id_url_exception_constructor_reentry.phpt} | 2 +- ...nvalid_url_exception_errors_argument.phpt} | 0 ...validation_error_constructor_reentry.phpt} | 2 +- ...instantiate_without_constructor_error.phpt | 18 ++ .../parsing/port_error_too_large.phpt} | 6 +- .../parsing/zend_test_invalid_url.phpt} | 8 +- .../resolve_error_ipv4_too_many_parts.phpt | 16 ++ ...olve_success_invalid_url_unit_warning.phpt | 25 +++ .../whatwg/serialization/basic_success.phpt | 33 ++++ .../whatwg/serialization/invalid_data.phpt | 70 +++++++ 17 files changed, 286 insertions(+), 239 deletions(-) delete mode 100644 ext/uri/tests/031.phpt delete mode 100644 ext/uri/tests/051.phpt rename ext/uri/tests/{055.phpt => rfc3986/parsing/basic_error_relative_base.phpt} (82%) rename ext/uri/tests/{015.phpt => rfc3986/parsing/instantiate_without_constructor_error.phpt} (51%) create mode 100644 ext/uri/tests/rfc3986/reference_resolution/resolve_error_unicode.phpt create mode 100644 ext/uri/tests/rfc3986/serialization/basic_success.phpt create mode 100644 ext/uri/tests/rfc3986/serialization/invalid_data.phpt rename ext/uri/tests/{053.phpt => whatwg/exceptions/invalid_url_exception_constructor_reentry.phpt} (96%) rename ext/uri/tests/{gh19780.phpt => whatwg/exceptions/invalid_url_exception_errors_argument.phpt} (100%) rename ext/uri/tests/{052.phpt => whatwg/exceptions/url_validation_error_constructor_reentry.phpt} (91%) create mode 100644 ext/uri/tests/whatwg/parsing/instantiate_without_constructor_error.phpt rename ext/uri/tests/{054.phpt => whatwg/parsing/port_error_too_large.phpt} (53%) rename ext/uri/tests/{101.phpt => whatwg/parsing/zend_test_invalid_url.phpt} (67%) create mode 100644 ext/uri/tests/whatwg/reference_resolution/resolve_error_ipv4_too_many_parts.phpt create mode 100644 ext/uri/tests/whatwg/reference_resolution/resolve_success_invalid_url_unit_warning.phpt create mode 100644 ext/uri/tests/whatwg/serialization/basic_success.phpt create mode 100644 ext/uri/tests/whatwg/serialization/invalid_data.phpt diff --git a/ext/uri/tests/031.phpt b/ext/uri/tests/031.phpt deleted file mode 100644 index d60190457c1e..000000000000 --- a/ext/uri/tests/031.phpt +++ /dev/null @@ -1,178 +0,0 @@ ---TEST-- -Test serialization and unserialization ---FILE-- -getMessage(), "\n"; -} - -try { - unserialize('O:15:"Uri\Rfc3986\Uri":3:{i:0;a:0:{}i:1;a:0:{}i:2;a:0:{}}'); // more than 2 items -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;N;i:1;a:0:{}}'); // first item is not an array -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:0:{}i:1;a:0:{}}'); // first array is empty -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";i:1;}i:1;a:0:{}}'); // "uri" key in first array is not a string -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";s:2:"%1";}i:1;a:0:{}}'); // "uri" key in first array contains invalid URI -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";s:4:"/uri";}i:1;s:0:"";}'); // second item in not an array -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";s:4:"/uri";}i:1;a:1:{s:5:"prop1";i:123;}}'); // second array contains a property -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$url1 = new Uri\WhatWg\Url("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists"); -$serializedUrl1 = serialize($url1); -$url2 = unserialize($serializedUrl1); - -var_dump($serializedUrl1); -var_dump($url2); - -try { - unserialize('O:14:"Uri\WhatWg\Url":1:{i:0;a:0:{}}'); // less than 2 items -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:14:"Uri\WhatWg\Url":3:{i:0;a:0:{}i:1;a:0:{}i:2;a:0:{}}'); // more than 2 items -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;N;i:1;a:0:{}}'); // first item is not an array -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:0:{}i:1;a:0:{}}'); // first array is empty -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:2:{s:3:"uri";s:19:"https://example.com";s:1:"a";i:1;}i:1;a:0:{}}'); // "uri" key in first array contains more than 1 item -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";i:1;}i:1;a:0:{}}'); // "uri" key in first array is not a string -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";s:11:"invalid-url";}i:1;a:0:{}}'); // "uri" key in first array contains invalid URL -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";s:19:"https://example.com";}i:1;s:0:"";}'); // second item in not an array -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -try { - unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";s:19:"https://example.com";}i:1;a:1:{s:5:"prop1";i:123;}}'); // second array contains property -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -?> ---EXPECTF-- -string(164) "O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";s:99:"https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists";}i:1;a:0:{}}" -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - string(8) "username" - ["password"]=> - string(8) "password" - ["host"]=> - string(15) "www.example.com" - ["port"]=> - int(8080) - ["path"]=> - string(30) "/pathname1/pathname2/pathname3" - ["query"]=> - string(10) "query=true" - ["fragment"]=> - string(11) "hash-exists" -} -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -string(163) "O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";s:99:"https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists";}i:1;a:0:{}}" -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - string(8) "username" - ["password"]=> - string(8) "password" - ["host"]=> - string(15) "www.example.com" - ["port"]=> - int(8080) - ["path"]=> - string(30) "/pathname1/pathname2/pathname3" - ["query"]=> - string(10) "query=true" - ["fragment"]=> - string(11) "hash-exists" -} -Exception: Invalid serialization data for Uri\WhatWg\Url object -Exception: Invalid serialization data for Uri\WhatWg\Url object -Exception: Invalid serialization data for Uri\WhatWg\Url object -Exception: Invalid serialization data for Uri\WhatWg\Url object -Exception: Invalid serialization data for Uri\WhatWg\Url object -Exception: Invalid serialization data for Uri\WhatWg\Url object -Exception: Invalid serialization data for Uri\WhatWg\Url object -Exception: Invalid serialization data for Uri\WhatWg\Url object -Exception: Invalid serialization data for Uri\WhatWg\Url object diff --git a/ext/uri/tests/051.phpt b/ext/uri/tests/051.phpt deleted file mode 100644 index cb9c975d2385..000000000000 --- a/ext/uri/tests/051.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -Test resolve() method - error cases ---FILE-- -resolve("á"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$url = new Uri\WhatWg\Url("https://example.com"); - -try { - $url->resolve("https://1.2.3.4.5"); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - -$softErrors = []; - -var_dump($url->resolve(" /foo", $softErrors)->toAsciiString()); -var_dump($softErrors); - -?> ---EXPECTF-- -Uri\InvalidUriException: The specified URI is malformed -Uri\WhatWg\InvalidUrlException: The specified URI is malformed (Ipv4TooManyParts) -string(23) "https://example.com/foo" -array(%d) { - [0]=> - object(Uri\WhatWg\UrlValidationError)#%d (%d) { - ["context"]=> - string(5) " /foo" - ["type"]=> - enum(Uri\WhatWg\UrlValidationErrorType::InvalidUrlUnit) - ["failure"]=> - bool(false) - } -} diff --git a/ext/uri/tests/055.phpt b/ext/uri/tests/rfc3986/parsing/basic_error_relative_base.phpt similarity index 82% rename from ext/uri/tests/055.phpt rename to ext/uri/tests/rfc3986/parsing/basic_error_relative_base.phpt index fddb313149df..26c947a50afc 100644 --- a/ext/uri/tests/055.phpt +++ b/ext/uri/tests/rfc3986/parsing/basic_error_relative_base.phpt @@ -1,5 +1,5 @@ --TEST-- -Test InvalidUrlException constructor error handling +Test Uri\Rfc3986\Uri parsing with a relative base URI --FILE-- getMessage(), "\n"; } + ?> --EXPECT-- Uri\InvalidUriException: The specified base URI must be absolute diff --git a/ext/uri/tests/015.phpt b/ext/uri/tests/rfc3986/parsing/instantiate_without_constructor_error.phpt similarity index 51% rename from ext/uri/tests/015.phpt rename to ext/uri/tests/rfc3986/parsing/instantiate_without_constructor_error.phpt index e3a846f5e314..5806ec1f14e5 100644 --- a/ext/uri/tests/015.phpt +++ b/ext/uri/tests/rfc3986/parsing/instantiate_without_constructor_error.phpt @@ -1,5 +1,5 @@ --TEST-- -Test instantiation without calling constructor +Test Uri\Rfc3986\Uri instantiation without calling the constructor --EXTENSIONS-- reflection uri @@ -13,14 +13,6 @@ try { echo $e::class, ': ', $e->getMessage(), "\n"; } -try { - $reflectionClass = new ReflectionClass(Uri\WhatWg\Url::class); - $reflectionClass->newInstanceWithoutConstructor(); -} catch (Throwable $e) { - echo $e::class, ': ', $e->getMessage(), "\n"; -} - ?> --EXPECT-- ReflectionException: Class Uri\Rfc3986\Uri is an internal class marked as final that cannot be instantiated without invoking its constructor -ReflectionException: Class Uri\WhatWg\Url is an internal class marked as final that cannot be instantiated without invoking its constructor diff --git a/ext/uri/tests/rfc3986/reference_resolution/resolve_error_unicode.phpt b/ext/uri/tests/rfc3986/reference_resolution/resolve_error_unicode.phpt new file mode 100644 index 000000000000..3fcf488074ed --- /dev/null +++ b/ext/uri/tests/rfc3986/reference_resolution/resolve_error_unicode.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test Uri\Rfc3986\Uri reference resolution - resolve() - unicode +--FILE-- +resolve("á"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Uri\InvalidUriException: The specified URI is malformed diff --git a/ext/uri/tests/rfc3986/serialization/basic_success.phpt b/ext/uri/tests/rfc3986/serialization/basic_success.phpt new file mode 100644 index 000000000000..5a69491b1aaa --- /dev/null +++ b/ext/uri/tests/rfc3986/serialization/basic_success.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test Uri\Rfc3986\Uri serialization and unserialization +--FILE-- + +--EXPECTF-- +string(164) "O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";s:99:"https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists";}i:1;a:0:{}}" +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(5) "https" + ["username"]=> + string(8) "username" + ["password"]=> + string(8) "password" + ["host"]=> + string(15) "www.example.com" + ["port"]=> + int(8080) + ["path"]=> + string(30) "/pathname1/pathname2/pathname3" + ["query"]=> + string(10) "query=true" + ["fragment"]=> + string(11) "hash-exists" +} diff --git a/ext/uri/tests/rfc3986/serialization/invalid_data.phpt b/ext/uri/tests/rfc3986/serialization/invalid_data.phpt new file mode 100644 index 000000000000..d256fb0b7327 --- /dev/null +++ b/ext/uri/tests/rfc3986/serialization/invalid_data.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test Uri\Rfc3986\Uri unserialization with invalid data +--FILE-- +getMessage(), "\n"; +} + +try { + unserialize('O:15:"Uri\Rfc3986\Uri":3:{i:0;a:0:{}i:1;a:0:{}i:2;a:0:{}}'); // more than 2 items +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;N;i:1;a:0:{}}'); // first item is not an array +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:0:{}i:1;a:0:{}}'); // first array is empty +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";i:1;}i:1;a:0:{}}'); // "uri" key in first array is not a string +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";s:2:"%1";}i:1;a:0:{}}'); // "uri" key in first array contains invalid URI +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";s:4:"/uri";}i:1;s:0:"";}'); // second item in not an array +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:15:"Uri\Rfc3986\Uri":2:{i:0;a:1:{s:3:"uri";s:4:"/uri";}i:1;a:1:{s:5:"prop1";i:123;}}'); // second array contains a property +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Exception: Invalid serialization data for Uri\Rfc3986\Uri object +Exception: Invalid serialization data for Uri\Rfc3986\Uri object +Exception: Invalid serialization data for Uri\Rfc3986\Uri object +Exception: Invalid serialization data for Uri\Rfc3986\Uri object +Exception: Invalid serialization data for Uri\Rfc3986\Uri object +Exception: Invalid serialization data for Uri\Rfc3986\Uri object +Exception: Invalid serialization data for Uri\Rfc3986\Uri object +Exception: Invalid serialization data for Uri\Rfc3986\Uri object diff --git a/ext/uri/tests/053.phpt b/ext/uri/tests/whatwg/exceptions/invalid_url_exception_constructor_reentry.phpt similarity index 96% rename from ext/uri/tests/053.phpt rename to ext/uri/tests/whatwg/exceptions/invalid_url_exception_constructor_reentry.phpt index 7f68772e5487..c869299eaab1 100644 --- a/ext/uri/tests/053.phpt +++ b/ext/uri/tests/whatwg/exceptions/invalid_url_exception_constructor_reentry.phpt @@ -1,5 +1,5 @@ --TEST-- -Test InvalidUrlException constructor error handling +Test Uri\WhatWg\InvalidUrlException constructor reentry --FILE-- newInstanceWithoutConstructor(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +ReflectionException: Class Uri\WhatWg\Url is an internal class marked as final that cannot be instantiated without invoking its constructor diff --git a/ext/uri/tests/054.phpt b/ext/uri/tests/whatwg/parsing/port_error_too_large.phpt similarity index 53% rename from ext/uri/tests/054.phpt rename to ext/uri/tests/whatwg/parsing/port_error_too_large.phpt index 386f88ae93e5..f9e045728307 100644 --- a/ext/uri/tests/054.phpt +++ b/ext/uri/tests/whatwg/parsing/port_error_too_large.phpt @@ -1,13 +1,13 @@ --TEST-- -Test UrlValidationErrorType singleton +Test Uri\WhatWg\Url parsing - port - too large --FILE-- getMessage(), "\n"; - var_dump($e->errors[0]->type === \Uri\WhatWg\UrlValidationErrorType::PortOutOfRange); + var_dump($e->errors[0]->type === Uri\WhatWg\UrlValidationErrorType::PortOutOfRange); } ?> diff --git a/ext/uri/tests/101.phpt b/ext/uri/tests/whatwg/parsing/zend_test_invalid_url.phpt similarity index 67% rename from ext/uri/tests/101.phpt rename to ext/uri/tests/whatwg/parsing/zend_test_invalid_url.phpt index b00eeac8f804..659eabde89a0 100644 --- a/ext/uri/tests/101.phpt +++ b/ext/uri/tests/whatwg/parsing/zend_test_invalid_url.phpt @@ -1,15 +1,15 @@ --TEST-- -Test the Lexbor-based URI parser +Test zend_test_uri_parser() with an invalid Uri\WhatWg\Url --EXTENSIONS-- zend_test --FILE-- getMessage(), PHP_EOL; - var_dump($e->errors); + echo $e::class, ': ', $e->getMessage(), "\n"; + var_dump($e->errors); } ?> diff --git a/ext/uri/tests/whatwg/reference_resolution/resolve_error_ipv4_too_many_parts.phpt b/ext/uri/tests/whatwg/reference_resolution/resolve_error_ipv4_too_many_parts.phpt new file mode 100644 index 000000000000..fdcd96ef0b81 --- /dev/null +++ b/ext/uri/tests/whatwg/reference_resolution/resolve_error_ipv4_too_many_parts.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test Uri\WhatWg\Url reference resolution - resolve() - IPv4 with too many parts +--FILE-- +resolve("https://1.2.3.4.5"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Uri\WhatWg\InvalidUrlException: The specified URI is malformed (Ipv4TooManyParts) diff --git a/ext/uri/tests/whatwg/reference_resolution/resolve_success_invalid_url_unit_warning.phpt b/ext/uri/tests/whatwg/reference_resolution/resolve_success_invalid_url_unit_warning.phpt new file mode 100644 index 000000000000..c8a4a9033729 --- /dev/null +++ b/ext/uri/tests/whatwg/reference_resolution/resolve_success_invalid_url_unit_warning.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test Uri\WhatWg\Url reference resolution - resolve() - invalid URL unit warning +--FILE-- +resolve(" /foo", $softErrors)->toAsciiString()); +var_dump($softErrors); + +?> +--EXPECTF-- +string(23) "https://example.com/foo" +array(%d) { + [0]=> + object(Uri\WhatWg\UrlValidationError)#%d (%d) { + ["context"]=> + string(5) " /foo" + ["type"]=> + enum(Uri\WhatWg\UrlValidationErrorType::InvalidUrlUnit) + ["failure"]=> + bool(false) + } +} diff --git a/ext/uri/tests/whatwg/serialization/basic_success.phpt b/ext/uri/tests/whatwg/serialization/basic_success.phpt new file mode 100644 index 000000000000..d07bef85d05d --- /dev/null +++ b/ext/uri/tests/whatwg/serialization/basic_success.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test Uri\WhatWg\Url serialization and unserialization +--FILE-- + +--EXPECTF-- +string(163) "O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";s:99:"https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists";}i:1;a:0:{}}" +object(Uri\WhatWg\Url)#%d (%d) { + ["scheme"]=> + string(5) "https" + ["username"]=> + string(8) "username" + ["password"]=> + string(8) "password" + ["host"]=> + string(15) "www.example.com" + ["port"]=> + int(8080) + ["path"]=> + string(30) "/pathname1/pathname2/pathname3" + ["query"]=> + string(10) "query=true" + ["fragment"]=> + string(11) "hash-exists" +} diff --git a/ext/uri/tests/whatwg/serialization/invalid_data.phpt b/ext/uri/tests/whatwg/serialization/invalid_data.phpt new file mode 100644 index 000000000000..24e5059715a5 --- /dev/null +++ b/ext/uri/tests/whatwg/serialization/invalid_data.phpt @@ -0,0 +1,70 @@ +--TEST-- +Test Uri\WhatWg\Url unserialization with invalid data +--FILE-- +getMessage(), "\n"; +} + +try { + unserialize('O:14:"Uri\WhatWg\Url":3:{i:0;a:0:{}i:1;a:0:{}i:2;a:0:{}}'); // more than 2 items +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;N;i:1;a:0:{}}'); // first item is not an array +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:0:{}i:1;a:0:{}}'); // first array is empty +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:2:{s:3:"uri";s:19:"https://example.com";s:1:"a";i:1;}i:1;a:0:{}}'); // "uri" key in first array contains more than 1 item +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";i:1;}i:1;a:0:{}}'); // "uri" key in first array is not a string +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";s:11:"invalid-url";}i:1;a:0:{}}'); // "uri" key in first array contains invalid URL +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";s:19:"https://example.com";}i:1;s:0:"";}'); // second item in not an array +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +try { + unserialize('O:14:"Uri\WhatWg\Url":2:{i:0;a:1:{s:3:"uri";s:19:"https://example.com";}i:1;a:1:{s:5:"prop1";i:123;}}'); // second array contains property +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Exception: Invalid serialization data for Uri\WhatWg\Url object +Exception: Invalid serialization data for Uri\WhatWg\Url object +Exception: Invalid serialization data for Uri\WhatWg\Url object +Exception: Invalid serialization data for Uri\WhatWg\Url object +Exception: Invalid serialization data for Uri\WhatWg\Url object +Exception: Invalid serialization data for Uri\WhatWg\Url object +Exception: Invalid serialization data for Uri\WhatWg\Url object +Exception: Invalid serialization data for Uri\WhatWg\Url object +Exception: Invalid serialization data for Uri\WhatWg\Url object From fbf59b9a063f2e757c9905798d289da90de388a8 Mon Sep 17 00:00:00 2001 From: NickSdot Date: Sat, 15 Aug 2026 14:59:13 +0700 Subject: [PATCH 4/5] ext/uri: reorganised remaining legacy tests --- ext/uri/tests/006.phpt | 49 -------- ext/uri/tests/012.phpt | 85 ------------- ext/uri/tests/014.phpt | 13 -- ext/uri/tests/018.phpt | 89 -------------- ext/uri/tests/024.phpt | 27 ---- ext/uri/tests/025.phpt | 27 ---- ext/uri/tests/041.phpt | 45 ------- ext/uri/tests/042.phpt | 48 -------- ext/uri/tests/045.phpt | 23 ---- ext/uri/tests/050.phpt | 21 ---- ext/uri/tests/059.phpt | 29 ----- ext/uri/tests/065.phpt | 115 ------------------ ext/uri/tests/gh22046.phpt | 19 --- .../getters/basic_success.phpt} | 30 +---- .../getters/percent_encoded_components.phpt} | 30 +---- .../parsing/basic_success_constructor.phpt | 27 ++++ .../parsing/extension_error.phpt} | 0 .../parsing/host_success_ip_addresses.phpt} | 20 +-- ext/uri/tests/rfc3986/parsing/idna_error.phpt | 12 ++ .../tests/rfc3986/parsing/normalization.phpt | 18 +++ ...ath_success_percent_encoded_reserved.phpt} | 11 +- .../parsing/path_success_variants.phpt} | 23 +--- .../percent_encoding_normalization.phpt} | 0 .../parsing/port_error_overflow.phpt} | 2 +- .../parsing/query_success_variants.phpt | 53 ++++++++ .../parsing/special_references.phpt} | 26 +--- .../parsing/zend_test_parse_url.phpt} | 0 .../zend_test_port_success_large.phpt} | 0 .../parse_success_variants.phpt} | 64 +--------- .../parse_success_with_base.phpt} | 41 +------ .../resolve_success_basic.phpt | 14 +++ .../serialization/array_cast_success.phpt} | 7 +- .../serialization/clone_success.phpt} | 16 +-- .../serialization/json_encode_success.phpt} | 6 +- .../serialization/legacy_format_error.phpt | 11 ++ .../serialization/reinitialization_error.phpt | 61 ++++++++++ .../string_conversion_success.phpt | 23 ++++ .../serialization/var_export_success.phpt} | 8 +- .../tests/whatwg/getters/basic_success.phpt | 28 +++++ .../getters/percent_encoded_components.phpt | 28 +++++ .../username_success_encoded.phpt | 15 +++ .../username_success_file_scheme.phpt | 15 +++ .../parsing/basic_success_constructor.phpt | 27 ++++ .../parsing/basic_success_multibyte.phpt} | 5 +- .../parsing/errors_reference_error.phpt} | 2 +- .../parsing/errors_success_empty.phpt} | 0 .../parsing/extension_error.phpt} | 0 .../parsing/host_success_ip_addresses.phpt | 25 ++++ .../parsing/idna_support.phpt} | 10 +- .../parsing/memory_management.phpt} | 0 .../parsing/normalization.phpt} | 15 +-- ...path_success_percent_encoded_reserved.phpt | 14 +++ .../whatwg/parsing/path_success_variants.phpt | 25 ++++ .../parsing/query_success_variants.phpt} | 49 +------- .../parse_success_variants.phpt | 66 ++++++++++ .../parse_success_with_base.phpt | 46 +++++++ .../resolve_success_basic.phpt | 14 +++ ...lve_success_relative_with_query_base.phpt} | 0 .../serialization/array_cast_success.phpt | 11 ++ .../serialization/clone_success.phpt} | 23 ++-- .../serialization/json_encode_success.phpt | 10 ++ .../serialization/legacy_format_error.phpt | 12 ++ .../serialization/reinitialization_error.phpt | 61 ++++++++++ .../string_conversion_success.phpt} | 18 +-- .../serialization/var_export_success.phpt | 12 ++ 65 files changed, 672 insertions(+), 952 deletions(-) delete mode 100644 ext/uri/tests/006.phpt delete mode 100644 ext/uri/tests/012.phpt delete mode 100644 ext/uri/tests/014.phpt delete mode 100644 ext/uri/tests/018.phpt delete mode 100644 ext/uri/tests/024.phpt delete mode 100644 ext/uri/tests/025.phpt delete mode 100644 ext/uri/tests/041.phpt delete mode 100644 ext/uri/tests/042.phpt delete mode 100644 ext/uri/tests/045.phpt delete mode 100644 ext/uri/tests/050.phpt delete mode 100644 ext/uri/tests/059.phpt delete mode 100644 ext/uri/tests/065.phpt delete mode 100644 ext/uri/tests/gh22046.phpt rename ext/uri/tests/{008.phpt => rfc3986/getters/basic_success.phpt} (62%) rename ext/uri/tests/{039.phpt => rfc3986/getters/percent_encoded_components.phpt} (61%) create mode 100644 ext/uri/tests/rfc3986/parsing/basic_success_constructor.phpt rename ext/uri/tests/{021.phpt => rfc3986/parsing/extension_error.phpt} (100%) rename ext/uri/tests/{047.phpt => rfc3986/parsing/host_success_ip_addresses.phpt} (63%) create mode 100644 ext/uri/tests/rfc3986/parsing/idna_error.phpt create mode 100644 ext/uri/tests/rfc3986/parsing/normalization.phpt rename ext/uri/tests/{049.phpt => rfc3986/parsing/path_success_percent_encoded_reserved.phpt} (56%) rename ext/uri/tests/{046.phpt => rfc3986/parsing/path_success_variants.phpt} (72%) rename ext/uri/tests/{048.phpt => rfc3986/parsing/percent_encoding_normalization.phpt} (100%) rename ext/uri/tests/{058.phpt => rfc3986/parsing/port_error_overflow.phpt} (93%) create mode 100644 ext/uri/tests/rfc3986/parsing/query_success_variants.phpt rename ext/uri/tests/{003.phpt => rfc3986/parsing/special_references.phpt} (57%) rename ext/uri/tests/{100.phpt => rfc3986/parsing/zend_test_parse_url.phpt} (100%) rename ext/uri/tests/{102.phpt => rfc3986/parsing/zend_test_port_success_large.phpt} (100%) rename ext/uri/tests/{043.phpt => rfc3986/reference_resolution/parse_success_variants.phpt} (58%) rename ext/uri/tests/{010.phpt => rfc3986/reference_resolution/parse_success_with_base.phpt} (50%) create mode 100644 ext/uri/tests/rfc3986/reference_resolution/resolve_success_basic.phpt rename ext/uri/tests/{034.phpt => rfc3986/serialization/array_cast_success.phpt} (53%) rename ext/uri/tests/{009.phpt => rfc3986/serialization/clone_success.phpt} (59%) rename ext/uri/tests/{032.phpt => rfc3986/serialization/json_encode_success.phpt} (52%) create mode 100644 ext/uri/tests/rfc3986/serialization/legacy_format_error.phpt create mode 100644 ext/uri/tests/rfc3986/serialization/reinitialization_error.phpt create mode 100644 ext/uri/tests/rfc3986/serialization/string_conversion_success.phpt rename ext/uri/tests/{033.phpt => rfc3986/serialization/var_export_success.phpt} (52%) create mode 100644 ext/uri/tests/whatwg/getters/basic_success.phpt create mode 100644 ext/uri/tests/whatwg/getters/percent_encoded_components.phpt create mode 100644 ext/uri/tests/whatwg/modification/username_success_encoded.phpt create mode 100644 ext/uri/tests/whatwg/modification/username_success_file_scheme.phpt create mode 100644 ext/uri/tests/whatwg/parsing/basic_success_constructor.phpt rename ext/uri/tests/{005.phpt => whatwg/parsing/basic_success_multibyte.phpt} (86%) rename ext/uri/tests/{057.phpt => whatwg/parsing/errors_reference_error.phpt} (85%) rename ext/uri/tests/{gh19892.phpt => whatwg/parsing/errors_success_empty.phpt} (100%) rename ext/uri/tests/{022.phpt => whatwg/parsing/extension_error.phpt} (100%) create mode 100644 ext/uri/tests/whatwg/parsing/host_success_ip_addresses.phpt rename ext/uri/tests/{019.phpt => whatwg/parsing/idna_support.phpt} (86%) rename ext/uri/tests/{056.phpt => whatwg/parsing/memory_management.phpt} (100%) rename ext/uri/tests/{011.phpt => whatwg/parsing/normalization.phpt} (56%) create mode 100644 ext/uri/tests/whatwg/parsing/path_success_percent_encoded_reserved.phpt create mode 100644 ext/uri/tests/whatwg/parsing/path_success_variants.phpt rename ext/uri/tests/{013.phpt => whatwg/parsing/query_success_variants.phpt} (61%) create mode 100644 ext/uri/tests/whatwg/reference_resolution/parse_success_variants.phpt create mode 100644 ext/uri/tests/whatwg/reference_resolution/parse_success_with_base.phpt create mode 100644 ext/uri/tests/whatwg/reference_resolution/resolve_success_basic.phpt rename ext/uri/tests/{gh19979.phpt => whatwg/reference_resolution/resolve_success_relative_with_query_base.phpt} (100%) create mode 100644 ext/uri/tests/whatwg/serialization/array_cast_success.phpt rename ext/uri/tests/{040.phpt => whatwg/serialization/clone_success.phpt} (55%) create mode 100644 ext/uri/tests/whatwg/serialization/json_encode_success.phpt create mode 100644 ext/uri/tests/whatwg/serialization/legacy_format_error.phpt create mode 100644 ext/uri/tests/whatwg/serialization/reinitialization_error.phpt rename ext/uri/tests/{038.phpt => whatwg/serialization/string_conversion_success.phpt} (51%) create mode 100644 ext/uri/tests/whatwg/serialization/var_export_success.phpt diff --git a/ext/uri/tests/006.phpt b/ext/uri/tests/006.phpt deleted file mode 100644 index e7fa79a8b837..000000000000 --- a/ext/uri/tests/006.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -Test successful manual Uri child instance creation ---FILE-- - ---EXPECTF-- -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - string(8) "username" - ["password"]=> - string(8) "password" - ["host"]=> - string(11) "example.com" - ["port"]=> - int(8080) - ["path"]=> - string(5) "/path" - ["query"]=> - string(3) "q=r" - ["fragment"]=> - string(8) "fragment" -} -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - string(8) "username" - ["password"]=> - string(8) "password" - ["host"]=> - string(11) "example.com" - ["port"]=> - int(8080) - ["path"]=> - string(5) "/path" - ["query"]=> - string(3) "q=r" - ["fragment"]=> - string(8) "fragment" -} diff --git a/ext/uri/tests/012.phpt b/ext/uri/tests/012.phpt deleted file mode 100644 index e033223a6426..000000000000 --- a/ext/uri/tests/012.phpt +++ /dev/null @@ -1,85 +0,0 @@ ---TEST-- -Test parsing of various schemes ---FILE-- - ---EXPECTF-- -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - string(6) "mailto" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - NULL - ["port"]=> - NULL - ["path"]=> - string(15) "Joe@Example.COM" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(6) "mailto" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - NULL - ["port"]=> - NULL - ["path"]=> - string(15) "Joe@Example.COM" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - string(4) "file" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(0) "" - ["port"]=> - NULL - ["path"]=> - string(30) "/E:/Documents%20and%20Settings" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(4) "file" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(0) "" - ["port"]=> - NULL - ["path"]=> - string(30) "/E:/Documents%20and%20Settings" - ["query"]=> - NULL - ["fragment"]=> - NULL -} diff --git a/ext/uri/tests/014.phpt b/ext/uri/tests/014.phpt deleted file mode 100644 index 2966e2a9dcf1..000000000000 --- a/ext/uri/tests/014.phpt +++ /dev/null @@ -1,13 +0,0 @@ ---TEST-- -Test recomposition of URIs ---FILE-- -toRawString()); - -var_dump(Uri\WhatWg\Url::parse("http://example.com?foo=Hell%C3%B3+W%C3%B6rld")->toAsciiString()); - -?> ---EXPECT-- -string(44) "http://example.com?foo=Hell%C3%B3+W%C3%B6rld" -string(45) "http://example.com/?foo=Hell%C3%B3+W%C3%B6rld" diff --git a/ext/uri/tests/018.phpt b/ext/uri/tests/018.phpt deleted file mode 100644 index 7a7be9b3c19f..000000000000 --- a/ext/uri/tests/018.phpt +++ /dev/null @@ -1,89 +0,0 @@ ---TEST-- -Test property mutation ---FILE-- - ---EXPECTF-- -object(Uri\Rfc3986\Uri)#1 (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(0) "" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\Rfc3986\Uri)#2 (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(0) "" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\WhatWg\Url)#3 (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(1) "/" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\WhatWg\Url)#4 (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(1) "/" - ["query"]=> - NULL - ["fragment"]=> - NULL -} diff --git a/ext/uri/tests/024.phpt b/ext/uri/tests/024.phpt deleted file mode 100644 index 4147ff3ae124..000000000000 --- a/ext/uri/tests/024.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Test property mutation - username ---FILE-- -withUsername("user"); -$url3 = $url2->withUsername(null); -$url4 = $url3->withUsername("%75s%2Fr"); // us/r -$url5 = $url4->withUsername("u:s/r"); - -$url6 = Uri\WhatWg\Url::parse("file:///foo/bar/"); -$url6 = $url6->withUsername("user"); - -var_dump($url2->getUsername()); -var_dump($url3->getUsername()); -var_dump($url4->getUsername()); -var_dump($url5->getUsername()); -var_dump($url6->getUsername()); - -?> ---EXPECT-- -string(4) "user" -NULL -string(8) "%75s%2Fr" -string(9) "u%3As%2Fr" -NULL diff --git a/ext/uri/tests/025.phpt b/ext/uri/tests/025.phpt deleted file mode 100644 index a6dd505fcca1..000000000000 --- a/ext/uri/tests/025.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Test property mutation - password ---FILE-- -withPassword("pass"); -$url3 = $url2->withPassword(null); -$url4 = $url3->withPassword("p%61ss"); -$url5 = $url4->withPassword("p:s/"); - -$url6 = Uri\WhatWg\Url::parse("file:///foo/bar/"); -$url6 = $url6->withUsername("pass"); - -var_dump($url2->getPassword()); -var_dump($url3->getPassword()); -var_dump($url4->getPassword()); -var_dump($url5->getPassword()); -var_dump($url6->getPassword()); - -?> ---EXPECT-- -string(4) "pass" -NULL -string(6) "p%61ss" -string(8) "p%3As%2F" -NULL diff --git a/ext/uri/tests/041.phpt b/ext/uri/tests/041.phpt deleted file mode 100644 index 59a8e3211f97..000000000000 --- a/ext/uri/tests/041.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -Test relative URI parsing ---FILE-- - ---EXPECTF-- -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - NULL - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - NULL - ["port"]=> - NULL - ["path"]=> - string(0) "" - ["query"]=> - string(5) "query" - ["fragment"]=> - string(8) "fragment" -} -NULL -array(%d) { - [0]=> - object(Uri\WhatWg\UrlValidationError)#%d (%d) { - ["context"]=> - string(15) "?query#fragment" - ["type"]=> - enum(Uri\WhatWg\UrlValidationErrorType::MissingSchemeNonRelativeUrl) - ["failure"]=> - bool(true) - } -} diff --git a/ext/uri/tests/042.phpt b/ext/uri/tests/042.phpt deleted file mode 100644 index aadb9e5c192f..000000000000 --- a/ext/uri/tests/042.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Test URN parsing ---FILE-- - ---EXPECTF-- -object(Uri\Rfc3986\Uri)#%d (%d) { - ["scheme"]=> - string(3) "urn" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - NULL - ["port"]=> - NULL - ["path"]=> - string(41) "uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(3) "urn" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - NULL - ["port"]=> - NULL - ["path"]=> - string(41) "uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66" - ["query"]=> - NULL - ["fragment"]=> - NULL -} diff --git a/ext/uri/tests/045.phpt b/ext/uri/tests/045.phpt deleted file mode 100644 index f968716f9fcd..000000000000 --- a/ext/uri/tests/045.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Test percent-decoding of reserved characters in the path ---FILE-- -toRawString()); -var_dump($uri->getPath()); -var_dump($uri->getRawPath()); - -$url = new Uri\Whatwg\Url("https://example.com/foo/bar%2Fbaz"); - -var_dump($url->toAsciiString()); -var_dump($url->getPath()); - -?> ---EXPECT-- -string(33) "https://example.com/foo/bar%2Fbaz" -string(14) "/foo/bar%2Fbaz" -string(14) "/foo/bar%2Fbaz" -string(33) "https://example.com/foo/bar%2Fbaz" -string(14) "/foo/bar%2Fbaz" diff --git a/ext/uri/tests/050.phpt b/ext/uri/tests/050.phpt deleted file mode 100644 index 3bd4052fb80c..000000000000 --- a/ext/uri/tests/050.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Test resolve() method - success cases ---FILE-- -resolve("/foo/")->toString()); -var_dump($uri->resolve("https://test.com/foo")->toString()); - -$url = new Uri\WhatWg\Url("https://example.com"); - -var_dump($url->resolve("/foo/")->toAsciiString()); -var_dump($url->resolve("https://test.com/foo")->toAsciiString()); - -?> ---EXPECTF-- -string(24) "https://example.com/foo/" -string(20) "https://test.com/foo" -string(24) "https://example.com/foo/" -string(20) "https://test.com/foo" diff --git a/ext/uri/tests/059.phpt b/ext/uri/tests/059.phpt deleted file mode 100644 index 23971cd4ebe0..000000000000 --- a/ext/uri/tests/059.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Test empty ports become null ---FILE-- -getPort()); - -?> ---EXPECTF-- -object(Uri\Rfc3986\Uri)#%d (8) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(0) "" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -NULL diff --git a/ext/uri/tests/065.phpt b/ext/uri/tests/065.phpt deleted file mode 100644 index 2c84cceea3d4..000000000000 --- a/ext/uri/tests/065.phpt +++ /dev/null @@ -1,115 +0,0 @@ ---TEST-- -Test that overwriting the URI is not possible ---FILE-- -__construct('ftp://example.org'); -} catch (Throwable $e) { - echo $e::class, ": ", $e->getMessage(), PHP_EOL; -} -var_dump($uri); - -$uri = new Uri\WhatWg\Url('https://example.com'); -try { - $uri->__unserialize([['uri' => 'ftp://example.org'], []]); -} catch (Throwable $e) { - echo $e::class, ": ", $e->getMessage(), PHP_EOL; -} -var_dump($uri); - -$uri = new Uri\Rfc3986\Uri('https://example.com'); -try { - $uri->__construct('ftp://example.org'); -} catch (Throwable $e) { - echo $e::class, ": ", $e->getMessage(), PHP_EOL; -} -var_dump($uri); - -$uri = new Uri\Rfc3986\Uri('https://example.com'); -try { - $uri->__unserialize([['uri' => 'ftp://example.org'], []]); -} catch (Throwable $e) { - echo $e::class, ": ", $e->getMessage(), PHP_EOL; -} -var_dump($uri); - -?> ---EXPECTF-- -Error: Cannot modify readonly object of class Uri\WhatWg\Url -object(Uri\WhatWg\Url)#%d (8) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(1) "/" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -Exception: Invalid serialization data for Uri\WhatWg\Url object -object(Uri\WhatWg\Url)#%d (8) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(1) "/" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -Error: Cannot modify readonly object of class Uri\Rfc3986\Uri -object(Uri\Rfc3986\Uri)#%d (8) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(0) "" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -Exception: Invalid serialization data for Uri\Rfc3986\Uri object -object(Uri\Rfc3986\Uri)#%d (8) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(0) "" - ["query"]=> - NULL - ["fragment"]=> - NULL -} diff --git a/ext/uri/tests/gh22046.phpt b/ext/uri/tests/gh22046.phpt deleted file mode 100644 index af297905aa30..000000000000 --- a/ext/uri/tests/gh22046.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -GH-22046: The unserialize function can lead to segfault when internal classes are serialized back with the unsupported C format ---FILE-- - ---EXPECTF-- -Warning: Class Uri\WhatWg\Url has no unserializer in %s on line %d - -Warning: unserialize(): Error at offset 25 of 26 bytes in %s on line %d - -Warning: Class Uri\Rfc3986\Uri has no unserializer in %s on line %d - -Warning: unserialize(): Error at offset 26 of 27 bytes in %s on line %d diff --git a/ext/uri/tests/008.phpt b/ext/uri/tests/rfc3986/getters/basic_success.phpt similarity index 62% rename from ext/uri/tests/008.phpt rename to ext/uri/tests/rfc3986/getters/basic_success.phpt index 0a02bae63163..4e90c98007cb 100644 --- a/ext/uri/tests/008.phpt +++ b/ext/uri/tests/rfc3986/getters/basic_success.phpt @@ -1,5 +1,5 @@ --TEST-- -Test Uri getters +Test Uri\Rfc3986\Uri component retrieval - basic --FILE-- getRawFragment()); } -function callWhatWgGetters($url) -{ - var_dump($url->getScheme()); - var_dump($url->getUsername()); - var_dump($url->getPassword()); - var_dump($url->getAsciiHost()); - var_dump($url->getUnicodeHost()); - var_dump($url->getPort()); - var_dump($url->getPath()); - var_dump($url->getQuery()); - var_dump($url->getFragment()); -} - $uri = Uri\Rfc3986\Uri::parse("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists"); callRfc3986Getters($uri); -echo "\n"; - -$url = Uri\WhatWg\Url::parse("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists"); -callWhatWgGetters($url); - ?> --EXPECT-- string(5) "https" @@ -64,13 +46,3 @@ string(10) "query=true" string(10) "query=true" string(11) "hash-exists" string(11) "hash-exists" - -string(5) "https" -string(8) "username" -string(8) "password" -string(15) "www.example.com" -string(15) "www.example.com" -int(8080) -string(30) "/pathname1/pathname2/pathname3" -string(10) "query=true" -string(11) "hash-exists" diff --git a/ext/uri/tests/039.phpt b/ext/uri/tests/rfc3986/getters/percent_encoded_components.phpt similarity index 61% rename from ext/uri/tests/039.phpt rename to ext/uri/tests/rfc3986/getters/percent_encoded_components.phpt index ae662dfd1722..3b0ae568fa2c 100644 --- a/ext/uri/tests/039.phpt +++ b/ext/uri/tests/rfc3986/getters/percent_encoded_components.phpt @@ -1,5 +1,5 @@ --TEST-- -Test percent-encoding of different URI components +Test Uri\Rfc3986\Uri component retrieval - percent-encoded components --FILE-- getRawFragment()); } -function callWhatWgGetters($url) -{ - var_dump($url->getScheme()); - var_dump($url->getUsername()); - var_dump($url->getPassword()); - var_dump($url->getAsciiHost()); - var_dump($url->getUnicodeHost()); - var_dump($url->getPort()); - var_dump($url->getPath()); - var_dump($url->getQuery()); - var_dump($url->getFragment()); -} - $uri = Uri\Rfc3986\Uri::parse("http://%61pple:p%61ss@ex%61mple.com/foob%61r?%61bc=%61bc#%61bc"); callRfc3986Getters($uri); -echo "\n"; - -$url = Uri\WhatWg\Url::parse("http://%61pple:p%61ss@ex%61mple.com/foob%61r?%61bc=%61bc#%61bc"); -callWhatWgGetters($url); - ?> --EXPECT-- string(4) "http" @@ -64,13 +46,3 @@ string(7) "abc=abc" string(11) "%61bc=%61bc" string(3) "abc" string(5) "%61bc" - -string(4) "http" -string(7) "%61pple" -string(6) "p%61ss" -string(11) "example.com" -string(11) "example.com" -NULL -string(9) "/foob%61r" -string(11) "%61bc=%61bc" -string(5) "%61bc" diff --git a/ext/uri/tests/rfc3986/parsing/basic_success_constructor.phpt b/ext/uri/tests/rfc3986/parsing/basic_success_constructor.phpt new file mode 100644 index 000000000000..6a873419e631 --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/basic_success_constructor.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test Uri\Rfc3986\Uri construction - basic - success +--FILE-- + +--EXPECTF-- +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(5) "https" + ["username"]=> + string(8) "username" + ["password"]=> + string(8) "password" + ["host"]=> + string(11) "example.com" + ["port"]=> + int(8080) + ["path"]=> + string(5) "/path" + ["query"]=> + string(3) "q=r" + ["fragment"]=> + string(8) "fragment" +} diff --git a/ext/uri/tests/021.phpt b/ext/uri/tests/rfc3986/parsing/extension_error.phpt similarity index 100% rename from ext/uri/tests/021.phpt rename to ext/uri/tests/rfc3986/parsing/extension_error.phpt diff --git a/ext/uri/tests/047.phpt b/ext/uri/tests/rfc3986/parsing/host_success_ip_addresses.phpt similarity index 63% rename from ext/uri/tests/047.phpt rename to ext/uri/tests/rfc3986/parsing/host_success_ip_addresses.phpt index de9a21efd9b0..f9dae8a376d6 100644 --- a/ext/uri/tests/047.phpt +++ b/ext/uri/tests/rfc3986/parsing/host_success_ip_addresses.phpt @@ -1,5 +1,5 @@ --TEST-- -Test IP addresses +Test Uri\Rfc3986\Uri parsing - host - IP addresses --FILE-- getHost()); var_dump($uri->toRawString()); var_dump($uri->toString()); -$url = new Uri\WhatWg\Url("https://192.168.0.1"); -var_dump($url->getAsciiHost()); -var_dump($url->toAsciiString()); - -$url = new Uri\WhatWg\Url("https://[2001:0db8:0001:0000:0000:0ab9:C0A8:0102]"); -var_dump($url->getAsciiHost()); -var_dump($url->toAsciiString()); - -$url = new Uri\WhatWg\Url("https://[0:0::1]"); -var_dump($url->getAsciiHost()); -var_dump($url->toAsciiString()); - ?> --EXPECT-- string(11) "192.168.0.1" @@ -47,9 +35,3 @@ string(9) "[v7.host]" string(9) "[v7.host]" string(18) "//[v7.host]/source" string(18) "//[v7.host]/source" -string(11) "192.168.0.1" -string(20) "https://192.168.0.1/" -string(26) "[2001:db8:1::ab9:c0a8:102]" -string(35) "https://[2001:db8:1::ab9:c0a8:102]/" -string(5) "[::1]" -string(14) "https://[::1]/" diff --git a/ext/uri/tests/rfc3986/parsing/idna_error.phpt b/ext/uri/tests/rfc3986/parsing/idna_error.phpt new file mode 100644 index 000000000000..1937a646d795 --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/idna_error.phpt @@ -0,0 +1,12 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - IDNA characters +--FILE-- + +--EXPECT-- +NULL +NULL diff --git a/ext/uri/tests/rfc3986/parsing/normalization.phpt b/ext/uri/tests/rfc3986/parsing/normalization.phpt new file mode 100644 index 000000000000..7ae8532ae6ab --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/normalization.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - normalization +--FILE-- +toRawString()); +var_dump(Uri\Rfc3986\Uri::parse("https://www.example.com/dir1/../dir2")->toRawString()); +var_dump(Uri\Rfc3986\Uri::parse("https://你好你好")); +var_dump(Uri\Rfc3986\Uri::parse("https://0Xc0.0250.01")); +var_dump(Uri\Rfc3986\Uri::parse("HttPs://0300.0250.0000.0001/path?query=foo%20bar")->toRawString()); + +?> +--EXPECT-- +string(29) "http://////www.EXAMPLE.com:80" +string(36) "https://www.example.com/dir1/../dir2" +NULL +NULL +string(48) "HttPs://0300.0250.0000.0001/path?query=foo%20bar" diff --git a/ext/uri/tests/049.phpt b/ext/uri/tests/rfc3986/parsing/path_success_percent_encoded_reserved.phpt similarity index 56% rename from ext/uri/tests/049.phpt rename to ext/uri/tests/rfc3986/parsing/path_success_percent_encoded_reserved.phpt index 48f27277fab0..b5bc41e200cb 100644 --- a/ext/uri/tests/049.phpt +++ b/ext/uri/tests/rfc3986/parsing/path_success_percent_encoded_reserved.phpt @@ -1,17 +1,16 @@ --TEST-- -Test percent-encoding normalization - special case +Test Uri\Rfc3986\Uri parsing - path - percent-encoded reserved character --FILE-- getRawPath()); -var_dump($uri->getPath()); -$url = new Uri\WhatWg\Url("https://example.com/foo/bar%2Fbaz"); -var_dump($url->getPath()); +var_dump($uri->toRawString()); +var_dump($uri->getPath()); +var_dump($uri->getRawPath()); ?> --EXPECT-- -string(14) "/foo/bar%2Fbaz" +string(33) "https://example.com/foo/bar%2Fbaz" string(14) "/foo/bar%2Fbaz" string(14) "/foo/bar%2Fbaz" diff --git a/ext/uri/tests/046.phpt b/ext/uri/tests/rfc3986/parsing/path_success_variants.phpt similarity index 72% rename from ext/uri/tests/046.phpt rename to ext/uri/tests/rfc3986/parsing/path_success_variants.phpt index 10d56024698e..5413bbd78977 100644 --- a/ext/uri/tests/046.phpt +++ b/ext/uri/tests/rfc3986/parsing/path_success_variants.phpt @@ -1,5 +1,5 @@ --TEST-- -Test special path variants +Test Uri\Rfc3986\Uri parsing - path - special variants --FILE-- toRawString()); var_dump($uri->getPath()); var_dump($uri->getRawPath()); -$url = new Uri\Whatwg\Url("mailto:johndoe@example.com"); - -var_dump($url->toAsciiString()); -var_dump($url->getPath()); - -$url = new Uri\Whatwg\Url("https://example.com"); - -var_dump($url->toAsciiString()); -var_dump($url->getPath()); - -$url = new Uri\Whatwg\Url("https://example.com/"); - -var_dump($url->toAsciiString()); -var_dump($url->getPath()); - ?> --EXPECT-- string(26) "mailto:johndoe@example.com" @@ -79,9 +64,3 @@ string(0) "" string(20) "https://example.com/" string(1) "/" string(1) "/" -string(26) "mailto:johndoe@example.com" -string(19) "johndoe@example.com" -string(20) "https://example.com/" -string(1) "/" -string(20) "https://example.com/" -string(1) "/" diff --git a/ext/uri/tests/048.phpt b/ext/uri/tests/rfc3986/parsing/percent_encoding_normalization.phpt similarity index 100% rename from ext/uri/tests/048.phpt rename to ext/uri/tests/rfc3986/parsing/percent_encoding_normalization.phpt diff --git a/ext/uri/tests/058.phpt b/ext/uri/tests/rfc3986/parsing/port_error_overflow.phpt similarity index 93% rename from ext/uri/tests/058.phpt rename to ext/uri/tests/rfc3986/parsing/port_error_overflow.phpt index c1ceaa1e02e5..4f803e9de3f2 100644 --- a/ext/uri/tests/058.phpt +++ b/ext/uri/tests/rfc3986/parsing/port_error_overflow.phpt @@ -20,7 +20,7 @@ try { new \Uri\Rfc3986\Uri('https://example.com:2147483648'); } } catch (Throwable $e) { - echo $e::class, ": ", $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> diff --git a/ext/uri/tests/rfc3986/parsing/query_success_variants.phpt b/ext/uri/tests/rfc3986/parsing/query_success_variants.phpt new file mode 100644 index 000000000000..a2eb5aa42f42 --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/query_success_variants.phpt @@ -0,0 +1,53 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - query - variants +--FILE-- + + @")); +var_dump(Uri\Rfc3986\Uri::parse("http://example.com?foo=Hell%C3%B3+W%C3%B6rld")->toRawString()); + +?> +--EXPECTF-- +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(4) "http" + ["username"]=> + NULL + ["password"]=> + NULL + ["host"]=> + string(11) "example.com" + ["port"]=> + NULL + ["path"]=> + string(0) "" + ["query"]=> + string(25) "foo=Hell%C3%B3+W%C3%B6rld" + ["fragment"]=> + NULL +} +NULL +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(4) "http" + ["username"]=> + NULL + ["password"]=> + NULL + ["host"]=> + string(11) "example.com" + ["port"]=> + NULL + ["path"]=> + string(0) "" + ["query"]=> + string(30) "foobar=%27%3Cscript%3E+%2B+%40" + ["fragment"]=> + NULL +} +NULL +string(44) "http://example.com?foo=Hell%C3%B3+W%C3%B6rld" diff --git a/ext/uri/tests/003.phpt b/ext/uri/tests/rfc3986/parsing/special_references.phpt similarity index 57% rename from ext/uri/tests/003.phpt rename to ext/uri/tests/rfc3986/parsing/special_references.phpt index 38d62b0ec8e6..f75174cd1385 100644 --- a/ext/uri/tests/003.phpt +++ b/ext/uri/tests/rfc3986/parsing/special_references.phpt @@ -1,37 +1,14 @@ --TEST-- -Parse special URIs +Test Uri\Rfc3986\Uri parsing - special references --FILE-- --EXPECTF-- -NULL -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(4) "http" - ["username"]=> - string(8) "username" - ["password"]=> - string(8) "password" - ["host"]=> - string(18) "xn--hostname-b1aaa" - ["port"]=> - int(9090) - ["path"]=> - string(5) "/path" - ["query"]=> - string(14) "arg=va%C3%A9ue" - ["fragment"]=> - string(6) "anchor" -} object(Uri\Rfc3986\Uri)#%d (%d) { ["scheme"]=> NULL @@ -86,4 +63,3 @@ object(Uri\Rfc3986\Uri)#%d (%d) { ["fragment"]=> NULL } -NULL diff --git a/ext/uri/tests/100.phpt b/ext/uri/tests/rfc3986/parsing/zend_test_parse_url.phpt similarity index 100% rename from ext/uri/tests/100.phpt rename to ext/uri/tests/rfc3986/parsing/zend_test_parse_url.phpt diff --git a/ext/uri/tests/102.phpt b/ext/uri/tests/rfc3986/parsing/zend_test_port_success_large.phpt similarity index 100% rename from ext/uri/tests/102.phpt rename to ext/uri/tests/rfc3986/parsing/zend_test_port_success_large.phpt diff --git a/ext/uri/tests/043.phpt b/ext/uri/tests/rfc3986/reference_resolution/parse_success_variants.phpt similarity index 58% rename from ext/uri/tests/043.phpt rename to ext/uri/tests/rfc3986/reference_resolution/parse_success_variants.phpt index 18c65e3c7735..71894a39d200 100644 --- a/ext/uri/tests/043.phpt +++ b/ext/uri/tests/rfc3986/reference_resolution/parse_success_variants.phpt @@ -1,5 +1,5 @@ --TEST-- -Test reference resolution +Test Uri\Rfc3986\Uri reference resolution during parsing --FILE-- toString()); -$url = Uri\WhatWg\Url::parse("https://example.com/without-base/"); -var_dump($url); - -$url = Uri\WhatWg\Url::parse("/with-base", new Uri\WhatWg\Url("https://example.com")); -var_dump($url); - -$url = Uri\WhatWg\Url::parse("https://test.com/with-base-in-vain", Uri\WhatWg\Url::parse("https://example.com/")); -var_dump($url); ?> --EXPECTF-- object(Uri\Rfc3986\Uri)#%d (%d) { @@ -99,57 +91,3 @@ object(Uri\Rfc3986\Uri)#%d (%d) { NULL } string(34) "https://test.com/with-base-in-vain" -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(14) "/without-base/" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(10) "/with-base" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(8) "test.com" - ["port"]=> - NULL - ["path"]=> - string(18) "/with-base-in-vain" - ["query"]=> - NULL - ["fragment"]=> - NULL -} diff --git a/ext/uri/tests/010.phpt b/ext/uri/tests/rfc3986/reference_resolution/parse_success_with_base.phpt similarity index 50% rename from ext/uri/tests/010.phpt rename to ext/uri/tests/rfc3986/reference_resolution/parse_success_with_base.phpt index ff5a37000775..0826f7197066 100644 --- a/ext/uri/tests/010.phpt +++ b/ext/uri/tests/rfc3986/reference_resolution/parse_success_with_base.phpt @@ -1,13 +1,10 @@ --TEST-- -Test parsing URIs when a base URI is present +Test Uri\Rfc3986\Uri parsing with a base URI --FILE-- --EXPECTF-- object(Uri\Rfc3986\Uri)#%d (%d) { @@ -46,39 +43,3 @@ object(Uri\Rfc3986\Uri)#%d (%d) { ["fragment"]=> NULL } -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(4) "http" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(11) "example.com" - ["port"]=> - NULL - ["path"]=> - string(14) "/path/to/file1" - ["query"]=> - NULL - ["fragment"]=> - NULL -} -object(Uri\WhatWg\Url)#%d (%d) { - ["scheme"]=> - string(5) "https" - ["username"]=> - NULL - ["password"]=> - NULL - ["host"]=> - string(8) "test.com" - ["port"]=> - NULL - ["path"]=> - string(14) "/path/to/file1" - ["query"]=> - NULL - ["fragment"]=> - NULL -} diff --git a/ext/uri/tests/rfc3986/reference_resolution/resolve_success_basic.phpt b/ext/uri/tests/rfc3986/reference_resolution/resolve_success_basic.phpt new file mode 100644 index 000000000000..0ff7d6468001 --- /dev/null +++ b/ext/uri/tests/rfc3986/reference_resolution/resolve_success_basic.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test Uri\Rfc3986\Uri reference resolution - resolve() - success +--FILE-- +resolve("/foo/")->toString()); +var_dump($uri->resolve("https://test.com/foo")->toString()); + +?> +--EXPECTF-- +string(24) "https://example.com/foo/" +string(20) "https://test.com/foo" diff --git a/ext/uri/tests/034.phpt b/ext/uri/tests/rfc3986/serialization/array_cast_success.phpt similarity index 53% rename from ext/uri/tests/034.phpt rename to ext/uri/tests/rfc3986/serialization/array_cast_success.phpt index 35d51aad8664..9e8e56eb7277 100644 --- a/ext/uri/tests/034.phpt +++ b/ext/uri/tests/rfc3986/serialization/array_cast_success.phpt @@ -1,17 +1,12 @@ --TEST-- -Test array cast +Test casting Uri\Rfc3986\Uri to array --FILE-- --EXPECTF-- array(%d) { } -array(%d) { -} diff --git a/ext/uri/tests/009.phpt b/ext/uri/tests/rfc3986/serialization/clone_success.phpt similarity index 59% rename from ext/uri/tests/009.phpt rename to ext/uri/tests/rfc3986/serialization/clone_success.phpt index 9c896d0153b2..6892811c871a 100644 --- a/ext/uri/tests/009.phpt +++ b/ext/uri/tests/rfc3986/serialization/clone_success.phpt @@ -1,16 +1,18 @@ --TEST-- -Test parsing with IANA schemes +Test cloning Uri\Rfc3986\Uri --FILE-- --EXPECTF-- -object(Uri\Rfc3986\Uri)#%d (%d) { +object(Uri\Rfc3986\Uri)#1 (%d) { ["scheme"]=> - string(16) "chrome-extension" + string(5) "https" ["username"]=> NULL ["password"]=> @@ -26,9 +28,9 @@ object(Uri\Rfc3986\Uri)#%d (%d) { ["fragment"]=> NULL } -object(Uri\WhatWg\Url)#%d (%d) { +object(Uri\Rfc3986\Uri)#2 (%d) { ["scheme"]=> - string(16) "chrome-extension" + string(5) "https" ["username"]=> NULL ["password"]=> diff --git a/ext/uri/tests/032.phpt b/ext/uri/tests/rfc3986/serialization/json_encode_success.phpt similarity index 52% rename from ext/uri/tests/032.phpt rename to ext/uri/tests/rfc3986/serialization/json_encode_success.phpt index b17765240c7b..cfc7b8a523d9 100644 --- a/ext/uri/tests/032.phpt +++ b/ext/uri/tests/rfc3986/serialization/json_encode_success.phpt @@ -1,15 +1,11 @@ --TEST-- -Test JSON encoding +Test JSON encoding Uri\Rfc3986\Uri --FILE-- --EXPECT-- string(2) "{}" -string(2) "{}" diff --git a/ext/uri/tests/rfc3986/serialization/legacy_format_error.phpt b/ext/uri/tests/rfc3986/serialization/legacy_format_error.phpt new file mode 100644 index 000000000000..ef76114f2f43 --- /dev/null +++ b/ext/uri/tests/rfc3986/serialization/legacy_format_error.phpt @@ -0,0 +1,11 @@ +--TEST-- +GH-22046: Uri\Rfc3986\Uri cannot be unserialized with the unsupported C format +--FILE-- + +--EXPECTF-- +Warning: Class Uri\Rfc3986\Uri has no unserializer in %s on line %d + +Warning: unserialize(): Error at offset 26 of 27 bytes in %s on line %d diff --git a/ext/uri/tests/rfc3986/serialization/reinitialization_error.phpt b/ext/uri/tests/rfc3986/serialization/reinitialization_error.phpt new file mode 100644 index 000000000000..9b7998c7fac4 --- /dev/null +++ b/ext/uri/tests/rfc3986/serialization/reinitialization_error.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test that overwriting Uri\Rfc3986\Uri is not possible +--FILE-- +__construct('ftp://example.org'); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} +var_dump($uri); + +$uri = new Uri\Rfc3986\Uri('https://example.com'); +try { + $uri->__unserialize([['uri' => 'ftp://example.org'], []]); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; +} +var_dump($uri); + +?> +--EXPECTF-- +Error: Cannot modify readonly object of class Uri\Rfc3986\Uri +object(Uri\Rfc3986\Uri)#%d (8) { + ["scheme"]=> + string(5) "https" + ["username"]=> + NULL + ["password"]=> + NULL + ["host"]=> + string(11) "example.com" + ["port"]=> + NULL + ["path"]=> + string(0) "" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +Exception: Invalid serialization data for Uri\Rfc3986\Uri object +object(Uri\Rfc3986\Uri)#%d (8) { + ["scheme"]=> + string(5) "https" + ["username"]=> + NULL + ["password"]=> + NULL + ["host"]=> + string(11) "example.com" + ["port"]=> + NULL + ["path"]=> + string(0) "" + ["query"]=> + NULL + ["fragment"]=> + NULL +} diff --git a/ext/uri/tests/rfc3986/serialization/string_conversion_success.phpt b/ext/uri/tests/rfc3986/serialization/string_conversion_success.phpt new file mode 100644 index 000000000000..90556c806580 --- /dev/null +++ b/ext/uri/tests/rfc3986/serialization/string_conversion_success.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri string conversion +--FILE-- +toRawString()); +var_dump($uri1->toString()); +var_dump($uri2->toRawString()); +var_dump($uri2->toString()); +var_dump($uri3->toRawString()); +var_dump($uri3->toString()); + +?> +--EXPECT-- +string(23) "HTTPS://////EXAMPLE.com" +string(23) "https://////EXAMPLE.com" +string(19) "https://example.com" +string(19) "https://example.com" +string(26) "https://example.com/foo/.." +string(20) "https://example.com/" diff --git a/ext/uri/tests/033.phpt b/ext/uri/tests/rfc3986/serialization/var_export_success.phpt similarity index 52% rename from ext/uri/tests/033.phpt rename to ext/uri/tests/rfc3986/serialization/var_export_success.phpt index e88baadeba0d..de83dadb0343 100644 --- a/ext/uri/tests/033.phpt +++ b/ext/uri/tests/rfc3986/serialization/var_export_success.phpt @@ -1,5 +1,5 @@ --TEST-- -Test var_export +Test var_export() with Uri\Rfc3986\Uri --FILE-- --EXPECT-- \Uri\Rfc3986\Uri::__set_state(array( )) -\Uri\WhatWg\Url::__set_state(array( -)) diff --git a/ext/uri/tests/whatwg/getters/basic_success.phpt b/ext/uri/tests/whatwg/getters/basic_success.phpt new file mode 100644 index 000000000000..aebf36eaaf12 --- /dev/null +++ b/ext/uri/tests/whatwg/getters/basic_success.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test Uri\WhatWg\Url component retrieval - basic +--FILE-- +getScheme()); +var_dump($url->getUsername()); +var_dump($url->getPassword()); +var_dump($url->getAsciiHost()); +var_dump($url->getUnicodeHost()); +var_dump($url->getPort()); +var_dump($url->getPath()); +var_dump($url->getQuery()); +var_dump($url->getFragment()); + +?> +--EXPECT-- +string(5) "https" +string(8) "username" +string(8) "password" +string(15) "www.example.com" +string(15) "www.example.com" +int(8080) +string(30) "/pathname1/pathname2/pathname3" +string(10) "query=true" +string(11) "hash-exists" diff --git a/ext/uri/tests/whatwg/getters/percent_encoded_components.phpt b/ext/uri/tests/whatwg/getters/percent_encoded_components.phpt new file mode 100644 index 000000000000..d6c24e1bc6e8 --- /dev/null +++ b/ext/uri/tests/whatwg/getters/percent_encoded_components.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test Uri\WhatWg\Url component retrieval - percent-encoded components +--FILE-- +getScheme()); +var_dump($url->getUsername()); +var_dump($url->getPassword()); +var_dump($url->getAsciiHost()); +var_dump($url->getUnicodeHost()); +var_dump($url->getPort()); +var_dump($url->getPath()); +var_dump($url->getQuery()); +var_dump($url->getFragment()); + +?> +--EXPECT-- +string(4) "http" +string(7) "%61pple" +string(6) "p%61ss" +string(11) "example.com" +string(11) "example.com" +NULL +string(9) "/foob%61r" +string(11) "%61bc=%61bc" +string(5) "%61bc" diff --git a/ext/uri/tests/whatwg/modification/username_success_encoded.phpt b/ext/uri/tests/whatwg/modification/username_success_encoded.phpt new file mode 100644 index 000000000000..84199fe8caa3 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_encoded.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - URL encoded characters +--FILE-- +withUsername("%75s%2Fr"); + +var_dump($url2->getUsername()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(8) "%75s%2Fr" +string(29) "https://%75s%2Fr@example.com/" diff --git a/ext/uri/tests/whatwg/modification/username_success_file_scheme.phpt b/ext/uri/tests/whatwg/modification/username_success_file_scheme.phpt new file mode 100644 index 000000000000..b5a2191dc6a8 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_file_scheme.phpt @@ -0,0 +1,15 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - file scheme +--FILE-- +withUsername("user"); + +var_dump($url2->getUsername()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(16) "file:///foo/bar/" diff --git a/ext/uri/tests/whatwg/parsing/basic_success_constructor.phpt b/ext/uri/tests/whatwg/parsing/basic_success_constructor.phpt new file mode 100644 index 000000000000..578f2a1f8b6b --- /dev/null +++ b/ext/uri/tests/whatwg/parsing/basic_success_constructor.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test Uri\WhatWg\Url construction - basic - success +--FILE-- + +--EXPECTF-- +object(Uri\WhatWg\Url)#%d (%d) { + ["scheme"]=> + string(5) "https" + ["username"]=> + string(8) "username" + ["password"]=> + string(8) "password" + ["host"]=> + string(11) "example.com" + ["port"]=> + int(8080) + ["path"]=> + string(5) "/path" + ["query"]=> + string(3) "q=r" + ["fragment"]=> + string(8) "fragment" +} diff --git a/ext/uri/tests/005.phpt b/ext/uri/tests/whatwg/parsing/basic_success_multibyte.phpt similarity index 86% rename from ext/uri/tests/005.phpt rename to ext/uri/tests/whatwg/parsing/basic_success_multibyte.phpt index 8d8be9679397..b6856ec22177 100644 --- a/ext/uri/tests/005.phpt +++ b/ext/uri/tests/whatwg/parsing/basic_success_multibyte.phpt @@ -1,10 +1,8 @@ --TEST-- -Parse multibyte URLs +Test Uri\WhatWg\Url parsing - basic - multibyte URL --FILE-- getAsciiHost()); @@ -14,7 +12,6 @@ var_dump($url->toUnicodeString()); ?> --EXPECTF-- -NULL object(Uri\WhatWg\Url)#%d (%d) { ["scheme"]=> string(4) "http" diff --git a/ext/uri/tests/057.phpt b/ext/uri/tests/whatwg/parsing/errors_reference_error.phpt similarity index 85% rename from ext/uri/tests/057.phpt rename to ext/uri/tests/whatwg/parsing/errors_reference_error.phpt index 5cc4e5974212..dfeb9cc81dc5 100644 --- a/ext/uri/tests/057.phpt +++ b/ext/uri/tests/whatwg/parsing/errors_reference_error.phpt @@ -11,7 +11,7 @@ $f = new Foo(); try { Uri\WhatWg\Url::parse(" https://example.org ", errors: $f->x); } catch (Throwable $e) { - echo $e::class, ": ", $e->getMessage(), PHP_EOL; + echo $e::class, ': ', $e->getMessage(), "\n"; } ?> diff --git a/ext/uri/tests/gh19892.phpt b/ext/uri/tests/whatwg/parsing/errors_success_empty.phpt similarity index 100% rename from ext/uri/tests/gh19892.phpt rename to ext/uri/tests/whatwg/parsing/errors_success_empty.phpt diff --git a/ext/uri/tests/022.phpt b/ext/uri/tests/whatwg/parsing/extension_error.phpt similarity index 100% rename from ext/uri/tests/022.phpt rename to ext/uri/tests/whatwg/parsing/extension_error.phpt diff --git a/ext/uri/tests/whatwg/parsing/host_success_ip_addresses.phpt b/ext/uri/tests/whatwg/parsing/host_success_ip_addresses.phpt new file mode 100644 index 000000000000..3f33c4982cbc --- /dev/null +++ b/ext/uri/tests/whatwg/parsing/host_success_ip_addresses.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test Uri\WhatWg\Url parsing - host - IP addresses +--FILE-- +getAsciiHost()); +var_dump($url->toAsciiString()); + +$url = new Uri\WhatWg\Url("https://[2001:0db8:0001:0000:0000:0ab9:C0A8:0102]"); +var_dump($url->getAsciiHost()); +var_dump($url->toAsciiString()); + +$url = new Uri\WhatWg\Url("https://[0:0::1]"); +var_dump($url->getAsciiHost()); +var_dump($url->toAsciiString()); + +?> +--EXPECT-- +string(11) "192.168.0.1" +string(20) "https://192.168.0.1/" +string(26) "[2001:db8:1::ab9:c0a8:102]" +string(35) "https://[2001:db8:1::ab9:c0a8:102]/" +string(5) "[::1]" +string(14) "https://[::1]/" diff --git a/ext/uri/tests/019.phpt b/ext/uri/tests/whatwg/parsing/idna_support.phpt similarity index 86% rename from ext/uri/tests/019.phpt rename to ext/uri/tests/whatwg/parsing/idna_support.phpt index 7f62a64e9fde..0433997d22ca 100644 --- a/ext/uri/tests/019.phpt +++ b/ext/uri/tests/whatwg/parsing/idna_support.phpt @@ -1,19 +1,13 @@ --TEST-- -Test IDNA support +Test Uri\WhatWg\Url parsing - IDNA support --FILE-- getAsciiHost()); @@ -24,7 +18,6 @@ var_dump($url->toUnicodeString()); ?> --EXPECTF-- NULL -NULL array(1) { [0]=> object(Uri\WhatWg\UrlValidationError)#%d (%d) { @@ -36,7 +29,6 @@ array(1) { bool(true) } } -NULL object(Uri\WhatWg\Url)#%d (%d) { ["scheme"]=> string(5) "https" diff --git a/ext/uri/tests/056.phpt b/ext/uri/tests/whatwg/parsing/memory_management.phpt similarity index 100% rename from ext/uri/tests/056.phpt rename to ext/uri/tests/whatwg/parsing/memory_management.phpt diff --git a/ext/uri/tests/011.phpt b/ext/uri/tests/whatwg/parsing/normalization.phpt similarity index 56% rename from ext/uri/tests/011.phpt rename to ext/uri/tests/whatwg/parsing/normalization.phpt index 0e8fd8ec8f48..9b8b883a72f4 100644 --- a/ext/uri/tests/011.phpt +++ b/ext/uri/tests/whatwg/parsing/normalization.phpt @@ -1,31 +1,22 @@ --TEST-- -Test encoding and normalization +Test Uri\WhatWg\Url parsing - normalization --FILE-- toRawString()); -var_dump(Uri\Rfc3986\Uri::parse("https://www.example.com/dir1/../dir2")->toRawString()); -var_dump(Uri\Rfc3986\Uri::parse("https://你好你好")); -var_dump(Uri\Rfc3986\Uri::parse("https://0Xc0.0250.01")); -var_dump(Uri\Rfc3986\Uri::parse("HttPs://0300.0250.0000.0001/path?query=foo%20bar")->toRawString()); - var_dump(Uri\WhatWg\Url::parse("http://////www.EXAMPLE.com:80")->toAsciiString()); var_dump(Uri\WhatWg\Url::parse("https://www.example.com:443/dir1/../dir2")->toAsciiString()); var_dump(Uri\WhatWg\Url::parse("https://你好你好")->toAsciiString()); var_dump(Uri\WhatWg\Url::parse("https://你好你好")->toUnicodeString()); var_dump(Uri\WhatWg\Url::parse("https://0Xc0.0250.01")->toAsciiString()); var_dump(Uri\WhatWg\Url::parse("HttPs://0300.0250.0000.0001/path?query=foo%20bar")->toAsciiString()); +var_dump(Uri\WhatWg\Url::parse("file:///E:\\Documents and Settings")->toAsciiString()); ?> --EXPECT-- -string(29) "http://////www.EXAMPLE.com:80" -string(36) "https://www.example.com/dir1/../dir2" -NULL -NULL -string(48) "HttPs://0300.0250.0000.0001/path?query=foo%20bar" string(23) "http://www.example.com/" string(28) "https://www.example.com/dir2" string(23) "https://xn--6qqa088eba/" string(21) "https://你好你好/" string(20) "https://192.168.0.1/" string(40) "https://192.168.0.1/path?query=foo%20bar" +string(37) "file:///E:/Documents%20and%20Settings" diff --git a/ext/uri/tests/whatwg/parsing/path_success_percent_encoded_reserved.phpt b/ext/uri/tests/whatwg/parsing/path_success_percent_encoded_reserved.phpt new file mode 100644 index 000000000000..532ce6c1ffb8 --- /dev/null +++ b/ext/uri/tests/whatwg/parsing/path_success_percent_encoded_reserved.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test Uri\WhatWg\Url parsing - path - percent-encoded reserved character +--FILE-- +toAsciiString()); +var_dump($url->getPath()); + +?> +--EXPECT-- +string(33) "https://example.com/foo/bar%2Fbaz" +string(14) "/foo/bar%2Fbaz" diff --git a/ext/uri/tests/whatwg/parsing/path_success_variants.phpt b/ext/uri/tests/whatwg/parsing/path_success_variants.phpt new file mode 100644 index 000000000000..9890d9758fad --- /dev/null +++ b/ext/uri/tests/whatwg/parsing/path_success_variants.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test Uri\WhatWg\Url parsing - path - special variants +--FILE-- +toAsciiString()); +var_dump($url->getPath()); + +$url = new Uri\WhatWg\Url("https://example.com"); +var_dump($url->toAsciiString()); +var_dump($url->getPath()); + +$url = new Uri\WhatWg\Url("https://example.com/"); +var_dump($url->toAsciiString()); +var_dump($url->getPath()); + +?> +--EXPECT-- +string(26) "mailto:johndoe@example.com" +string(19) "johndoe@example.com" +string(20) "https://example.com/" +string(1) "/" +string(20) "https://example.com/" +string(1) "/" diff --git a/ext/uri/tests/013.phpt b/ext/uri/tests/whatwg/parsing/query_success_variants.phpt similarity index 61% rename from ext/uri/tests/013.phpt rename to ext/uri/tests/whatwg/parsing/query_success_variants.phpt index 865843ec27e8..fc45ae455ee1 100644 --- a/ext/uri/tests/013.phpt +++ b/ext/uri/tests/whatwg/parsing/query_success_variants.phpt @@ -1,41 +1,16 @@ --TEST-- -Test parsing of query strings +Test Uri\WhatWg\Url parsing - query - variants --FILE-- + @")); - var_dump(Uri\WhatWg\Url::parse("http://example.com?foobar=%27%3Cscript%3E+%2B+%40")); var_dump(Uri\WhatWg\Url::parse("http://example.com?foobar='