Commit c0352c2c0e1 for php.net
commit c0352c2c0e139879a033f52e4c9fef6575ba7469
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date: Fri Sep 4 16:43:53 2026 +0700
ext/uri: Reorganises legacy tests (#23286)
diff --git a/ext/uri/tests/003.phpt b/ext/uri/tests/003.phpt
deleted file mode 100644
index 38d62b0ec8e..00000000000
--- a/ext/uri/tests/003.phpt
+++ /dev/null
@@ -1,89 +0,0 @@
---TEST--
-Parse special URIs
---FILE--
-<?php
-
-var_dump(Uri\Rfc3986\Uri::parse("http://username:password@héééostname:9090/gah/../path?arg=vaéue#anchor"));
-var_dump(Uri\WhatWg\Url::parse("http://username:password@héééostname:9090/gah/../path?arg=vaéue#anchor"));
-
-var_dump(Uri\Rfc3986\Uri::parse("//host123/"));
-var_dump(Uri\Rfc3986\Uri::parse("///foo/"));
-var_dump(Uri\Rfc3986\Uri::parse("/page:1"));
-var_dump(Uri\WhatWg\Url::parse("/page:1"));
-
-?>
---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
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(7) "host123"
- ["port"]=>
- NULL
- ["path"]=>
- string(1) "/"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
-object(Uri\Rfc3986\Uri)#%d (%d) {
- ["scheme"]=>
- NULL
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(0) ""
- ["port"]=>
- NULL
- ["path"]=>
- string(5) "/foo/"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
-object(Uri\Rfc3986\Uri)#%d (%d) {
- ["scheme"]=>
- NULL
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- NULL
- ["port"]=>
- NULL
- ["path"]=>
- string(7) "/page:1"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
-NULL
diff --git a/ext/uri/tests/004.phpt b/ext/uri/tests/004.phpt
deleted file mode 100644
index c6ad96ce99a..00000000000
--- a/ext/uri/tests/004.phpt
+++ /dev/null
@@ -1,83 +0,0 @@
---TEST--
-Parse invalid URLs
---FILE--
-<?php
-
-var_dump(new Uri\Rfc3986\Uri(""));
-var_dump(Uri\Rfc3986\Uri::parse(""));
-
-try {
- new Uri\WhatWg\Url("");
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->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/006.phpt b/ext/uri/tests/006.phpt
deleted file mode 100644
index e7fa79a8b83..00000000000
--- a/ext/uri/tests/006.phpt
+++ /dev/null
@@ -1,49 +0,0 @@
---TEST--
-Test successful manual Uri child instance creation
---FILE--
-<?php
-
-$uri = new Uri\Rfc3986\Uri("https://username:password@example.com:8080/path?q=r#fragment");
-var_dump($uri);
-
-$url = new Uri\WhatWg\Url("https://username:password@example.com:8080/path?q=r#fragment");
-var_dump($url);
-
-?>
---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/007.phpt b/ext/uri/tests/007.phpt
deleted file mode 100644
index 9d2f389e251..00000000000
--- a/ext/uri/tests/007.phpt
+++ /dev/null
@@ -1,68 +0,0 @@
---TEST--
-Test URI creation errors
---FILE--
-<?php
-
-try {
- new Uri\Rfc3986\Uri("https://example.com:8080@username:password/path?q=r#fragment");
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->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/008.phpt b/ext/uri/tests/008.phpt
deleted file mode 100644
index 0a02bae6316..00000000000
--- a/ext/uri/tests/008.phpt
+++ /dev/null
@@ -1,76 +0,0 @@
---TEST--
-Test Uri getters
---FILE--
-<?php
-
-function callRfc3986Getters($uri)
-{
- var_dump($uri->getScheme());
- var_dump($uri->getRawScheme());
- var_dump($uri->getUsername());
- var_dump($uri->getRawUsername());
- var_dump($uri->getPassword());
- var_dump($uri->getRawPassword());
- var_dump($uri->getUserInfo());
- var_dump($uri->getRawUserInfo());
- var_dump($uri->getHost());
- var_dump($uri->getRawHost());
- var_dump($uri->getPort());
- var_dump($uri->getPath());
- var_dump($uri->getRawPath());
- var_dump($uri->getQuery());
- var_dump($uri->getRawQuery());
- var_dump($uri->getFragment());
- var_dump($uri->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"
-string(5) "https"
-string(8) "username"
-string(8) "username"
-string(8) "password"
-string(8) "password"
-string(17) "username:password"
-string(17) "username:password"
-string(15) "www.example.com"
-string(15) "www.example.com"
-int(8080)
-string(30) "/pathname1/pathname2/pathname3"
-string(30) "/pathname1/pathname2/pathname3"
-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/009.phpt b/ext/uri/tests/009.phpt
deleted file mode 100644
index 9c896d0153b..00000000000
--- a/ext/uri/tests/009.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Test parsing with IANA schemes
---FILE--
-<?php
-
-var_dump(Uri\Rfc3986\Uri::parse("chrome-extension://example.com"));
-var_dump(Uri\WhatWg\Url::parse("chrome-extension://example.com"));
-
-?>
---EXPECTF--
-object(Uri\Rfc3986\Uri)#%d (%d) {
- ["scheme"]=>
- string(16) "chrome-extension"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(11) "example.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(0) ""
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
-object(Uri\WhatWg\Url)#%d (%d) {
- ["scheme"]=>
- string(16) "chrome-extension"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(11) "example.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(0) ""
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
diff --git a/ext/uri/tests/010.phpt b/ext/uri/tests/010.phpt
deleted file mode 100644
index ff5a3700077..00000000000
--- a/ext/uri/tests/010.phpt
+++ /dev/null
@@ -1,84 +0,0 @@
---TEST--
-Test parsing URIs when a base URI is present
---FILE--
-<?php
-
-var_dump(Uri\Rfc3986\Uri::parse("http://example.com/path/to/file2", new Uri\Rfc3986\Uri("https://test.com")));
-var_dump(Uri\Rfc3986\Uri::parse("/path/to/file2", new Uri\Rfc3986\Uri("https://test.com")));
-var_dump(Uri\WhatWg\Url::parse("http://example.com/path/to/file1", new Uri\WhatWg\Url("https://test.com")));
-var_dump(Uri\WhatWg\Url::parse("/path/to/file1", new Uri\WhatWg\Url("https://test.com")));
-
-?>
---EXPECTF--
-object(Uri\Rfc3986\Uri)#%d (%d) {
- ["scheme"]=>
- string(4) "http"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(11) "example.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(14) "/path/to/file2"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
-object(Uri\Rfc3986\Uri)#%d (%d) {
- ["scheme"]=>
- string(5) "https"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(8) "test.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(14) "/path/to/file2"
- ["query"]=>
- NULL
- ["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/011.phpt b/ext/uri/tests/011.phpt
deleted file mode 100644
index 0e8fd8ec8f4..00000000000
--- a/ext/uri/tests/011.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-Test encoding and normalization
---FILE--
-<?php
-
-var_dump(Uri\Rfc3986\Uri::parse("http://////www.EXAMPLE.com:80")->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());
-
-?>
---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"
diff --git a/ext/uri/tests/012.phpt b/ext/uri/tests/012.phpt
deleted file mode 100644
index e033223a642..00000000000
--- a/ext/uri/tests/012.phpt
+++ /dev/null
@@ -1,85 +0,0 @@
---TEST--
-Test parsing of various schemes
---FILE--
-<?php
-
-var_dump(Uri\Rfc3986\Uri::parse("mailto:Joe@Example.COM"));
-var_dump(Uri\WhatWg\Url::parse("mailto:Joe@Example.COM"));
-
-var_dump(Uri\Rfc3986\Uri::parse("file:///E:/Documents%20and%20Settings"));
-var_dump(Uri\WhatWg\Url::parse("file:///E:\\Documents and Settings"));
-
-?>
---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/013.phpt b/ext/uri/tests/013.phpt
deleted file mode 100644
index 865843ec27e..00000000000
--- a/ext/uri/tests/013.phpt
+++ /dev/null
@@ -1,129 +0,0 @@
---TEST--
-Test parsing of query strings
---FILE--
-<?php
-
-var_dump(Uri\Rfc3986\Uri::parse("http://example.com?foo=Hell%C3%B3+W%C3%B6rld"));
-var_dump(Uri\Rfc3986\Uri::parse("http://example.com?foo=Helló Wörld"));
-
-var_dump(Uri\WhatWg\Url::parse("http://example.com?foo=Hell%C3%B3+W%C3%B6rld"));
-var_dump(Uri\WhatWg\Url::parse("http://example.com?foo=Helló Wörld"));
-
-var_dump(Uri\Rfc3986\Uri::parse("http://example.com?foobar=%27%3Cscript%3E+%2B+%40"));
-var_dump(Uri\Rfc3986\Uri::parse("http://example.com?foobar='<script> + @"));
-
-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='<script> + @"));
-
-?>
---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\WhatWg\Url)#%d (%d) {
- ["scheme"]=>
- string(4) "http"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(11) "example.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(1) "/"
- ["query"]=>
- string(25) "foo=Hell%C3%B3+W%C3%B6rld"
- ["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(1) "/"
- ["query"]=>
- string(27) "foo=Hell%C3%B3%20W%C3%B6rld"
- ["fragment"]=>
- 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
-object(Uri\WhatWg\Url)#%d (%d) {
- ["scheme"]=>
- string(4) "http"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(11) "example.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(1) "/"
- ["query"]=>
- string(30) "foobar=%27%3Cscript%3E+%2B+%40"
- ["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(1) "/"
- ["query"]=>
- string(30) "foobar=%27%3Cscript%3E%20+%20@"
- ["fragment"]=>
- NULL
-}
diff --git a/ext/uri/tests/014.phpt b/ext/uri/tests/014.phpt
deleted file mode 100644
index 2966e2a9dcf..00000000000
--- a/ext/uri/tests/014.phpt
+++ /dev/null
@@ -1,13 +0,0 @@
---TEST--
-Test recomposition of URIs
---FILE--
-<?php
-
-var_dump(Uri\Rfc3986\Uri::parse("http://example.com?foo=Hell%C3%B3+W%C3%B6rld")->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 7a7be9b3c19..00000000000
--- a/ext/uri/tests/018.phpt
+++ /dev/null
@@ -1,89 +0,0 @@
---TEST--
-Test property mutation
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
-$uri2 = clone $uri1;
-var_dump($uri1);
-var_dump($uri2);
-
-$url3 = Uri\WhatWg\Url::parse("https://example.com");
-$url4 = clone $url3;
-var_dump($url3);
-var_dump($url4);
-
-?>
---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/019.phpt b/ext/uri/tests/019.phpt
deleted file mode 100644
index 7f62a64e9fd..00000000000
--- a/ext/uri/tests/019.phpt
+++ /dev/null
@@ -1,61 +0,0 @@
---TEST--
-Test IDNA support
---FILE--
-<?php
-
-$uri = Uri\Rfc3986\Uri::parse("🐘");
-var_dump($uri);
-
-$errors = [];
-$url = Uri\WhatWg\Url::parse("🐘", null, $errors);
-var_dump($url);
-var_dump($errors);
-
-$uri = Uri\Rfc3986\Uri::parse("https://🐘.com/🐘?🐘=🐘");
-var_dump($uri);
-
-$url = Uri\WhatWg\Url::parse("https://🐘.com/🐘?🐘=🐘", null);
-var_dump($url);
-var_dump($url->getAsciiHost());
-var_dump($url->getUnicodeHost());
-var_dump($url->toAsciiString());
-var_dump($url->toUnicodeString());
-
-?>
---EXPECTF--
-NULL
-NULL
-array(1) {
- [0]=>
- object(Uri\WhatWg\UrlValidationError)#%d (%d) {
- ["context"]=>
- string(4) "🐘"
- ["type"]=>
- enum(Uri\WhatWg\UrlValidationErrorType::MissingSchemeNonRelativeUrl)
- ["failure"]=>
- bool(true)
- }
-}
-NULL
-object(Uri\WhatWg\Url)#%d (%d) {
- ["scheme"]=>
- string(5) "https"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(12) "xn--go8h.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(13) "/%F0%9F%90%98"
- ["query"]=>
- string(25) "%F0%9F%90%98=%F0%9F%90%98"
- ["fragment"]=>
- NULL
-}
-string(12) "xn--go8h.com"
-string(8) "🐘.com"
-string(59) "https://xn--go8h.com/%F0%9F%90%98?%F0%9F%90%98=%F0%9F%90%98"
-string(55) "https://🐘.com/%F0%9F%90%98?%F0%9F%90%98=%F0%9F%90%98"
diff --git a/ext/uri/tests/023.phpt b/ext/uri/tests/023.phpt
deleted file mode 100644
index 8899abc16b6..00000000000
--- a/ext/uri/tests/023.phpt
+++ /dev/null
@@ -1,61 +0,0 @@
---TEST--
-Test property mutation - scheme
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
-var_dump($uri1->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/024.phpt b/ext/uri/tests/024.phpt
deleted file mode 100644
index 4147ff3ae12..00000000000
--- a/ext/uri/tests/024.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-Test property mutation - username
---FILE--
-<?php
-
-$url1 = Uri\WhatWg\Url::parse("https://example.com");
-$url2 = $url1->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 a6dd505fcca..00000000000
--- a/ext/uri/tests/025.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-Test property mutation - password
---FILE--
-<?php
-
-$url1 = Uri\WhatWg\Url::parse("https://example.com");
-$url2 = $url1->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/026.phpt b/ext/uri/tests/026.phpt
deleted file mode 100644
index 179b00d3857..00000000000
--- a/ext/uri/tests/026.phpt
+++ /dev/null
@@ -1,137 +0,0 @@
---TEST--
-Test property mutation - host
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
-var_dump($uri1->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/026_userinfo.phpt b/ext/uri/tests/026_userinfo.phpt
deleted file mode 100644
index a29abddf972..00000000000
--- a/ext/uri/tests/026_userinfo.phpt
+++ /dev/null
@@ -1,51 +0,0 @@
---TEST--
-Test property mutation - userinfo
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
-var_dump($uri1->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/027.phpt b/ext/uri/tests/027.phpt
deleted file mode 100644
index 2309cace93d..00000000000
--- a/ext/uri/tests/027.phpt
+++ /dev/null
@@ -1,73 +0,0 @@
---TEST--
-Test property mutation - port
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("https://example.com:8080");
-$uri2 = $uri1->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/028.phpt b/ext/uri/tests/028.phpt
deleted file mode 100644
index 708a50d4f2e..00000000000
--- a/ext/uri/tests/028.phpt
+++ /dev/null
@@ -1,87 +0,0 @@
---TEST--
-Test property mutation - path
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("https://example.com/foo/bar/");
-var_dump($uri1->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 c1ce0e10d94..00000000000
--- a/ext/uri/tests/029.phpt
+++ /dev/null
@@ -1,93 +0,0 @@
---TEST--
-Test property mutation - query
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("https://example.com?foo=bar");
-var_dump($uri1->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 e3df0f93998..00000000000
--- a/ext/uri/tests/030.phpt
+++ /dev/null
@@ -1,69 +0,0 @@
---TEST--
-Test property mutation - fragment
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("https://example.com#fragment1");
-var_dump($uri1->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"
diff --git a/ext/uri/tests/031.phpt b/ext/uri/tests/031.phpt
deleted file mode 100644
index d60190457c1..00000000000
--- a/ext/uri/tests/031.phpt
+++ /dev/null
@@ -1,178 +0,0 @@
---TEST--
-Test serialization and unserialization
---FILE--
-<?php
-
-$uri1 = new Uri\Rfc3986\Uri("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists");
-$serializedUri1 = serialize($uri1);
-$uri2 = unserialize($serializedUri1);
-
-var_dump($serializedUri1);
-var_dump($uri2);
-
-try {
- unserialize('O:15:"Uri\Rfc3986\Uri":1:{i:0;a:0:{}}'); // less than 2 items
-} catch (Throwable $e) {
- echo $e::class, ': ', $e->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/033.phpt b/ext/uri/tests/033.phpt
deleted file mode 100644
index e88baadeba0..00000000000
--- a/ext/uri/tests/033.phpt
+++ /dev/null
@@ -1,19 +0,0 @@
---TEST--
-Test var_export
---FILE--
-<?php
-
-$uri = new Uri\Rfc3986\Uri("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists");
-var_export($uri);
-echo "\n";
-
-$url = new Uri\WhatWg\Url("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists");
-var_export($url);
-echo "\n";
-
-?>
---EXPECT--
-\Uri\Rfc3986\Uri::__set_state(array(
-))
-\Uri\WhatWg\Url::__set_state(array(
-))
diff --git a/ext/uri/tests/038.phpt b/ext/uri/tests/038.phpt
deleted file mode 100644
index 175a6762894..00000000000
--- a/ext/uri/tests/038.phpt
+++ /dev/null
@@ -1,40 +0,0 @@
---TEST--
-Test toString()
---FILE--
-<?php
-
-$uri1 = Uri\Rfc3986\Uri::parse("HTTPS://////EXAMPLE.com");
-$uri2 = Uri\Rfc3986\Uri::parse("https://example.com");
-$uri3 = Uri\Rfc3986\Uri::parse("https://example.com/foo/..");
-var_dump($uri1->toRawString());
-var_dump($uri1->toString());
-var_dump($uri2->toRawString());
-var_dump($uri2->toString());
-var_dump($uri3->toRawString());
-var_dump($uri3->toString());
-
-$url1 = Uri\WhatWg\Url::parse("HTTPS://////EXAMPLE.com");
-$url2 = Uri\WhatWg\Url::parse("https://example.com");
-$url3 = Uri\WhatWg\Url::parse("https://example.com/foo/..");
-
-var_dump($url1->toUnicodeString());
-var_dump($url1->toAsciiString());
-var_dump($url2->toUnicodeString());
-var_dump($url2->toAsciiString());
-var_dump($url3->toUnicodeString());
-var_dump($url3->toAsciiString());
-
-?>
---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/"
-string(20) "https://example.com/"
-string(20) "https://example.com/"
-string(20) "https://example.com/"
-string(20) "https://example.com/"
-string(20) "https://example.com/"
-string(20) "https://example.com/"
diff --git a/ext/uri/tests/039.phpt b/ext/uri/tests/039.phpt
deleted file mode 100644
index ae662dfd172..00000000000
--- a/ext/uri/tests/039.phpt
+++ /dev/null
@@ -1,76 +0,0 @@
---TEST--
-Test percent-encoding of different URI components
---FILE--
-<?php
-
-function callRfc3986Getters($uri)
-{
- var_dump($uri->getScheme());
- var_dump($uri->getRawScheme());
- var_dump($uri->getUsername());
- var_dump($uri->getRawUsername());
- var_dump($uri->getPassword());
- var_dump($uri->getRawPassword());
- var_dump($uri->getUserInfo());
- var_dump($uri->getRawUserInfo());
- var_dump($uri->getHost());
- var_dump($uri->getRawHost());
- var_dump($uri->getPort());
- var_dump($uri->getPath());
- var_dump($uri->getRawPath());
- var_dump($uri->getQuery());
- var_dump($uri->getRawQuery());
- var_dump($uri->getFragment());
- var_dump($uri->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"
-string(4) "http"
-string(5) "apple"
-string(7) "%61pple"
-string(4) "pass"
-string(6) "p%61ss"
-string(10) "apple:pass"
-string(14) "%61pple:p%61ss"
-string(11) "example.com"
-string(13) "ex%61mple.com"
-NULL
-string(7) "/foobar"
-string(9) "/foob%61r"
-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/040.phpt b/ext/uri/tests/040.phpt
deleted file mode 100644
index 2699de18e17..00000000000
--- a/ext/uri/tests/040.phpt
+++ /dev/null
@@ -1,53 +0,0 @@
---TEST--
-Test HTTP URL validation
---FILE--
-<?php
-
-$uri = Uri\Rfc3986\Uri::parse("https:example.com");
-var_dump($uri);
-var_dump($uri->toRawString());
-
-$url = Uri\WhatWg\Url::parse("https:example.com");
-var_dump($url);
-var_dump($url->toAsciiString());
-
-?>
---EXPECTF--
-object(Uri\Rfc3986\Uri)#%d (%d) {
- ["scheme"]=>
- string(5) "https"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- NULL
- ["port"]=>
- NULL
- ["path"]=>
- string(11) "example.com"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
-string(17) "https:example.com"
-object(Uri\WhatWg\Url)#%d (%d) {
- ["scheme"]=>
- string(5) "https"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(11) "example.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(1) "/"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
-string(20) "https://example.com/"
diff --git a/ext/uri/tests/041.phpt b/ext/uri/tests/041.phpt
deleted file mode 100644
index 59a8e3211f9..00000000000
--- a/ext/uri/tests/041.phpt
+++ /dev/null
@@ -1,45 +0,0 @@
---TEST--
-Test relative URI parsing
---FILE--
-<?php
-
-$uri = Uri\Rfc3986\Uri::parse("?query#fragment");
-var_dump($uri);
-
-$errors = [];
-$url = Uri\WhatWg\Url::parse("?query#fragment", null, $errors);
-var_dump($url);
-var_dump($errors);
-
-?>
---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 aadb9e5c192..00000000000
--- a/ext/uri/tests/042.phpt
+++ /dev/null
@@ -1,48 +0,0 @@
---TEST--
-Test URN parsing
---FILE--
-<?php
-
-$uri = Uri\Rfc3986\Uri::parse("urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66");
-var_dump($uri);
-
-$url = Uri\WhatWg\Url::parse("urn:uuid:6e8bc430-9c3a-11d9-9669-0800200c9a66");
-var_dump($url);
-?>
---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/043.phpt b/ext/uri/tests/043.phpt
deleted file mode 100644
index 18c65e3c773..00000000000
--- a/ext/uri/tests/043.phpt
+++ /dev/null
@@ -1,155 +0,0 @@
---TEST--
-Test reference resolution
---FILE--
-<?php
-
-$uri = Uri\Rfc3986\Uri::parse("https://example.com/without-base");
-var_dump($uri);
-
-$uri = Uri\Rfc3986\Uri::parse("/with-base", new Uri\Rfc3986\Uri("https://example.com"));
-var_dump($uri);
-
-$uri = Uri\Rfc3986\Uri::parse("https://test.com/with-base-in-vain", new Uri\Rfc3986\Uri("https://example.com"));
-var_dump($uri);
-
-$uri = Uri\Rfc3986\Uri::parse("HTTPS://TEST.com/with-base-in-vain", Uri\Rfc3986\Uri::parse("https://example.com"));
-var_dump($uri);
-var_dump($uri->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) {
- ["scheme"]=>
- string(5) "https"
- ["username"]=>
- NULL
- ["password"]=>
- NULL
- ["host"]=>
- string(11) "example.com"
- ["port"]=>
- NULL
- ["path"]=>
- string(13) "/without-base"
- ["query"]=>
- NULL
- ["fragment"]=>
- NULL
-}
-object(Uri\Rfc3986\Uri)#%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\Rfc3986\Uri)#%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
-}
-object(Uri\Rfc3986\Uri)#%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
-}
-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/045.phpt b/ext/uri/tests/045.phpt
deleted file mode 100644
index f968716f9fc..00000000000
--- a/ext/uri/tests/045.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-Test percent-decoding of reserved characters in the path
---FILE--
-<?php
-
-$uri = new Uri\Rfc3986\Uri("https://example.com/foo/bar%2Fbaz");
-
-var_dump($uri->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/046.phpt b/ext/uri/tests/046.phpt
deleted file mode 100644
index 10d56024698..00000000000
--- a/ext/uri/tests/046.phpt
+++ /dev/null
@@ -1,87 +0,0 @@
---TEST--
-Test special path variants
---FILE--
-<?php
-
-$uri = new Uri\Rfc3986\Uri("mailto:johndoe@example.com");
-
-var_dump($uri->toRawString());
-var_dump($uri->getPath());
-var_dump($uri->getRawPath());
-
-$uri = new Uri\Rfc3986\Uri("foo/bar");
-var_dump($uri->toRawString());
-var_dump($uri->getPath());
-var_dump($uri->getRawPath());
-
-$uri = new Uri\Rfc3986\Uri("/foo/bar");
-var_dump($uri->toRawString());
-var_dump($uri->getPath());
-var_dump($uri->getRawPath());
-
-$uri = new Uri\Rfc3986\Uri("//");
-var_dump($uri->toRawString());
-var_dump($uri->getPath());
-var_dump($uri->getRawPath());
-
-$uri = new Uri\Rfc3986\Uri("///");
-var_dump($uri->toRawString());
-var_dump($uri->getPath());
-var_dump($uri->getRawPath());
-
-$uri = new Uri\Rfc3986\Uri("https://example.com");
-
-var_dump($uri->toRawString());
-var_dump($uri->getPath());
-var_dump($uri->getRawPath());
-
-$uri = new Uri\Rfc3986\Uri("https://example.com/");
-
-var_dump($uri->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"
-string(19) "johndoe@example.com"
-string(19) "johndoe@example.com"
-string(7) "foo/bar"
-string(7) "foo/bar"
-string(7) "foo/bar"
-string(8) "/foo/bar"
-string(8) "/foo/bar"
-string(8) "/foo/bar"
-string(2) "//"
-string(0) ""
-string(0) ""
-string(3) "///"
-string(1) "/"
-string(1) "/"
-string(19) "https://example.com"
-string(0) ""
-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/047.phpt b/ext/uri/tests/047.phpt
deleted file mode 100644
index de9a21efd9b..00000000000
--- a/ext/uri/tests/047.phpt
+++ /dev/null
@@ -1,55 +0,0 @@
---TEST--
-Test IP addresses
---FILE--
-<?php
-
-$uri = new Uri\Rfc3986\Uri("https://192.168.0.1");
-var_dump($uri->getRawHost());
-var_dump($uri->getHost());
-var_dump($uri->toRawString());
-var_dump($uri->toString());
-
-$uri = new Uri\Rfc3986\Uri("https://[2001:0db8:0001:0000:0000:0ab9:C0A8:0102]");
-var_dump($uri->getRawHost());
-var_dump($uri->getHost());
-var_dump($uri->toRawString());
-var_dump($uri->toString());
-
-$uri = new Uri\Rfc3986\Uri("//[v7.host]/source");
-var_dump($uri->getRawHost());
-var_dump($uri->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"
-string(11) "192.168.0.1"
-string(19) "https://192.168.0.1"
-string(19) "https://192.168.0.1"
-string(41) "[2001:0db8:0001:0000:0000:0ab9:C0A8:0102]"
-string(41) "[2001:0db8:0001:0000:0000:0ab9:c0a8:0102]"
-string(49) "https://[2001:0db8:0001:0000:0000:0ab9:c0a8:0102]"
-string(49) "https://[2001:0db8:0001:0000:0000:0ab9:c0a8:0102]"
-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/049.phpt b/ext/uri/tests/049.phpt
deleted file mode 100644
index 48f27277fab..00000000000
--- a/ext/uri/tests/049.phpt
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-Test percent-encoding normalization - special case
---FILE--
-<?php
-
-$uri = new Uri\Rfc3986\Uri("https://example.com/foo/bar%2Fbaz");
-var_dump($uri->getRawPath());
-var_dump($uri->getPath());
-
-$url = new Uri\WhatWg\Url("https://example.com/foo/bar%2Fbaz");
-var_dump($url->getPath());
-
-?>
---EXPECT--
-string(14) "/foo/bar%2Fbaz"
-string(14) "/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 3bd4052fb80..00000000000
--- a/ext/uri/tests/050.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-Test resolve() method - success cases
---FILE--
-<?php
-
-$uri = new Uri\Rfc3986\Uri("https://example.com");
-
-var_dump($uri->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/051.phpt b/ext/uri/tests/051.phpt
deleted file mode 100644
index cb9c975d238..00000000000
--- a/ext/uri/tests/051.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Test resolve() method - error cases
---FILE--
-<?php
-
-$uri = new Uri\Rfc3986\Uri("https://example.com");
-
-try {
- $uri->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/065.phpt b/ext/uri/tests/065.phpt
deleted file mode 100644
index 2c84cceea3d..00000000000
--- a/ext/uri/tests/065.phpt
+++ /dev/null
@@ -1,115 +0,0 @@
---TEST--
-Test that overwriting the URI is not possible
---FILE--
-<?php
-
-$uri = new Uri\WhatWg\Url('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\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/rfc3986/builder/host_error_ipv6_closing_brace.phpt b/ext/uri/tests/rfc3986/builder/host_error_ipv6_closing_brace.phpt
index feda6170b38..f03a8b680a7 100644
--- a/ext/uri/tests/rfc3986/builder/host_error_ipv6_closing_brace.phpt
+++ b/ext/uri/tests/rfc3986/builder/host_error_ipv6_closing_brace.phpt
@@ -8,7 +8,7 @@
try {
$builder->setHost("[2001:db8:85a3:0000:0000:8a2e:0370:7334");
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/034.phpt b/ext/uri/tests/rfc3986/general/array_cast_success.phpt
similarity index 53%
rename from ext/uri/tests/034.phpt
rename to ext/uri/tests/rfc3986/general/array_cast_success.phpt
index 35d51aad866..9e8e56eb727 100644
--- a/ext/uri/tests/034.phpt
+++ b/ext/uri/tests/rfc3986/general/array_cast_success.phpt
@@ -1,17 +1,12 @@
--TEST--
-Test array cast
+Test casting Uri\Rfc3986\Uri to array
--FILE--
<?php
$uri = new Uri\Rfc3986\Uri("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists");
var_dump((array) $uri);
-$url = new Uri\WhatWg\Url("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists");
-var_dump((array) $url);
-
?>
--EXPECTF--
array(%d) {
}
-array(%d) {
-}
diff --git a/ext/uri/tests/rfc3986/general/clone_success.phpt b/ext/uri/tests/rfc3986/general/clone_success.phpt
new file mode 100644
index 00000000000..915909bb735
--- /dev/null
+++ b/ext/uri/tests/rfc3986/general/clone_success.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test cloning Uri\Rfc3986\Uri
+--FILE--
+<?php
+
+$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
+$uri2 = clone $uri1;
+
+var_dump($uri1->toRawString());
+
+var_dump($uri2);
+var_dump($uri2->toRawString());
+var_dump($uri2->toString());
+
+?>
+--EXPECTF--
+string(19) "https://example.com"
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(0) ""
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(19) "https://example.com"
+string(19) "https://example.com"
diff --git a/ext/uri/tests/rfc3986/general/constructor_error_reinitialization.phpt b/ext/uri/tests/rfc3986/general/constructor_error_reinitialization.phpt
new file mode 100644
index 00000000000..412d9e83ac1
--- /dev/null
+++ b/ext/uri/tests/rfc3986/general/constructor_error_reinitialization.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test Uri\Rfc3986\Uri __construct() - error - reinitialization
+--FILE--
+<?php
+
+$uri = new Uri\Rfc3986\Uri('https://example.com');
+
+try {
+ $uri->__construct('ftp://example.org');
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--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
+}
+string(19) "https://example.com"
+string(19) "https://example.com"
diff --git a/ext/uri/tests/021.phpt b/ext/uri/tests/rfc3986/general/extension_error.phpt
similarity index 100%
rename from ext/uri/tests/021.phpt
rename to ext/uri/tests/rfc3986/general/extension_error.phpt
diff --git a/ext/uri/tests/015.phpt b/ext/uri/tests/rfc3986/general/instantiate_without_constructor_error.phpt
similarity index 51%
rename from ext/uri/tests/015.phpt
rename to ext/uri/tests/rfc3986/general/instantiate_without_constructor_error.phpt
index e3a846f5e31..5806ec1f14e 100644
--- a/ext/uri/tests/015.phpt
+++ b/ext/uri/tests/rfc3986/general/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 @@
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/getters/basic_success_percent_encoded_components.phpt b/ext/uri/tests/rfc3986/getters/basic_success_percent_encoded_components.phpt
new file mode 100644
index 00000000000..e0df794c11b
--- /dev/null
+++ b/ext/uri/tests/rfc3986/getters/basic_success_percent_encoded_components.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test Uri\Rfc3986\Uri component retrieval - basic - percent-encoded components
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("http://%61pple:p%61ss@ex%61mple.com/foob%61r?%61bc=%61bc#%61bc");
+
+var_dump($uri->getScheme());
+var_dump($uri->getRawScheme());
+var_dump($uri->getUsername());
+var_dump($uri->getRawUsername());
+var_dump($uri->getPassword());
+var_dump($uri->getRawPassword());
+var_dump($uri->getUserInfo());
+var_dump($uri->getRawUserInfo());
+var_dump($uri->getHost());
+var_dump($uri->getRawHost());
+var_dump($uri->getPort());
+var_dump($uri->getPath());
+var_dump($uri->getRawPath());
+var_dump($uri->getQuery());
+var_dump($uri->getRawQuery());
+var_dump($uri->getFragment());
+var_dump($uri->getRawFragment());
+
+?>
+--EXPECT--
+string(4) "http"
+string(4) "http"
+string(5) "apple"
+string(7) "%61pple"
+string(4) "pass"
+string(6) "p%61ss"
+string(10) "apple:pass"
+string(14) "%61pple:p%61ss"
+string(11) "example.com"
+string(13) "ex%61mple.com"
+NULL
+string(7) "/foobar"
+string(9) "/foob%61r"
+string(7) "abc=abc"
+string(11) "%61bc=%61bc"
+string(3) "abc"
+string(5) "%61bc"
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 00000000000..dd3a527ff9e
--- /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--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("ftp://user:pass@foo.com?query=abc#foo");
+
+try {
+ $uri->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 00000000000..dbdf0cd877d
--- /dev/null
+++ b/ext/uri/tests/rfc3986/modification/host_success_ipv4_to_ipv6.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test Uri\Rfc3986\Uri component modification - host - changing IPv4 to IPv6
+--FILE--
+<?php
+
+$uri1 = Uri\Rfc3986\Uri::parse("https://192.168.0.1");
+$uri2 = $uri1->withHost("[2001:0db8:3333:4444:5555:6666:7777:8888]");
+
+var_dump($uri1->getRawHost());
+
+var_dump($uri2->getRawHost());
+var_dump($uri2->toRawString());
+var_dump($uri2->getHost());
+var_dump($uri2->toString());
+
+?>
+--EXPECT--
+string(11) "192.168.0.1"
+string(41) "[2001:0db8:3333:4444:5555:6666:7777:8888]"
+string(49) "https://[2001:0db8:3333:4444:5555:6666:7777:8888]"
+string(41) "[2001:0db8:3333:4444:5555:6666:7777:8888]"
+string(49) "https://[2001:0db8: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 00000000000..89fa9502cce
--- /dev/null
+++ b/ext/uri/tests/rfc3986/modification/host_success_percent_encoded_reserved.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Test Uri\Rfc3986\Uri component modification - host - percent-encoded reserved characters
+--FILE--
+<?php
+
+$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
+$uri2 = $uri1->withHost("t%3As%2Ft.com");
+
+var_dump($uri1->getRawHost());
+
+var_dump($uri2->getRawHost());
+var_dump($uri2->toRawString());
+var_dump($uri2->getHost());
+var_dump($uri2->toString());
+
+?>
+--EXPECT--
+string(11) "example.com"
+string(13) "t%3As%2Ft.com"
+string(21) "https://t%3As%2Ft.com"
+string(13) "t%3As%2Ft.com"
+string(21) "https://t%3As%2Ft.com"
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 00000000000..51ab43185a4
--- /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--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("/foo");
+
+try {
+ $uri->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 00000000000..4710f4fb81b
--- /dev/null
+++ b/ext/uri/tests/rfc3986/modification/port_success_empty_host.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test Uri\Rfc3986\Uri component modification - port - adding with an empty host
+--FILE--
+<?php
+
+$uri1 = Uri\Rfc3986\Uri::parse("file:///foo/bar");
+$uri2 = $uri1->withPort(80);
+
+var_dump($uri1->getPort());
+
+var_dump($uri2->getPort());
+var_dump($uri2->toRawString());
+
+?>
+--EXPECT--
+NULL
+int(80)
+string(18) "file://:80/foo/bar"
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 00000000000..3783e0122bd
--- /dev/null
+++ b/ext/uri/tests/rfc3986/modification/port_success_unset_without_host.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test Uri\Rfc3986\Uri component modification - port - unsetting with an empty host
+--FILE--
+<?php
+
+$uri1 = Uri\Rfc3986\Uri::parse('https://:80/foo/bar');
+$uri2 = $uri1->withPort(null);
+
+var_dump($uri1->getPort());
+
+var_dump($uri2->getPort());
+var_dump($uri2->toRawString());
+
+?>
+--EXPECT--
+int(80)
+NULL
+string(16) "https:///foo/bar"
diff --git a/ext/uri/tests/048.phpt b/ext/uri/tests/rfc3986/normalization/percent_encoding.phpt
similarity index 90%
rename from ext/uri/tests/048.phpt
rename to ext/uri/tests/rfc3986/normalization/percent_encoding.phpt
index ee7a396f179..f2ddb1d345e 100644
--- a/ext/uri/tests/048.phpt
+++ b/ext/uri/tests/rfc3986/normalization/percent_encoding.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test RFC 3986 percent-encoding normalization
+Test Uri\Rfc3986\Uri normalization - percent-encoding
--FILE--
<?php
diff --git a/ext/uri/tests/rfc3986/parsing/basic_error_emoji_relative_reference_returns_null.phpt b/ext/uri/tests/rfc3986/parsing/basic_error_emoji_relative_reference_returns_null.phpt
new file mode 100644
index 00000000000..2226c55b35c
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/basic_error_emoji_relative_reference_returns_null.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - basic - parse() returns null for an emoji relative reference
+--FILE--
+<?php
+
+var_dump(Uri\Rfc3986\Uri::parse("🐘"));
+
+?>
+--EXPECT--
+NULL
diff --git a/ext/uri/tests/rfc3986/parsing/basic_error_invalid_uris_return_null.phpt b/ext/uri/tests/rfc3986/parsing/basic_error_invalid_uris_return_null.phpt
new file mode 100644
index 00000000000..1e8e95fa5f7
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/basic_error_invalid_uris_return_null.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - basic - parse() returns null for invalid URIs
+--FILE--
+<?php
+
+var_dump(Uri\Rfc3986\Uri::parse(':'));
+var_dump(Uri\Rfc3986\Uri::parse("https://你好你好"));
+var_dump(Uri\Rfc3986\Uri::parse("https://0Xc0.0250.01"));
+
+?>
+--EXPECT--
+NULL
+NULL
+NULL
diff --git a/ext/uri/tests/055.phpt b/ext/uri/tests/rfc3986/parsing/basic_error_relative_base.phpt
similarity index 77%
rename from ext/uri/tests/055.phpt
rename to ext/uri/tests/rfc3986/parsing/basic_error_relative_base.phpt
index fddb313149d..dcbf41dc52c 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 - basic - base URI is a relative reference
--FILE--
<?php
@@ -8,6 +8,7 @@
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
+
?>
--EXPECT--
Uri\InvalidUriException: The specified base URI must be absolute
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 00000000000..109777ba533
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/basic_success_constructor.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - basic - parsing all components with the constructor
+--FILE--
+<?php
+
+$uri = new Uri\Rfc3986\Uri("https://username:password@example.com:8080/path?q=r#fragment");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--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"
+}
+string(60) "https://username:password@example.com:8080/path?q=r#fragment"
+string(60) "https://username:password@example.com:8080/path?q=r#fragment"
diff --git a/ext/uri/tests/rfc3986/parsing/host_error_multibyte_emoji.phpt b/ext/uri/tests/rfc3986/parsing/host_error_multibyte_emoji.phpt
new file mode 100644
index 00000000000..be4fc5aa626
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/host_error_multibyte_emoji.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - host - emoji code point
+--FILE--
+<?php
+
+var_dump(Uri\Rfc3986\Uri::parse("https://🐘.com"));
+
+?>
+--EXPECT--
+NULL
diff --git a/ext/uri/tests/rfc3986/parsing/host_success_empty_network_path_reference.phpt b/ext/uri/tests/rfc3986/parsing/host_success_empty_network_path_reference.phpt
new file mode 100644
index 00000000000..dd0856784d0
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/host_success_empty_network_path_reference.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - host - empty in a network-path reference
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("///foo/");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ NULL
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(0) ""
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(5) "/foo/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(7) "///foo/"
+string(7) "///foo/"
diff --git a/ext/uri/tests/rfc3986/parsing/host_success_ipv4_octal_like_registered_name.phpt b/ext/uri/tests/rfc3986/parsing/host_success_ipv4_octal_like_registered_name.phpt
new file mode 100644
index 00000000000..02dd4db3659
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/host_success_ipv4_octal_like_registered_name.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - host - octal-like registered name
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("https://0300.0250.0000.0001");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+var_dump($uri->getHostType());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(19) "0300.0250.0000.0001"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(0) ""
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(27) "https://0300.0250.0000.0001"
+string(27) "https://0300.0250.0000.0001"
+enum(Uri\Rfc3986\UriHostType::RegisteredName)
diff --git a/ext/uri/tests/rfc3986/parsing/host_success_ipvfuture_relative_reference.phpt b/ext/uri/tests/rfc3986/parsing/host_success_ipvfuture_relative_reference.phpt
new file mode 100644
index 00000000000..4fa50788d40
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/host_success_ipvfuture_relative_reference.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - host - IPvFuture in a relative reference
+--FILE--
+<?php
+
+$uri = new Uri\Rfc3986\Uri("//[v7.host]/source");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ NULL
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(9) "[v7.host]"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(7) "/source"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(18) "//[v7.host]/source"
+string(18) "//[v7.host]/source"
diff --git a/ext/uri/tests/rfc3986/parsing/path_success_multiple_leading_slashes.phpt b/ext/uri/tests/rfc3986/parsing/path_success_multiple_leading_slashes.phpt
new file mode 100644
index 00000000000..f814a0582b0
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/path_success_multiple_leading_slashes.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - path - multiple leading slashes after an empty authority
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("http://////www.EXAMPLE.com:80");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ string(4) "http"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(0) ""
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(22) "////www.EXAMPLE.com:80"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(29) "http://////www.EXAMPLE.com:80"
+string(29) "http://////www.EXAMPLE.com:80"
diff --git a/ext/uri/tests/rfc3986/parsing/path_success_percent_encoded.phpt b/ext/uri/tests/rfc3986/parsing/path_success_percent_encoded.phpt
new file mode 100644
index 00000000000..1ebbb9a0ae0
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/path_success_percent_encoded.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - path - percent-encoded slash character
+--FILE--
+<?php
+
+$uri = new Uri\Rfc3986\Uri("https://example.com/foo/bar%2Fbaz");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(14) "/foo/bar%2Fbaz"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(33) "https://example.com/foo/bar%2Fbaz"
+string(33) "https://example.com/foo/bar%2Fbaz"
diff --git a/ext/uri/tests/rfc3986/parsing/path_success_relative_reference_network.phpt b/ext/uri/tests/rfc3986/parsing/path_success_relative_reference_network.phpt
new file mode 100644
index 00000000000..8aa2abe07d9
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/path_success_relative_reference_network.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - path - network-path reference
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("//host123/");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ NULL
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(7) "host123"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(10) "//host123/"
+string(10) "//host123/"
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 00000000000..ead4a0061e8
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/path_success_relative_reference_numeric.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - path - numeric relative reference
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("192.168/contact.html");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--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
+}
+string(20) "192.168/contact.html"
+string(20) "192.168/contact.html"
diff --git a/ext/uri/tests/rfc3986/parsing/path_success_special_chars.phpt b/ext/uri/tests/rfc3986/parsing/path_success_special_chars.phpt
new file mode 100644
index 00000000000..ecf9ab5c749
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/path_success_special_chars.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - path - special characters
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("/foo:1@&+=");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ NULL
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ NULL
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(10) "/foo:1@&+="
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(10) "/foo:1@&+="
+string(10) "/foo:1@&+="
diff --git a/ext/uri/tests/058.phpt b/ext/uri/tests/rfc3986/parsing/port_error_overflow.phpt
similarity index 86%
rename from ext/uri/tests/058.phpt
rename to ext/uri/tests/rfc3986/parsing/port_error_overflow.phpt
index c1ceaa1e02e..169f74e61de 100644
--- a/ext/uri/tests/058.phpt
+++ b/ext/uri/tests/rfc3986/parsing/port_error_overflow.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test that integer overflows in the port are rejected
+Test Uri\Rfc3986\Uri parsing - port - integer overflow
--FILE--
<?php
@@ -20,7 +20,7 @@
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_error_multibyte.phpt b/ext/uri/tests/rfc3986/parsing/query_error_multibyte.phpt
new file mode 100644
index 00000000000..4f450933788
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/query_error_multibyte.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - query - multibyte character
+--FILE--
+<?php
+
+var_dump(Uri\Rfc3986\Uri::parse("http://example.com?foo=Helló Wörld"));
+
+?>
+--EXPECT--
+NULL
diff --git a/ext/uri/tests/rfc3986/parsing/query_error_multibyte_emoji.phpt b/ext/uri/tests/rfc3986/parsing/query_error_multibyte_emoji.phpt
new file mode 100644
index 00000000000..7b720ee2c8c
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/query_error_multibyte_emoji.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - query - emoji code point
+--FILE--
+<?php
+
+var_dump(Uri\Rfc3986\Uri::parse("https://example.com?🐘=🐘"));
+
+?>
+--EXPECT--
+NULL
diff --git a/ext/uri/tests/rfc3986/parsing/query_error_special.phpt b/ext/uri/tests/rfc3986/parsing/query_error_special.phpt
new file mode 100644
index 00000000000..5bec22c030d
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/query_error_special.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - query - special characters
+--FILE--
+<?php
+
+var_dump(Uri\Rfc3986\Uri::parse("http://example.com?foobar='<script> + @"));
+
+?>
+--EXPECT--
+NULL
diff --git a/ext/uri/tests/rfc3986/parsing/query_success_percent_encoded.phpt b/ext/uri/tests/rfc3986/parsing/query_success_percent_encoded.phpt
new file mode 100644
index 00000000000..fb68f507928
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/query_success_percent_encoded.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - query - percent-encoded bytes
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("http://example.com?foo=Hell%C3%B3+W%C3%B6rld");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--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
+}
+string(44) "http://example.com?foo=Hell%C3%B3+W%C3%B6rld"
+string(44) "http://example.com?foo=Hell%C3%B3+W%C3%B6rld"
diff --git a/ext/uri/tests/rfc3986/parsing/query_success_percent_encoded_special.phpt b/ext/uri/tests/rfc3986/parsing/query_success_percent_encoded_special.phpt
new file mode 100644
index 00000000000..f3159286b53
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/query_success_percent_encoded_special.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - query - percent-encoded special characters
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("http://example.com?foobar=%27%3Cscript%3E+%2B+%40");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--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(30) "foobar=%27%3Cscript%3E+%2B+%40"
+ ["fragment"]=>
+ NULL
+}
+string(49) "http://example.com?foobar=%27%3Cscript%3E+%2B+%40"
+string(49) "http://example.com?foobar=%27%3Cscript%3E+%2B+%40"
diff --git a/ext/uri/tests/rfc3986/parsing/query_success_plus.phpt b/ext/uri/tests/rfc3986/parsing/query_success_plus.phpt
new file mode 100644
index 00000000000..f70976dd954
--- /dev/null
+++ b/ext/uri/tests/rfc3986/parsing/query_success_plus.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri parsing - query - plus character
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("http://example.com?foo=foo+bar");
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--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(11) "foo=foo+bar"
+ ["fragment"]=>
+ NULL
+}
+string(30) "http://example.com?foo=foo+bar"
+string(30) "http://example.com?foo=foo+bar"
diff --git a/ext/uri/tests/rfc3986/reference_resolution/parse_success_absolute_with_base.phpt b/ext/uri/tests/rfc3986/reference_resolution/parse_success_absolute_with_base.phpt
new file mode 100644
index 00000000000..54f96abf14c
--- /dev/null
+++ b/ext/uri/tests/rfc3986/reference_resolution/parse_success_absolute_with_base.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri reference resolution - parse() - absolute URI with base URI
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("https://test.com/with-base-in-vain", new Uri\Rfc3986\Uri("https://example.com"));
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%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
+}
+string(34) "https://test.com/with-base-in-vain"
+string(34) "https://test.com/with-base-in-vain"
diff --git a/ext/uri/tests/rfc3986/reference_resolution/parse_success_relative_with_base.phpt b/ext/uri/tests/rfc3986/reference_resolution/parse_success_relative_with_base.phpt
new file mode 100644
index 00000000000..ce601e197dd
--- /dev/null
+++ b/ext/uri/tests/rfc3986/reference_resolution/parse_success_relative_with_base.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\Rfc3986\Uri reference resolution - parse() - relative reference with base URI
+--FILE--
+<?php
+
+$uri = Uri\Rfc3986\Uri::parse("/with-base", new Uri\Rfc3986\Uri("https://example.com"));
+
+var_dump($uri);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+object(Uri\Rfc3986\Uri)#%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
+}
+string(29) "https://example.com/with-base"
+string(29) "https://example.com/with-base"
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 00000000000..3fcf488074e
--- /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--
+<?php
+
+$uri = new Uri\Rfc3986\Uri("https://example.com");
+
+try {
+ $uri->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/reference_resolution/resolve_success_absolute_uri.phpt b/ext/uri/tests/rfc3986/reference_resolution/resolve_success_absolute_uri.phpt
new file mode 100644
index 00000000000..433f62fd372
--- /dev/null
+++ b/ext/uri/tests/rfc3986/reference_resolution/resolve_success_absolute_uri.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test Uri\Rfc3986\Uri reference resolution - resolve() - absolute URI
+--FILE--
+<?php
+
+$uri1 = new Uri\Rfc3986\Uri("https://example.com");
+$uri2 = $uri1->resolve("https://test.com/foo");
+
+var_dump($uri1->toRawString());
+
+var_dump($uri2);
+var_dump($uri2->toRawString());
+var_dump($uri2->toString());
+
+?>
+--EXPECTF--
+string(19) "https://example.com"
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(8) "test.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(4) "/foo"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(20) "https://test.com/foo"
+string(20) "https://test.com/foo"
diff --git a/ext/uri/tests/rfc3986/reference_resolution/resolve_success_relative_reference.phpt b/ext/uri/tests/rfc3986/reference_resolution/resolve_success_relative_reference.phpt
new file mode 100644
index 00000000000..b09789c7cf9
--- /dev/null
+++ b/ext/uri/tests/rfc3986/reference_resolution/resolve_success_relative_reference.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Test Uri\Rfc3986\Uri reference resolution - resolve() - relative reference
+--FILE--
+<?php
+
+$uri1 = new Uri\Rfc3986\Uri("https://example.com");
+$uri2 = $uri1->resolve("/foo/");
+
+var_dump($uri1->toRawString());
+
+var_dump($uri2);
+var_dump($uri2->toRawString());
+var_dump($uri2->toString());
+
+?>
+--EXPECTF--
+string(19) "https://example.com"
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(5) "/foo/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(24) "https://example.com/foo/"
+string(24) "https://example.com/foo/"
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 00000000000..95b25b30712
--- /dev/null
+++ b/ext/uri/tests/rfc3986/serialization/basic_success.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test Uri\Rfc3986\Uri serialization and unserialization
+--FILE--
+<?php
+
+$uri1 = new Uri\Rfc3986\Uri(
+ "https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists"
+);
+
+$serializedUri1 = serialize($uri1);
+var_dump($serializedUri1);
+
+$uri2 = unserialize($serializedUri1);
+var_dump($uri2);
+var_dump($uri2->toRawString());
+var_dump($uri2->toString());
+
+?>
+--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"
+}
+string(99) "https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists"
+string(99) "https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists"
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 b17765240c7..a0521ab6b3c 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 Uri\Rfc3986\Uri json_encode() - success
--FILE--
<?php
$uri = new Uri\Rfc3986\Uri("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists");
var_dump(json_encode($uri));
-$url = new Uri\WhatWg\Url("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists");
-var_dump(json_encode($url));
-
?>
--EXPECT--
string(2) "{}"
-string(2) "{}"
diff --git a/ext/uri/tests/rfc3986/serialization/unserialize_error_invalid_data.phpt b/ext/uri/tests/rfc3986/serialization/unserialize_error_invalid_data.phpt
new file mode 100644
index 00000000000..0121b0b961f
--- /dev/null
+++ b/ext/uri/tests/rfc3986/serialization/unserialize_error_invalid_data.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Test Uri\Rfc3986\Uri unserialize() - error - invalid data
+--FILE--
+<?php
+
+try {
+ unserialize('O:15:"Uri\Rfc3986\Uri":1:{i:0;a:0:{}}'); // less than 2 items
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->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/rfc3986/serialization/unserialize_error_legacy_format.phpt b/ext/uri/tests/rfc3986/serialization/unserialize_error_legacy_format.phpt
new file mode 100644
index 00000000000..ef76114f2f4
--- /dev/null
+++ b/ext/uri/tests/rfc3986/serialization/unserialize_error_legacy_format.phpt
@@ -0,0 +1,11 @@
+--TEST--
+GH-22046: Uri\Rfc3986\Uri cannot be unserialized with the unsupported C format
+--FILE--
+<?php
+
+unserialize('C:15:"Uri\Rfc3986\Uri":0:{}');
+?>
+--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/unserialize_error_reinitialization.phpt b/ext/uri/tests/rfc3986/serialization/unserialize_error_reinitialization.phpt
new file mode 100644
index 00000000000..14263afce9f
--- /dev/null
+++ b/ext/uri/tests/rfc3986/serialization/unserialize_error_reinitialization.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Test Uri\Rfc3986\Uri __unserialize() - error - reinitialization
+--FILE--
+<?php
+
+$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);
+var_dump($uri->toRawString());
+var_dump($uri->toString());
+
+?>
+--EXPECTF--
+Exception: Invalid serialization data for Uri\Rfc3986\Uri object
+object(Uri\Rfc3986\Uri)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(0) ""
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(19) "https://example.com"
+string(19) "https://example.com"
diff --git a/ext/uri/tests/whatwg/builder/basic_error_with_base.phpt b/ext/uri/tests/whatwg/builder/basic_error_with_base.phpt
index 6f65cdacdb4..8fc06a2f8d9 100644
--- a/ext/uri/tests/whatwg/builder/basic_error_with_base.phpt
+++ b/ext/uri/tests/whatwg/builder/basic_error_with_base.phpt
@@ -9,7 +9,7 @@
try {
$builder->build(new Uri\WhatWg\Url("/foo/bar"));
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/host_error_ipv6_closing_brace_opaque.phpt b/ext/uri/tests/whatwg/builder/host_error_ipv6_closing_brace_opaque.phpt
index 7f3fbb35da6..53f905692c6 100644
--- a/ext/uri/tests/whatwg/builder/host_error_ipv6_closing_brace_opaque.phpt
+++ b/ext/uri/tests/whatwg/builder/host_error_ipv6_closing_brace_opaque.phpt
@@ -9,7 +9,7 @@
try {
$builder->setHost("[2001:db8:85a3:0000:0000:8a2e:0370:7334");
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/host_error_ipv6_closing_brace_special.phpt b/ext/uri/tests/whatwg/builder/host_error_ipv6_closing_brace_special.phpt
index 94ba827ca32..b442d888215 100644
--- a/ext/uri/tests/whatwg/builder/host_error_ipv6_closing_brace_special.phpt
+++ b/ext/uri/tests/whatwg/builder/host_error_ipv6_closing_brace_special.phpt
@@ -9,7 +9,7 @@
try {
$builder->setHost("[2001:%30db8:85a3:0000:0000:8a2e:0370:7334");
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/host_error_null_special.phpt b/ext/uri/tests/whatwg/builder/host_error_null_special.phpt
index 973f4ef9aca..e9abda112c2 100644
--- a/ext/uri/tests/whatwg/builder/host_error_null_special.phpt
+++ b/ext/uri/tests/whatwg/builder/host_error_null_special.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\UrlBuilder::setHost() - success - null in case of special URLs
+Test Uri\WhatWg\UrlBuilder::setHost() - error - null in case of special URLs
--FILE--
<?php
@@ -10,7 +10,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/host_error_percent_encoding1.phpt b/ext/uri/tests/whatwg/builder/host_error_percent_encoding1.phpt
index 2dc8c76189f..e90371744e6 100644
--- a/ext/uri/tests/whatwg/builder/host_error_percent_encoding1.phpt
+++ b/ext/uri/tests/whatwg/builder/host_error_percent_encoding1.phpt
@@ -10,7 +10,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/host_error_percent_encoding2.phpt b/ext/uri/tests/whatwg/builder/host_error_percent_encoding2.phpt
index 90a228ded22..efc2d928bb6 100644
--- a/ext/uri/tests/whatwg/builder/host_error_percent_encoding2.phpt
+++ b/ext/uri/tests/whatwg/builder/host_error_percent_encoding2.phpt
@@ -9,7 +9,7 @@
try {
$builder->setHost("[2001:%308:85a3:0000:0000:8a2e:0370:7334]");
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/host_error_percent_encoding3.phpt b/ext/uri/tests/whatwg/builder/host_error_percent_encoding3.phpt
index aee9f95d1f4..7ba24a56a31 100644
--- a/ext/uri/tests/whatwg/builder/host_error_percent_encoding3.phpt
+++ b/ext/uri/tests/whatwg/builder/host_error_percent_encoding3.phpt
@@ -10,7 +10,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/password_error_empty_opaque_host.phpt b/ext/uri/tests/whatwg/builder/password_error_empty_opaque_host.phpt
index 5c79856b93c..831ff446f78 100644
--- a/ext/uri/tests/whatwg/builder/password_error_empty_opaque_host.phpt
+++ b/ext/uri/tests/whatwg/builder/password_error_empty_opaque_host.phpt
@@ -11,7 +11,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/password_error_file_scheme.phpt b/ext/uri/tests/whatwg/builder/password_error_file_scheme.phpt
index e6f4f993c4d..f4349ef384d 100644
--- a/ext/uri/tests/whatwg/builder/password_error_file_scheme.phpt
+++ b/ext/uri/tests/whatwg/builder/password_error_file_scheme.phpt
@@ -11,7 +11,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/password_error_missing_host.phpt b/ext/uri/tests/whatwg/builder/password_error_missing_host.phpt
index 9b3ba087633..482612573e5 100644
--- a/ext/uri/tests/whatwg/builder/password_error_missing_host.phpt
+++ b/ext/uri/tests/whatwg/builder/password_error_missing_host.phpt
@@ -10,7 +10,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/password_error_missing_opaque_host.phpt b/ext/uri/tests/whatwg/builder/password_error_missing_opaque_host.phpt
index efc14b06a41..cbe09fcbefe 100644
--- a/ext/uri/tests/whatwg/builder/password_error_missing_opaque_host.phpt
+++ b/ext/uri/tests/whatwg/builder/password_error_missing_opaque_host.phpt
@@ -10,7 +10,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/port_error_empty_opaque_host.phpt b/ext/uri/tests/whatwg/builder/port_error_empty_opaque_host.phpt
index acf82a1a12c..b1a8e0d86e3 100644
--- a/ext/uri/tests/whatwg/builder/port_error_empty_opaque_host.phpt
+++ b/ext/uri/tests/whatwg/builder/port_error_empty_opaque_host.phpt
@@ -11,7 +11,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/port_error_file_scheme.phpt b/ext/uri/tests/whatwg/builder/port_error_file_scheme.phpt
index 08559dbfd20..c514beb71b2 100644
--- a/ext/uri/tests/whatwg/builder/port_error_file_scheme.phpt
+++ b/ext/uri/tests/whatwg/builder/port_error_file_scheme.phpt
@@ -11,7 +11,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/port_error_file_with_host_and_port.phpt b/ext/uri/tests/whatwg/builder/port_error_file_with_host_and_port.phpt
index 9e4e17ca3ae..b5f3131b0b7 100644
--- a/ext/uri/tests/whatwg/builder/port_error_file_with_host_and_port.phpt
+++ b/ext/uri/tests/whatwg/builder/port_error_file_with_host_and_port.phpt
@@ -11,7 +11,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/port_error_large.phpt b/ext/uri/tests/whatwg/builder/port_error_large.phpt
index 46e80e1689b..38f626a9e35 100644
--- a/ext/uri/tests/whatwg/builder/port_error_large.phpt
+++ b/ext/uri/tests/whatwg/builder/port_error_large.phpt
@@ -13,7 +13,7 @@
*/
$builder->setPort(PHP_INT_MAX);
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/port_error_missing_opaque_host.phpt b/ext/uri/tests/whatwg/builder/port_error_missing_opaque_host.phpt
index 3130b27cfcb..4e3e42188d4 100644
--- a/ext/uri/tests/whatwg/builder/port_error_missing_opaque_host.phpt
+++ b/ext/uri/tests/whatwg/builder/port_error_missing_opaque_host.phpt
@@ -10,7 +10,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/port_error_negative.phpt b/ext/uri/tests/whatwg/builder/port_error_negative.phpt
index a1a723f43ca..0b7dd7e67b9 100644
--- a/ext/uri/tests/whatwg/builder/port_error_negative.phpt
+++ b/ext/uri/tests/whatwg/builder/port_error_negative.phpt
@@ -8,7 +8,7 @@
try {
$builder->setPort(-1);
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/scheme_error_c0_control_space_char.phpt b/ext/uri/tests/whatwg/builder/scheme_error_c0_control_space_char.phpt
index 285e9113246..e1980ee4d53 100644
--- a/ext/uri/tests/whatwg/builder/scheme_error_c0_control_space_char.phpt
+++ b/ext/uri/tests/whatwg/builder/scheme_error_c0_control_space_char.phpt
@@ -8,7 +8,7 @@
try {
$builder->setScheme(" \x01https \x02");
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/scheme_error_empty.phpt b/ext/uri/tests/whatwg/builder/scheme_error_empty.phpt
index f4090a9c4aa..7b5d5b7fa1a 100644
--- a/ext/uri/tests/whatwg/builder/scheme_error_empty.phpt
+++ b/ext/uri/tests/whatwg/builder/scheme_error_empty.phpt
@@ -8,7 +8,7 @@
try {
$builder->setScheme("");
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/scheme_error_first_char.phpt b/ext/uri/tests/whatwg/builder/scheme_error_first_char.phpt
index 34a70c043aa..d791ecb599b 100644
--- a/ext/uri/tests/whatwg/builder/scheme_error_first_char.phpt
+++ b/ext/uri/tests/whatwg/builder/scheme_error_first_char.phpt
@@ -8,7 +8,7 @@
try {
$builder->setScheme("1");
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/scheme_error_special_char.phpt b/ext/uri/tests/whatwg/builder/scheme_error_special_char.phpt
index c37abc1ebb7..c5bd82e6d6b 100644
--- a/ext/uri/tests/whatwg/builder/scheme_error_special_char.phpt
+++ b/ext/uri/tests/whatwg/builder/scheme_error_special_char.phpt
@@ -8,7 +8,7 @@
try {
$builder->setScheme(":");
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/username_error_empty_opaque_host.phpt b/ext/uri/tests/whatwg/builder/username_error_empty_opaque_host.phpt
index c97ffd49afa..fa63c5a3aa3 100644
--- a/ext/uri/tests/whatwg/builder/username_error_empty_opaque_host.phpt
+++ b/ext/uri/tests/whatwg/builder/username_error_empty_opaque_host.phpt
@@ -11,7 +11,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/username_error_file_scheme.phpt b/ext/uri/tests/whatwg/builder/username_error_file_scheme.phpt
index aee81ee3b83..fa1a13af04c 100644
--- a/ext/uri/tests/whatwg/builder/username_error_file_scheme.phpt
+++ b/ext/uri/tests/whatwg/builder/username_error_file_scheme.phpt
@@ -11,7 +11,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/uri/tests/whatwg/builder/username_error_missing_opaque_host.phpt b/ext/uri/tests/whatwg/builder/username_error_missing_opaque_host.phpt
index 257266f97c9..43ebf550832 100644
--- a/ext/uri/tests/whatwg/builder/username_error_missing_opaque_host.phpt
+++ b/ext/uri/tests/whatwg/builder/username_error_missing_opaque_host.phpt
@@ -10,7 +10,7 @@
try {
$builder->build();
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
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 7f68772e548..c869299eaab 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--
<?php
diff --git a/ext/uri/tests/052.phpt b/ext/uri/tests/whatwg/exceptions/url_validation_error_constructor_reentry.phpt
similarity index 91%
rename from ext/uri/tests/052.phpt
rename to ext/uri/tests/whatwg/exceptions/url_validation_error_constructor_reentry.phpt
index b0867b02bd5..e5a473b4a6a 100644
--- a/ext/uri/tests/052.phpt
+++ b/ext/uri/tests/whatwg/exceptions/url_validation_error_constructor_reentry.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test UrlValidationError constructor error handling
+Test Uri\WhatWg\UrlValidationError constructor reentry
--FILE--
<?php
diff --git a/ext/uri/tests/whatwg/general/array_cast_success.phpt b/ext/uri/tests/whatwg/general/array_cast_success.phpt
new file mode 100644
index 00000000000..bb267a46fe5
--- /dev/null
+++ b/ext/uri/tests/whatwg/general/array_cast_success.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Test casting Uri\WhatWg\Url to array
+--FILE--
+<?php
+
+var_dump((array) new Uri\WhatWg\Url("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists"));
+
+?>
+--EXPECTF--
+array(%d) {
+}
diff --git a/ext/uri/tests/whatwg/general/clone_success.phpt b/ext/uri/tests/whatwg/general/clone_success.phpt
new file mode 100644
index 00000000000..47885b6fe19
--- /dev/null
+++ b/ext/uri/tests/whatwg/general/clone_success.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test cloning Uri\WhatWg\Url
+--FILE--
+<?php
+
+$url1 = Uri\WhatWg\Url::parse("https://example.com");
+$url2 = clone $url1;
+
+var_dump($url1->toAsciiString());
+
+var_dump($url2);
+var_dump($url2->toAsciiString());
+
+?>
+--EXPECTF--
+string(20) "https://example.com/"
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(20) "https://example.com/"
diff --git a/ext/uri/tests/whatwg/general/constructor_error_reinitialization.phpt b/ext/uri/tests/whatwg/general/constructor_error_reinitialization.phpt
new file mode 100644
index 00000000000..e6e0ecde312
--- /dev/null
+++ b/ext/uri/tests/whatwg/general/constructor_error_reinitialization.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test Uri\WhatWg\Url __construct() - error - reinitialization
+--FILE--
+<?php
+
+$url = new Uri\WhatWg\Url('https://example.com');
+
+try {
+ $url->__construct('ftp://example.org');
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--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
+}
+string(20) "https://example.com/"
diff --git a/ext/uri/tests/022.phpt b/ext/uri/tests/whatwg/general/extension_error.phpt
similarity index 100%
rename from ext/uri/tests/022.phpt
rename to ext/uri/tests/whatwg/general/extension_error.phpt
diff --git a/ext/uri/tests/whatwg/general/instantiate_without_constructor_error.phpt b/ext/uri/tests/whatwg/general/instantiate_without_constructor_error.phpt
new file mode 100644
index 00000000000..088c8f5fb64
--- /dev/null
+++ b/ext/uri/tests/whatwg/general/instantiate_without_constructor_error.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test Uri\WhatWg\Url instantiation without calling the constructor
+--EXTENSIONS--
+reflection
+uri
+--FILE--
+<?php
+
+try {
+ $reflectionClass = new ReflectionClass(Uri\WhatWg\Url::class);
+ $reflectionClass->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/056.phpt b/ext/uri/tests/whatwg/general/memory_management.phpt
similarity index 59%
rename from ext/uri/tests/056.phpt
rename to ext/uri/tests/whatwg/general/memory_management.phpt
index 7f348774459..915e3135067 100644
--- a/ext/uri/tests/056.phpt
+++ b/ext/uri/tests/whatwg/general/memory_management.phpt
@@ -6,11 +6,11 @@
$urls = [];
for ($i = 0; $i < 1000; $i++) {
- $urls[] = Uri\WhatWg\Url::parse("https://example.com/{$i}/");
+ $urls[] = Uri\WhatWg\Url::parse("https://example.com/$i/");
}
for ($i = 0; $i < 1000; $i++) {
- if ($urls[$i]->toAsciiString() !== "https://example.com/{$i}/") {
+ if ($urls[$i]->toAsciiString() !== "https://example.com/$i/") {
die("FAIL");
}
}
diff --git a/ext/uri/tests/whatwg/getters/basic_success_percent_encoded_components.phpt b/ext/uri/tests/whatwg/getters/basic_success_percent_encoded_components.phpt
new file mode 100644
index 00000000000..e864d5fb63c
--- /dev/null
+++ b/ext/uri/tests/whatwg/getters/basic_success_percent_encoded_components.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Test Uri\WhatWg\Url component retrieval - basic - percent-encoded components
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("http://%61pple:p%61ss@ex%61mple.com/foob%61r?%61bc=%61bc#%61bc");
+
+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());
+
+?>
+--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/host_error_forbidden_host_codepoint_opaque3.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque3.phpt
index 7b4a2fad908..a968e140527 100644
--- a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque3.phpt
+++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque3.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\Url component modification - host - forbidden host codepoint
+Test Uri\WhatWg\Url component modification - host - forbidden host code point
--FILE--
<?php
diff --git a/ext/uri/tests/whatwg/modification/host_success_ipv4_to_ipv6.phpt b/ext/uri/tests/whatwg/modification/host_success_ipv4_to_ipv6.phpt
new file mode 100644
index 00000000000..52989097f8c
--- /dev/null
+++ b/ext/uri/tests/whatwg/modification/host_success_ipv4_to_ipv6.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test Uri\WhatWg\Url component modification - host - changing IPv4 to IPv6
+--FILE--
+<?php
+
+$url1 = Uri\WhatWg\Url::parse("https://192.168.0.1");
+$url2 = $url1->withHost("[2001:db8:3333:4444:5555:6666:7777:8888]");
+
+var_dump($url1->getAsciiHost());
+
+var_dump($url2->getAsciiHost());
+var_dump($url2->toAsciiString());
+
+?>
+--EXPECT--
+string(11) "192.168.0.1"
+string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
+string(49) "https://[2001:db8:3333:4444:5555:6666:7777:8888]/"
diff --git a/ext/uri/tests/whatwg/modification/port_error_too_large.phpt b/ext/uri/tests/whatwg/modification/port_error_too_large.phpt
index 204b3caccc9..a7270fd5f41 100644
--- a/ext/uri/tests/whatwg/modification/port_error_too_large.phpt
+++ b/ext/uri/tests/whatwg/modification/port_error_too_large.phpt
@@ -8,9 +8,11 @@
try {
$url->withPort(65536);
} catch (Throwable $e) {
- echo $e::class, ": ", $e->getMessage(), PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), "\n";
+ var_dump($e->errors[0]->type === Uri\WhatWg\UrlValidationErrorType::PortOutOfRange);
}
?>
--EXPECT--
Uri\WhatWg\InvalidUrlException: The specified port is malformed (PortOutOfRange)
+bool(true)
diff --git a/ext/uri/tests/whatwg/modification/port_success_empty_host.phpt b/ext/uri/tests/whatwg/modification/port_success_empty_host.phpt
index df392ab4b74..e7a6b94207e 100644
--- a/ext/uri/tests/whatwg/modification/port_success_empty_host.phpt
+++ b/ext/uri/tests/whatwg/modification/port_success_empty_host.phpt
@@ -7,6 +7,7 @@
$url2 = $url1->withPort(433);
var_dump($url1->getPort());
+
var_dump($url2->getPort());
var_dump($url2->toAsciiString());
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 00000000000..e49d075035d
--- /dev/null
+++ b/ext/uri/tests/whatwg/modification/port_success_file_scheme.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test Uri\WhatWg\Url component modification - port - file scheme
+--FILE--
+<?php
+
+$url1 = Uri\WhatWg\Url::parse("file:///foo/bar");
+$url2 = $url1->withPort(80);
+
+var_dump($url1->getPort());
+
+var_dump($url2->getPort());
+var_dump($url2->toAsciiString());
+
+?>
+--EXPECT--
+NULL
+NULL
+string(15) "file:///foo/bar"
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 00000000000..1415261e1ed
--- /dev/null
+++ b/ext/uri/tests/whatwg/modification/username_success_encoded.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test Uri\WhatWg\Url component modification - username - percent-encoded octet byte
+--FILE--
+<?php
+
+$url1 = Uri\WhatWg\Url::parse("https://example.com");
+$url2 = $url1->withUsername("%75s%2Fr");
+
+var_dump($url1->getUsername());
+
+var_dump($url2->getUsername());
+var_dump($url2->toAsciiString());
+
+?>
+--EXPECT--
+NULL
+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 00000000000..3a6a0bf858e
--- /dev/null
+++ b/ext/uri/tests/whatwg/modification/username_success_file_scheme.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Test Uri\WhatWg\Url component modification - username - file scheme
+--FILE--
+<?php
+
+$url1 = Uri\WhatWg\Url::parse("file:///foo/bar/");
+$url2 = $url1->withUsername("user");
+
+var_dump($url1->getUsername());
+
+var_dump($url2->getUsername());
+var_dump($url2->toAsciiString());
+
+?>
+--EXPECT--
+NULL
+NULL
+string(16) "file:///foo/bar/"
diff --git a/ext/uri/tests/whatwg/parsing/basic_error_emoji_relative_reference_returns_null.phpt b/ext/uri/tests/whatwg/parsing/basic_error_emoji_relative_reference_returns_null.phpt
new file mode 100644
index 00000000000..888f289a38a
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/basic_error_emoji_relative_reference_returns_null.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - basic - parse() returns null for an emoji relative reference
+--FILE--
+<?php
+
+$errors = [];
+$url = Uri\WhatWg\Url::parse("🐘", null, $errors);
+
+var_dump($url);
+var_dump($errors);
+
+?>
+--EXPECTF--
+NULL
+array(1) {
+ [0]=>
+ object(Uri\WhatWg\UrlValidationError)#%d (%d) {
+ ["context"]=>
+ string(4) "🐘"
+ ["type"]=>
+ enum(Uri\WhatWg\UrlValidationErrorType::MissingSchemeNonRelativeUrl)
+ ["failure"]=>
+ bool(true)
+ }
+}
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 00000000000..65bb588b567
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/basic_success_constructor.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - basic - parsing all components with the constructor
+--FILE--
+<?php
+
+$url = new Uri\WhatWg\Url("https://username:password@example.com:8080/path?q=r#fragment");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--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"
+}
+string(60) "https://username:password@example.com:8080/path?q=r#fragment"
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 00000000000..4ee2a3d3b92
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/basic_success_invalid_url_unit_warnings.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - basic - invalid URL unit warnings
+--FILE--
+<?php
+
+$errors = [];
+$url = new Uri\WhatWg\Url(" https://example.org ", null, $errors);
+
+var_dump($url);
+var_dump($url->toAsciiString());
+var_dump($errors);
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.org"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+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/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 8d8be967939..b6856ec2217 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--
<?php
-var_dump(Uri\Rfc3986\Uri::parse("http://username:password@héééostname:9090/gah/../path?arg=vaéue#anchor"));
-
$url = Uri\WhatWg\Url::parse("http://username:password@héééostname:9090/gah/../path?arg=vaéue#anchor");
var_dump($url);
var_dump($url->getAsciiHost());
@@ -14,7 +12,6 @@
?>
--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_error_typed_property_reference.phpt
similarity index 61%
rename from ext/uri/tests/057.phpt
rename to ext/uri/tests/whatwg/parsing/errors_error_typed_property_reference.phpt
index 5cc4e597421..dbbf04b24bf 100644
--- a/ext/uri/tests/057.phpt
+++ b/ext/uri/tests/whatwg/parsing/errors_error_typed_property_reference.phpt
@@ -1,17 +1,17 @@
--TEST--
-Test assigning errors by reference fails
+Test Uri\WhatWg\Url parsing - errors - assignment to a typed property reference
--FILE--
<?php
class Foo {
- public string $x = '';
+ public string $x = '';
}
$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/whatwg/parsing/host_success_ipv4_fullwidth.phpt b/ext/uri/tests/whatwg/parsing/host_success_ipv4_fullwidth.phpt
new file mode 100644
index 00000000000..fa1e5042e7e
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/host_success_ipv4_fullwidth.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - host - IPv4 address with fullwidth characters
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("https://0Xc0.0250.01");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "192.168.0.1"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(20) "https://192.168.0.1/"
diff --git a/ext/uri/tests/whatwg/parsing/host_success_ipv4_octal.phpt b/ext/uri/tests/whatwg/parsing/host_success_ipv4_octal.phpt
new file mode 100644
index 00000000000..ea6e71fed6b
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/host_success_ipv4_octal.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - host - IPv4 address in octal notation
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("https://0300.0250.0000.0001");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "192.168.0.1"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(20) "https://192.168.0.1/"
diff --git a/ext/uri/tests/whatwg/parsing/host_success_ipv6_short.phpt b/ext/uri/tests/whatwg/parsing/host_success_ipv6_short.phpt
new file mode 100644
index 00000000000..5027dc09330
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/host_success_ipv6_short.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - host - short IPv6
+--FILE--
+<?php
+
+$url = new Uri\WhatWg\Url("https://[0:0::1]");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(5) "[::1]"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(14) "https://[::1]/"
diff --git a/ext/uri/tests/whatwg/parsing/host_success_multibyte.phpt b/ext/uri/tests/whatwg/parsing/host_success_multibyte.phpt
index 15613a1a0a9..53cb4174bbc 100644
--- a/ext/uri/tests/whatwg/parsing/host_success_multibyte.phpt
+++ b/ext/uri/tests/whatwg/parsing/host_success_multibyte.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\Url parsing - host - multibyte codepoint
+Test Uri\WhatWg\Url parsing - host - multibyte code point
--FILE--
<?php
diff --git a/ext/uri/tests/whatwg/parsing/host_success_multibyte_emoji.phpt b/ext/uri/tests/whatwg/parsing/host_success_multibyte_emoji.phpt
new file mode 100644
index 00000000000..2b269195fe6
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/host_success_multibyte_emoji.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - host - emoji code point
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("https://🐘.com");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+var_dump($url->toUnicodeString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(12) "xn--go8h.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(21) "https://xn--go8h.com/"
+string(17) "https://🐘.com/"
diff --git a/ext/uri/tests/whatwg/parsing/password_success_multibyte.phpt b/ext/uri/tests/whatwg/parsing/password_success_multibyte.phpt
index 96d636ea284..7098fc6b681 100644
--- a/ext/uri/tests/whatwg/parsing/password_success_multibyte.phpt
+++ b/ext/uri/tests/whatwg/parsing/password_success_multibyte.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\Url parsing - password - multibyte codepoint
+Test Uri\WhatWg\Url parsing - password - multibyte code point
--FILE--
<?php
diff --git a/ext/uri/tests/whatwg/parsing/password_success_percent_encode_set.phpt b/ext/uri/tests/whatwg/parsing/password_success_percent_encode_set.phpt
index 3a104bd6340..9c96da99572 100644
--- a/ext/uri/tests/whatwg/parsing/password_success_percent_encode_set.phpt
+++ b/ext/uri/tests/whatwg/parsing/password_success_percent_encode_set.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\Url parsing - password - codepoint in percent-encode set
+Test Uri\WhatWg\Url parsing - password - code point in percent-encode set
--FILE--
<?php
diff --git a/ext/uri/tests/whatwg/parsing/path_success_file_backslash_and_spaces.phpt b/ext/uri/tests/whatwg/parsing/path_success_file_backslash_and_spaces.phpt
new file mode 100644
index 00000000000..1c728db13e5
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/path_success_file_backslash_and_spaces.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - path - file URL with a backslash and spaces
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("file:///E:\Documents and Settings");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+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
+}
+string(37) "file:///E:/Documents%20and%20Settings"
diff --git a/ext/uri/tests/whatwg/parsing/path_success_multibyte_emoji.phpt b/ext/uri/tests/whatwg/parsing/path_success_multibyte_emoji.phpt
new file mode 100644
index 00000000000..b4e223c4bbd
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/path_success_multibyte_emoji.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - path - emoji code point
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("https://example.com/🐘");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(13) "/%F0%9F%90%98"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(32) "https://example.com/%F0%9F%90%98"
diff --git a/ext/uri/tests/whatwg/parsing/path_success_percent_encode_set2.phpt b/ext/uri/tests/whatwg/parsing/path_success_percent_encode_set2.phpt
index dd82beeff10..6690fd9e0e8 100644
--- a/ext/uri/tests/whatwg/parsing/path_success_percent_encode_set2.phpt
+++ b/ext/uri/tests/whatwg/parsing/path_success_percent_encode_set2.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\Url parsing - path - codepoint in percent-encode set
+Test Uri\WhatWg\Url parsing - path - code point in percent-encode set
--FILE--
<?php
diff --git a/ext/uri/tests/whatwg/parsing/path_success_percent_encoded.phpt b/ext/uri/tests/whatwg/parsing/path_success_percent_encoded.phpt
new file mode 100644
index 00000000000..01162c70b36
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/path_success_percent_encoded.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - path - percent-encoded byte
+--FILE--
+<?php
+
+$url = new Uri\WhatWg\Url("https://example.com/foo/bar%2Fbaz");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(14) "/foo/bar%2Fbaz"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(33) "https://example.com/foo/bar%2Fbaz"
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 386f88ae93e..f9e04572830 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--
<?php
try {
- new \Uri\WhatWg\Url('http://localhost:99999');
+ new Uri\WhatWg\Url('http://localhost:99999');
} catch (Throwable $e) {
echo $e::class, ': ', $e->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/whatwg/parsing/query_success_multibyte.phpt b/ext/uri/tests/whatwg/parsing/query_success_multibyte.phpt
new file mode 100644
index 00000000000..19e5adf2a41
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/query_success_multibyte.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - query - multibyte code points
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("http://example.com?foo=Helló Wörld");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(4) "http"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ string(27) "foo=Hell%C3%B3%20W%C3%B6rld"
+ ["fragment"]=>
+ NULL
+}
+string(47) "http://example.com/?foo=Hell%C3%B3%20W%C3%B6rld"
diff --git a/ext/uri/tests/whatwg/parsing/query_success_multibyte_emoji.phpt b/ext/uri/tests/whatwg/parsing/query_success_multibyte_emoji.phpt
new file mode 100644
index 00000000000..8815bf09330
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/query_success_multibyte_emoji.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - query - emoji code points
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("https://example.com/?🐘=🐘");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ string(25) "%F0%9F%90%98=%F0%9F%90%98"
+ ["fragment"]=>
+ NULL
+}
+string(46) "https://example.com/?%F0%9F%90%98=%F0%9F%90%98"
diff --git a/ext/uri/tests/whatwg/parsing/query_success_percent_encoded.phpt b/ext/uri/tests/whatwg/parsing/query_success_percent_encoded.phpt
new file mode 100644
index 00000000000..cf0cd280d98
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/query_success_percent_encoded.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - query - percent-encoded bytes
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("http://example.com?foo=Hell%C3%B3+W%C3%B6rld");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(4) "http"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ string(25) "foo=Hell%C3%B3+W%C3%B6rld"
+ ["fragment"]=>
+ NULL
+}
+string(45) "http://example.com/?foo=Hell%C3%B3+W%C3%B6rld"
diff --git a/ext/uri/tests/whatwg/parsing/query_success_percent_encoded_special.phpt b/ext/uri/tests/whatwg/parsing/query_success_percent_encoded_special.phpt
new file mode 100644
index 00000000000..a10f8c64492
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/query_success_percent_encoded_special.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - query - percent-encoded special characters
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("http://example.com?foobar=%27%3Cscript%3E+%2B+%40");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(4) "http"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ string(30) "foobar=%27%3Cscript%3E+%2B+%40"
+ ["fragment"]=>
+ NULL
+}
+string(50) "http://example.com/?foobar=%27%3Cscript%3E+%2B+%40"
diff --git a/ext/uri/tests/whatwg/parsing/query_success_plus.phpt b/ext/uri/tests/whatwg/parsing/query_success_plus.phpt
new file mode 100644
index 00000000000..12ea59a6b05
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/query_success_plus.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - query - plus character
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("http://example.com?foo=foo+bar");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(4) "http"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ string(11) "foo=foo+bar"
+ ["fragment"]=>
+ NULL
+}
+string(31) "http://example.com/?foo=foo+bar"
diff --git a/ext/uri/tests/whatwg/parsing/query_success_special.phpt b/ext/uri/tests/whatwg/parsing/query_success_special.phpt
new file mode 100644
index 00000000000..a49a9f61cc0
--- /dev/null
+++ b/ext/uri/tests/whatwg/parsing/query_success_special.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url parsing - query - special characters
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("http://example.com?foobar='<script> + @");
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(4) "http"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(1) "/"
+ ["query"]=>
+ string(30) "foobar=%27%3Cscript%3E%20+%20@"
+ ["fragment"]=>
+ NULL
+}
+string(50) "http://example.com/?foobar=%27%3Cscript%3E%20+%20@"
diff --git a/ext/uri/tests/whatwg/parsing/scheme_error_multibyte.phpt b/ext/uri/tests/whatwg/parsing/scheme_error_multibyte.phpt
index 0d6601e718e..517bbb41059 100644
--- a/ext/uri/tests/whatwg/parsing/scheme_error_multibyte.phpt
+++ b/ext/uri/tests/whatwg/parsing/scheme_error_multibyte.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\Url parsing - scheme - multibyte codepoint
+Test Uri\WhatWg\Url parsing - scheme - multibyte code point
--FILE--
<?php
diff --git a/ext/uri/tests/059.phpt b/ext/uri/tests/whatwg/parsing/scheme_success_extra_slashes.phpt
similarity index 50%
rename from ext/uri/tests/059.phpt
rename to ext/uri/tests/whatwg/parsing/scheme_success_extra_slashes.phpt
index 23971cd4ebe..3aa686c10d8 100644
--- a/ext/uri/tests/059.phpt
+++ b/ext/uri/tests/whatwg/parsing/scheme_success_extra_slashes.phpt
@@ -1,14 +1,16 @@
--TEST--
-Test empty ports become null
+Test Uri\WhatWg\Url parsing - scheme - extra slashes
--FILE--
<?php
-$uri = new \Uri\Rfc3986\Uri('https://example.com:');
-var_dump($uri, $uri->getPort());
+$url = Uri\WhatWg\Url::parse("HTTPS://////EXAMPLE.com");
+
+var_dump($url);
+var_dump($url->toAsciiString());
?>
--EXPECTF--
-object(Uri\Rfc3986\Uri)#%d (8) {
+object(Uri\WhatWg\Url)#%d (%d) {
["scheme"]=>
string(5) "https"
["username"]=>
@@ -20,10 +22,10 @@
["port"]=>
NULL
["path"]=>
- string(0) ""
+ string(1) "/"
["query"]=>
NULL
["fragment"]=>
NULL
}
-NULL
+string(20) "https://example.com/"
diff --git a/ext/uri/tests/whatwg/parsing/username_success_multibyte.phpt b/ext/uri/tests/whatwg/parsing/username_success_multibyte.phpt
index bf08c404d04..788dbd944bc 100644
--- a/ext/uri/tests/whatwg/parsing/username_success_multibyte.phpt
+++ b/ext/uri/tests/whatwg/parsing/username_success_multibyte.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\Url parsing - username - multibyte codepoint
+Test Uri\WhatWg\Url parsing - username - multibyte code point
--FILE--
<?php
diff --git a/ext/uri/tests/whatwg/parsing/username_success_percent_encode_set.phpt b/ext/uri/tests/whatwg/parsing/username_success_percent_encode_set.phpt
index d4aeaf61d72..31bffc09f2f 100644
--- a/ext/uri/tests/whatwg/parsing/username_success_percent_encode_set.phpt
+++ b/ext/uri/tests/whatwg/parsing/username_success_percent_encode_set.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test Uri\WhatWg\Url parsing - username - codepoint in percent-encode set
+Test Uri\WhatWg\Url parsing - username - code point in percent-encode set
--FILE--
<?php
diff --git a/ext/uri/tests/whatwg/reference_resolution/parse_success_absolute_with_base.phpt b/ext/uri/tests/whatwg/reference_resolution/parse_success_absolute_with_base.phpt
new file mode 100644
index 00000000000..0c293c6ba54
--- /dev/null
+++ b/ext/uri/tests/whatwg/reference_resolution/parse_success_absolute_with_base.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url reference resolution - parse() - absolute URL with base URL
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("https://test.com/with-base-in-vain", Uri\WhatWg\Url::parse("https://example.com/"));
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+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
+}
+string(34) "https://test.com/with-base-in-vain"
diff --git a/ext/uri/tests/whatwg/reference_resolution/parse_success_relative_with_base.phpt b/ext/uri/tests/whatwg/reference_resolution/parse_success_relative_with_base.phpt
new file mode 100644
index 00000000000..e6b24b7beab
--- /dev/null
+++ b/ext/uri/tests/whatwg/reference_resolution/parse_success_relative_with_base.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Test Uri\WhatWg\Url reference resolution - parse() - relative reference with base URL
+--FILE--
+<?php
+
+$url = Uri\WhatWg\Url::parse("/with-base", new Uri\WhatWg\Url("https://example.com"));
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+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
+}
+string(29) "https://example.com/with-base"
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 00000000000..fdcd96ef0b8
--- /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--
+<?php
+
+$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";
+}
+
+?>
+--EXPECT--
+Uri\WhatWg\InvalidUrlException: The specified URI is malformed (Ipv4TooManyParts)
diff --git a/ext/uri/tests/whatwg/reference_resolution/resolve_success_absolute_url.phpt b/ext/uri/tests/whatwg/reference_resolution/resolve_success_absolute_url.phpt
new file mode 100644
index 00000000000..042b082cda0
--- /dev/null
+++ b/ext/uri/tests/whatwg/reference_resolution/resolve_success_absolute_url.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test Uri\WhatWg\Url reference resolution - resolve() - absolute URL
+--FILE--
+<?php
+
+$url1 = new Uri\WhatWg\Url("https://example.com");
+$url2 = $url1->resolve("https://test.com/foo");
+
+var_dump($url1->toAsciiString());
+
+var_dump($url2);
+var_dump($url2->toAsciiString());
+
+?>
+--EXPECTF--
+string(20) "https://example.com/"
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(8) "test.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(4) "/foo"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(20) "https://test.com/foo"
diff --git a/ext/uri/tests/whatwg/reference_resolution/resolve_success_invalid_url_unit_warnings.phpt b/ext/uri/tests/whatwg/reference_resolution/resolve_success_invalid_url_unit_warnings.phpt
new file mode 100644
index 00000000000..49713f5e838
--- /dev/null
+++ b/ext/uri/tests/whatwg/reference_resolution/resolve_success_invalid_url_unit_warnings.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test Uri\WhatWg\Url reference resolution - resolve() - invalid URL unit warning
+--FILE--
+<?php
+
+$errors = [];
+$url1 = new Uri\WhatWg\Url("https://example.com");
+$url2 = $url1->resolve(" /foo", $errors);
+
+var_dump($url1->toAsciiString());
+
+var_dump($url2);
+var_dump($url2->toAsciiString());
+var_dump($errors);
+
+?>
+--EXPECTF--
+string(20) "https://example.com/"
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(4) "/foo"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+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/reference_resolution/resolve_success_relative_reference.phpt b/ext/uri/tests/whatwg/reference_resolution/resolve_success_relative_reference.phpt
new file mode 100644
index 00000000000..3d9fff39692
--- /dev/null
+++ b/ext/uri/tests/whatwg/reference_resolution/resolve_success_relative_reference.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test Uri\WhatWg\Url reference resolution - resolve() - relative reference
+--FILE--
+<?php
+
+$url1 = new Uri\WhatWg\Url("https://example.com");
+$url2 = $url1->resolve("/foo/");
+
+var_dump($url1->toAsciiString());
+
+var_dump($url2);
+var_dump($url2->toAsciiString());
+
+?>
+--EXPECTF--
+string(20) "https://example.com/"
+object(Uri\WhatWg\Url)#%d (%d) {
+ ["scheme"]=>
+ string(5) "https"
+ ["username"]=>
+ NULL
+ ["password"]=>
+ NULL
+ ["host"]=>
+ string(11) "example.com"
+ ["port"]=>
+ NULL
+ ["path"]=>
+ string(5) "/foo/"
+ ["query"]=>
+ NULL
+ ["fragment"]=>
+ NULL
+}
+string(24) "https://example.com/foo/"
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 00000000000..b5b22479719
--- /dev/null
+++ b/ext/uri/tests/whatwg/serialization/basic_success.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Test Uri\WhatWg\Url serialization and unserialization
+--FILE--
+<?php
+
+$url1 = new Uri\WhatWg\Url("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists");
+
+$serializedUrl1 = serialize($url1);
+var_dump($serializedUrl1);
+
+$url2 = unserialize($serializedUrl1);
+var_dump($url2);
+var_dump($url2->toAsciiString());
+
+?>
+--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"
+}
+string(99) "https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists"
diff --git a/ext/uri/tests/whatwg/serialization/json_encode_success.phpt b/ext/uri/tests/whatwg/serialization/json_encode_success.phpt
new file mode 100644
index 00000000000..71cd64fe48a
--- /dev/null
+++ b/ext/uri/tests/whatwg/serialization/json_encode_success.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test Uri\WhatWg\Url json_encode() - success
+--FILE--
+<?php
+
+var_dump(json_encode(new Uri\WhatWg\Url("https://username:password@www.example.com:8080/pathname1/pathname2/pathname3?query=true#hash-exists")));
+
+?>
+--EXPECT--
+string(2) "{}"
diff --git a/ext/uri/tests/whatwg/serialization/unserialize_error_invalid_data.phpt b/ext/uri/tests/whatwg/serialization/unserialize_error_invalid_data.phpt
new file mode 100644
index 00000000000..f46e8799c11
--- /dev/null
+++ b/ext/uri/tests/whatwg/serialization/unserialize_error_invalid_data.phpt
@@ -0,0 +1,70 @@
+--TEST--
+Test Uri\WhatWg\Url unserialize() - error - invalid data
+--FILE--
+<?php
+
+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";
+}
+
+?>
+--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
diff --git a/ext/uri/tests/whatwg/serialization/unserialize_error_legacy_format.phpt b/ext/uri/tests/whatwg/serialization/unserialize_error_legacy_format.phpt
new file mode 100644
index 00000000000..6de1d9d1756
--- /dev/null
+++ b/ext/uri/tests/whatwg/serialization/unserialize_error_legacy_format.phpt
@@ -0,0 +1,12 @@
+--TEST--
+GH-22046: Uri\WhatWg\Url cannot be unserialized with the unsupported C format
+--FILE--
+<?php
+
+unserialize('C:14:"Uri\WhatWg\Url":0:{}');
+
+?>
+--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
diff --git a/ext/uri/tests/whatwg/serialization/unserialize_error_reinitialization.phpt b/ext/uri/tests/whatwg/serialization/unserialize_error_reinitialization.phpt
new file mode 100644
index 00000000000..4c3826e9a1b
--- /dev/null
+++ b/ext/uri/tests/whatwg/serialization/unserialize_error_reinitialization.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Test Uri\WhatWg\Url __unserialize() - error - reinitialization
+--FILE--
+<?php
+
+$url = new Uri\WhatWg\Url('https://example.com');
+
+try {
+ $url->__unserialize([['uri' => 'ftp://example.org'], []]);
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+var_dump($url);
+var_dump($url->toAsciiString());
+
+?>
+--EXPECTF--
+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
+}
+string(20) "https://example.com/"
diff --git a/ext/uri/tests/101.phpt b/ext/uri/tests/zend/internal_api_error_whatwg_invalid_url.phpt
similarity index 67%
rename from ext/uri/tests/101.phpt
rename to ext/uri/tests/zend/internal_api_error_whatwg_invalid_url.phpt
index b00eeac8f80..659eabde89a 100644
--- a/ext/uri/tests/101.phpt
+++ b/ext/uri/tests/zend/internal_api_error_whatwg_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--
<?php
try {
- var_dump(zend_test_uri_parser('invalid uri', "Uri\\WhatWg\\Url"));
+ var_dump(zend_test_uri_parser('invalid uri', "Uri\\WhatWg\\Url"));
} catch (Throwable $e) {
- echo $e::class, ': ', $e->getMessage(), PHP_EOL;
- var_dump($e->errors);
+ echo $e::class, ': ', $e->getMessage(), "\n";
+ var_dump($e->errors);
}
?>
diff --git a/ext/uri/tests/100.phpt b/ext/uri/tests/zend/internal_api_success_parse_url_parsing.phpt
similarity index 100%
rename from ext/uri/tests/100.phpt
rename to ext/uri/tests/zend/internal_api_success_parse_url_parsing.phpt
diff --git a/ext/uri/tests/102.phpt b/ext/uri/tests/zend/internal_api_success_rfc3986_large_port.phpt
similarity index 95%
rename from ext/uri/tests/102.phpt
rename to ext/uri/tests/zend/internal_api_success_rfc3986_large_port.phpt
index 69d6b21babb..7eec9984dc7 100644
--- a/ext/uri/tests/102.phpt
+++ b/ext/uri/tests/zend/internal_api_success_rfc3986_large_port.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test the handling large ports for the uri struct
+Test the handling of large ports for the uri struct
--EXTENSIONS--
zend_test
--FILE--