diff --git a/ext/uri/tests/rfc3986/modification/fragment_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/fragment_error_reserved.phpt new file mode 100644 index 0000000000000..4b3c3dd00a99e --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/fragment_error_reserved.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - fragment - reserved characters +--EXTENSIONS-- +uri +--FILE-- +withFragment("#fragment"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified fragment is malformed diff --git a/ext/uri/tests/rfc3986/modification/fragment_error_unicode.phpt b/ext/uri/tests/rfc3986/modification/fragment_error_unicode.phpt new file mode 100644 index 0000000000000..bbb1e2ffe8727 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/fragment_error_unicode.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - fragment - unicode characters +--EXTENSIONS-- +uri +--FILE-- +withFragment("ő"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified fragment is malformed diff --git a/ext/uri/tests/rfc3986/modification/fragment_success_empty.phpt b/ext/uri/tests/rfc3986/modification/fragment_success_empty.phpt new file mode 100644 index 0000000000000..f0a05d5bb5bb0 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/fragment_success_empty.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - fragment - empty string +--EXTENSIONS-- +uri +--FILE-- +withFragment(""); + +var_dump($uri1->getRawFragment()); +var_dump($uri2->getRawFragment()); +var_dump($uri2->toRawString()); +var_dump($uri2->getFragment()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +string(0) "" +string(20) "https://example.com#" +string(0) "" +string(20) "https://example.com#" diff --git a/ext/uri/tests/rfc3986/modification/fragment_success_encoded.phpt b/ext/uri/tests/rfc3986/modification/fragment_success_encoded.phpt new file mode 100644 index 0000000000000..4b6ccb2f7aa31 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/fragment_success_encoded.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - fragment - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withFragment("foo%3dbar"); // foo=bar + +var_dump($uri1->getRawFragment()); +var_dump($uri2->getRawFragment()); +var_dump($uri2->toRawString()); +var_dump($uri2->getFragment()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +string(9) "foo%3dbar" +string(29) "https://example.com#foo%3dbar" +string(9) "foo%3Dbar" +string(29) "https://example.com#foo%3Dbar" diff --git a/ext/uri/tests/rfc3986/modification/fragment_success_existing.phpt b/ext/uri/tests/rfc3986/modification/fragment_success_existing.phpt new file mode 100644 index 0000000000000..fe534e8465041 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/fragment_success_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - fragment - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withFragment("bar"); + +var_dump($uri1->getRawFragment()); +var_dump($uri2->getRawFragment()); +var_dump($uri2->toRawString()); +var_dump($uri2->getFragment()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(3) "foo" +string(3) "bar" +string(23) "https://example.com#bar" +string(3) "bar" +string(23) "https://example.com#bar" diff --git a/ext/uri/tests/rfc3986/modification/fragment_success_unset_existing.phpt b/ext/uri/tests/rfc3986/modification/fragment_success_unset_existing.phpt new file mode 100644 index 0000000000000..7532c35e0fe76 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/fragment_success_unset_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - fragment - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withFragment(null); + +var_dump($uri1->getRawFragment()); +var_dump($uri2->getRawFragment()); +var_dump($uri2->toRawString()); +var_dump($uri2->getFragment()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(3) "foo" +NULL +string(19) "https://example.com" +NULL +string(19) "https://example.com" diff --git a/ext/uri/tests/rfc3986/modification/fragment_success_unset_non_existent.phpt b/ext/uri/tests/rfc3986/modification/fragment_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..1c6fa898dde36 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/fragment_success_unset_non_existent.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - fragment - unsetting not-existent +--EXTENSIONS-- +uri +--FILE-- +withFragment(null); + +var_dump($uri1->getRawFragment()); +var_dump($uri2->getRawFragment()); +var_dump($uri2->toRawString()); +var_dump($uri2->getFragment()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +NULL +string(19) "https://example.com" +NULL +string(19) "https://example.com" diff --git a/ext/uri/tests/rfc3986/modification/host_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/host_error_reserved.phpt new file mode 100644 index 0000000000000..81d60bc2e400b --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_error_reserved.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - reserved characters +--EXTENSIONS-- +uri +--FILE-- +withHost("ex#mple.com"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified host is malformed diff --git a/ext/uri/tests/rfc3986/modification/host_success_empty.phpt b/ext/uri/tests/rfc3986/modification/host_success_empty.phpt new file mode 100644 index 0000000000000..b337674841c6b --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_empty.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - empty string +--EXTENSIONS-- +uri +--FILE-- +withHost(""); + +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(0) "" +string(8) "https://" +string(0) "" +string(8) "https://" diff --git a/ext/uri/tests/rfc3986/modification/host_success_encoded.phpt b/ext/uri/tests/rfc3986/modification/host_success_encoded.phpt new file mode 100644 index 0000000000000..3db01109e1dbb --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_encoded.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withHost("t%65st.com"); // test.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(10) "t%65st.com" +string(18) "https://t%65st.com" +string(8) "test.com" +string(16) "https://test.com" diff --git a/ext/uri/tests/rfc3986/modification/host_success_existing.phpt b/ext/uri/tests/rfc3986/modification/host_success_existing.phpt new file mode 100644 index 0000000000000..140eb60ecad58 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withHost("test.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(8) "test.com" +string(16) "https://test.com" +string(8) "test.com" +string(16) "https://test.com" diff --git a/ext/uri/tests/rfc3986/modification/host_success_ip_future.phpt b/ext/uri/tests/rfc3986/modification/host_success_ip_future.phpt new file mode 100644 index 0000000000000..004210000cf43 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_ip_future.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - IP future address +--EXTENSIONS-- +uri +--FILE-- +withHost("[vF.addr]"); + +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(9) "[vF.addr]" +string(17) "https://[vF.addr]" +string(9) "[vf.addr]" +string(17) "https://[vf.addr]" diff --git a/ext/uri/tests/rfc3986/modification/host_success_ipv4.phpt b/ext/uri/tests/rfc3986/modification/host_success_ipv4.phpt new file mode 100644 index 0000000000000..850a32281aba6 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_ipv4.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - IPv4 address +--EXTENSIONS-- +uri +--FILE-- +withHost("192.168.0.1"); + +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(11) "192.168.0.1" +string(19) "https://192.168.0.1" +string(11) "192.168.0.1" +string(19) "https://192.168.0.1" diff --git a/ext/uri/tests/rfc3986/modification/host_success_ipv6.phpt b/ext/uri/tests/rfc3986/modification/host_success_ipv6.phpt new file mode 100644 index 0000000000000..4750888401599 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_ipv6.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - IPv6 address +--EXTENSIONS-- +uri +--FILE-- +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) "example.com" +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_new.phpt b/ext/uri/tests/rfc3986/modification/host_success_new.phpt new file mode 100644 index 0000000000000..326616140078f --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_new.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - adding a new one +--EXTENSIONS-- +uri +--FILE-- +withHost("example.com"); + +var_dump($uri1->getRawHost()); +var_dump($uri2->getRawHost()); +var_dump($uri2->toRawString()); +var_dump($uri2->getHost()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +string(11) "example.com" +string(21) "//example.com/foo/bar" +string(11) "example.com" +string(21) "//example.com/foo/bar" diff --git a/ext/uri/tests/rfc3986/modification/host_success_unset_existing.phpt b/ext/uri/tests/rfc3986/modification/host_success_unset_existing.phpt new file mode 100644 index 0000000000000..521b6397ec450 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_unset_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withHost(null); + +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" +NULL +string(7) "https:/" +NULL +string(7) "https:/" diff --git a/ext/uri/tests/rfc3986/modification/host_success_unset_non_existent.phpt b/ext/uri/tests/rfc3986/modification/host_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..b1793a31413ab --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/host_success_unset_non_existent.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - unsetting non-existent +--EXTENSIONS-- +uri +--FILE-- +withHost(null); + +var_dump($uri1->getRawHost()); +var_dump($uri2->getRawHost()); +var_dump($uri2->toRawString()); +var_dump($uri2->getHost()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +NULL +string(8) "/foo/bar" +NULL +string(8) "/foo/bar" diff --git a/ext/uri/tests/rfc3986/modification/path_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/path_error_reserved.phpt new file mode 100644 index 0000000000000..2da84e2689b3b --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/path_error_reserved.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - path - reserved characters +--EXTENSIONS-- +uri +--FILE-- +withPath("/[foo]"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified path is malformed diff --git a/ext/uri/tests/rfc3986/modification/path_error_unicode.phpt b/ext/uri/tests/rfc3986/modification/path_error_unicode.phpt new file mode 100644 index 0000000000000..9335132dad56c --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/path_error_unicode.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - path - unicode characters +--EXTENSIONS-- +uri +--FILE-- +withPath("/ő"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified path is malformed diff --git a/ext/uri/tests/rfc3986/modification/path_error_without_leading_slash.phpt b/ext/uri/tests/rfc3986/modification/path_error_without_leading_slash.phpt new file mode 100644 index 0000000000000..476e4ec873c28 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/path_error_without_leading_slash.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - path - without leading slash +--EXTENSIONS-- +uri +--FILE-- +withPath("foo"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified path is malformed diff --git a/ext/uri/tests/rfc3986/modification/path_success_email.phpt b/ext/uri/tests/rfc3986/modification/path_success_email.phpt new file mode 100644 index 0000000000000..58f5ab4baa6d5 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/path_success_email.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - path - using an email format +--EXTENSIONS-- +uri +--FILE-- +withPath("john.doe@example.com"); + +var_dump($uri1->getRawPath()); +var_dump($uri2->getRawPath()); +var_dump($uri2->toRawString()); +var_dump($uri2->getPath()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(0) "" +string(20) "john.doe@example.com" +string(20) "john.doe@example.com" +string(20) "john.doe@example.com" +string(20) "john.doe@example.com" diff --git a/ext/uri/tests/rfc3986/modification/path_success_empty.phpt b/ext/uri/tests/rfc3986/modification/path_success_empty.phpt new file mode 100644 index 0000000000000..a67eeae44eed4 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/path_success_empty.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - path - empty string +--EXTENSIONS-- +uri +--FILE-- +withPath(""); + +var_dump($uri1->getRawPath()); +var_dump($uri2->getRawPath()); +var_dump($uri2->toRawString()); +var_dump($uri2->getPath()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(0) "" +string(0) "" +string(19) "https://example.com" +string(0) "" +string(19) "https://example.com" diff --git a/ext/uri/tests/rfc3986/modification/path_success_encoded.phpt b/ext/uri/tests/rfc3986/modification/path_success_encoded.phpt new file mode 100644 index 0000000000000..7f94ee8fd7d27 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/path_success_encoded.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - path - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withPath("/foo%2Fbar"); // /foo/bar + +var_dump($uri1->getRawPath()); +var_dump($uri2->getRawPath()); +var_dump($uri2->toRawString()); +var_dump($uri2->getPath()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(0) "" +string(10) "/foo%2Fbar" +string(29) "https://example.com/foo%2Fbar" +string(10) "/foo%2Fbar" +string(29) "https://example.com/foo%2Fbar" diff --git a/ext/uri/tests/rfc3986/modification/path_success_existing.phpt b/ext/uri/tests/rfc3986/modification/path_success_existing.phpt new file mode 100644 index 0000000000000..6dafbc0a3ff80 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/path_success_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - path - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withPath("/baz"); + +var_dump($uri1->getRawPath()); +var_dump($uri2->getRawPath()); +var_dump($uri2->toRawString()); +var_dump($uri2->getPath()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(8) "/foo/bar" +string(4) "/baz" +string(23) "https://example.com/baz" +string(4) "/baz" +string(23) "https://example.com/baz" diff --git a/ext/uri/tests/rfc3986/modification/port_error_negative.phpt b/ext/uri/tests/rfc3986/modification/port_error_negative.phpt new file mode 100644 index 0000000000000..598475b1e1845 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/port_error_negative.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - host - too small number +--EXTENSIONS-- +uri +--FILE-- +withPort(-1); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified port is malformed diff --git a/ext/uri/tests/rfc3986/modification/port_success_existing.phpt b/ext/uri/tests/rfc3986/modification/port_success_existing.phpt new file mode 100644 index 0000000000000..8451f1bcf4690 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/port_success_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - port - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withPort(443); + +var_dump($uri1->getPort()); +var_dump($uri2->getPort()); +var_dump($uri2->toRawString()); + +?> +--EXPECT-- +int(80) +int(443) +string(23) "https://example.com:443" diff --git a/ext/uri/tests/rfc3986/modification/port_success_new.phpt b/ext/uri/tests/rfc3986/modification/port_success_new.phpt new file mode 100644 index 0000000000000..36ccea04a9497 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/port_success_new.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - port - adding a new one +--EXTENSIONS-- +uri +--FILE-- +withPort(443); + +var_dump($uri1->getPort()); +var_dump($uri2->getPort()); +var_dump($uri2->toRawString()); + +?> +--EXPECT-- +NULL +int(443) +string(23) "https://example.com:443" diff --git a/ext/uri/tests/rfc3986/modification/port_success_unset_existing.phpt b/ext/uri/tests/rfc3986/modification/port_success_unset_existing.phpt new file mode 100644 index 0000000000000..574af3f6e3ee7 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/port_success_unset_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - port - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withPort(null); + +var_dump($uri1->getPort()); +var_dump($uri2->getPort()); +var_dump($uri2->toRawString()); + +?> +--EXPECT-- +int(80) +NULL +string(19) "https://example.com" diff --git a/ext/uri/tests/rfc3986/modification/port_success_unset_non_existent.phpt b/ext/uri/tests/rfc3986/modification/port_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..a3fbdc5e87422 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/port_success_unset_non_existent.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - port - unsetting non-existent +--EXTENSIONS-- +uri +--FILE-- +withPort(null); + +var_dump($uri2->getPort()); +var_dump($uri2->getPort()); +var_dump($uri2->toRawString()); + +?> +--EXPECT-- +NULL +NULL +string(17) "ftp://example.com" diff --git a/ext/uri/tests/rfc3986/modification/query_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/query_error_reserved.phpt new file mode 100644 index 0000000000000..f09e867a0210f --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_error_reserved.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - query - reserved characters +--EXTENSIONS-- +uri +--FILE-- +withQuery("#foo"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified query is malformed diff --git a/ext/uri/tests/rfc3986/modification/query_error_unicode.phpt b/ext/uri/tests/rfc3986/modification/query_error_unicode.phpt new file mode 100644 index 0000000000000..c8f5100597429 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_error_unicode.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - query - unicode characters +--EXTENSIONS-- +uri +--FILE-- +withQuery("ő"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified query is malformed diff --git a/ext/uri/tests/rfc3986/modification/query_success_context_senstive_reserved.phpt b/ext/uri/tests/rfc3986/modification/query_success_context_senstive_reserved.phpt new file mode 100644 index 0000000000000..d40a7f7e09efb --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_success_context_senstive_reserved.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - query - context-sensitive reserved character +--EXTENSIONS-- +uri +--FILE-- +withQuery("?foo=bar"); + +var_dump($uri1->getRawQuery()); +var_dump($uri2->getRawQuery()); +var_dump($uri2->toRawString()); +var_dump($uri2->getQuery()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +string(8) "?foo=bar" +string(28) "https://example.com??foo=bar" +string(8) "?foo=bar" +string(28) "https://example.com??foo=bar" diff --git a/ext/uri/tests/rfc3986/modification/query_success_empty.phpt b/ext/uri/tests/rfc3986/modification/query_success_empty.phpt new file mode 100644 index 0000000000000..e668b44df9b3a --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_success_empty.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - query - empty string +--EXTENSIONS-- +uri +--FILE-- +withQuery(""); + +var_dump($uri1->getRawQuery()); +var_dump($uri2->getRawQuery()); +var_dump($uri2->toRawString()); +var_dump($uri2->getQuery()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +string(0) "" +string(20) "https://example.com?" +string(0) "" +string(20) "https://example.com?" diff --git a/ext/uri/tests/rfc3986/modification/query_success_encoded.phpt b/ext/uri/tests/rfc3986/modification/query_success_encoded.phpt new file mode 100644 index 0000000000000..7fd9707220d88 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_success_encoded.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - query - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withQuery("foo%3dbar"); // foo=bar + +var_dump($uri1->getRawQuery()); +var_dump($uri2->getRawQuery()); +var_dump($uri2->toRawString()); +var_dump($uri2->getQuery()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +string(9) "foo%3dbar" +string(29) "https://example.com?foo%3dbar" +string(9) "foo%3Dbar" +string(29) "https://example.com?foo%3Dbar" diff --git a/ext/uri/tests/rfc3986/modification/query_success_existing.phpt b/ext/uri/tests/rfc3986/modification/query_success_existing.phpt new file mode 100644 index 0000000000000..b5af7feee2507 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_success_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - query - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withQuery("foo=bar&baz=qux"); + +var_dump($uri1->getRawQuery()); +var_dump($uri2->getRawQuery()); +var_dump($uri2->toRawString()); +var_dump($uri2->getQuery()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(7) "foo=bar" +string(15) "foo=bar&baz=qux" +string(35) "https://example.com?foo=bar&baz=qux" +string(15) "foo=bar&baz=qux" +string(35) "https://example.com?foo=bar&baz=qux" diff --git a/ext/uri/tests/rfc3986/modification/query_success_unset_existing.phpt b/ext/uri/tests/rfc3986/modification/query_success_unset_existing.phpt new file mode 100644 index 0000000000000..89d130eedc27b --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_success_unset_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - query - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withQuery(null); + +var_dump($uri1->getRawQuery()); +var_dump($uri2->getRawQuery()); +var_dump($uri2->toRawString()); +var_dump($uri2->getQuery()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(7) "foo=bar" +NULL +string(19) "https://example.com" +NULL +string(19) "https://example.com" diff --git a/ext/uri/tests/rfc3986/modification/query_success_unset_non_existent.phpt b/ext/uri/tests/rfc3986/modification/query_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..d9dfcd2083100 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_success_unset_non_existent.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - query - unsetting not-existent +--EXTENSIONS-- +uri +--FILE-- +withQuery(null); + +var_dump($uri1->getRawQuery()); +var_dump($uri2->getRawQuery()); +var_dump($uri2->toRawString()); +var_dump($uri2->getQuery()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +NULL +string(19) "https://example.com" +NULL +string(19) "https://example.com" diff --git a/ext/uri/tests/rfc3986/modification/roundtrip_special_case1.phpt b/ext/uri/tests/rfc3986/modification/roundtrip_special_case1.phpt new file mode 100644 index 0000000000000..4349764d4dd1f --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/roundtrip_special_case1.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification when roundtripping is not guaranteed - case 1 +--EXTENSIONS-- +uri +--FILE-- +withHost("host"); +$uri2 = $uri2->withHost(null); + +var_dump($uri1->getRawPath()); +var_dump($uri2->getRawPath()); +var_dump($uri2->toRawString()); +var_dump($uri2->getPath()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(5) "path1" +string(6) "/path1" +string(6) "/path1" +string(6) "/path1" +string(6) "/path1" diff --git a/ext/uri/tests/rfc3986/modification/roundtrip_special_case2.phpt b/ext/uri/tests/rfc3986/modification/roundtrip_special_case2.phpt new file mode 100644 index 0000000000000..624abf2fc49ca --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/roundtrip_special_case2.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification when roundtripping is not guaranteed - case 2 +--EXTENSIONS-- +uri +--FILE-- +withScheme(null); +$uri2 = $uri2->withScheme("scheme"); + +var_dump($uri1->toRawString()); +var_dump($uri2->toRawString()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(13) "scheme:path1:" +string(15) "scheme:./path1:" +string(13) "scheme:path1:" diff --git a/ext/uri/tests/rfc3986/modification/roundtrip_special_case3.phpt b/ext/uri/tests/rfc3986/modification/roundtrip_special_case3.phpt new file mode 100644 index 0000000000000..7d6e1e4d0489b --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/roundtrip_special_case3.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification when roundtripping is not guaranteed - case 3 +--EXTENSIONS-- +uri +--FILE-- +withHost(null); +$uri2 = $uri2->withHost("host"); + +var_dump($uri1->toRawString()); +var_dump($uri2->toRawString()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(12) "//host//path" +string(14) "//host/.//path" +string(12) "//host//path" diff --git a/ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt b/ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt new file mode 100644 index 0000000000000..477be1d2331c6 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/scheme_error_empty.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - scheme - empty string +--EXTENSIONS-- +uri +--FILE-- +withScheme(""); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified scheme is malformed diff --git a/ext/uri/tests/rfc3986/modification/scheme_error_encoded.phpt b/ext/uri/tests/rfc3986/modification/scheme_error_encoded.phpt new file mode 100644 index 0000000000000..683f46cc42a83 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/scheme_error_encoded.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - scheme - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withScheme("http%73"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified scheme is malformed diff --git a/ext/uri/tests/rfc3986/modification/scheme_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/scheme_error_reserved.phpt new file mode 100644 index 0000000000000..dd3bcc02f83e3 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/scheme_error_reserved.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - scheme - reserved characters +--EXTENSIONS-- +uri +--FILE-- +withScheme("https:"); +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified scheme is malformed diff --git a/ext/uri/tests/rfc3986/modification/scheme_success_basic.phpt b/ext/uri/tests/rfc3986/modification/scheme_success_basic.phpt new file mode 100644 index 0000000000000..39e924e778f67 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/scheme_success_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - scheme - basic case +--EXTENSIONS-- +uri +--FILE-- +withScheme("http"); + +var_dump($uri1->getRawScheme()); +var_dump($uri2->getRawScheme()); +var_dump($uri2->toRawString()); +var_dump($uri2->getScheme()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(5) "https" +string(4) "http" +string(18) "http://example.com" +string(4) "http" +string(18) "http://example.com" diff --git a/ext/uri/tests/rfc3986/modification/scheme_success_unset_existing.phpt b/ext/uri/tests/rfc3986/modification/scheme_success_unset_existing.phpt new file mode 100644 index 0000000000000..67d447e8810e4 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/scheme_success_unset_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - scheme - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withScheme(null); + +var_dump($uri1->getRawScheme()); +var_dump($uri2->getRawScheme()); +var_dump($uri2->toRawString()); +var_dump($uri2->getScheme()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(5) "https" +NULL +string(13) "//example.com" +NULL +string(13) "//example.com" diff --git a/ext/uri/tests/rfc3986/modification/scheme_success_unset_non_existent.phpt b/ext/uri/tests/rfc3986/modification/scheme_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..4aa9b2d9dd2c6 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/scheme_success_unset_non_existent.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - scheme - unsetting non-existent +--EXTENSIONS-- +uri +--FILE-- +withScheme(null); + +var_dump($uri1->getRawScheme()); +var_dump($uri2->getRawScheme()); +var_dump($uri2->toRawString()); +var_dump($uri2->getScheme()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +NULL +string(8) "/foo/bar" +NULL +string(8) "/foo/bar" diff --git a/ext/uri/tests/rfc3986/modification/userinfo_error_reserved.phpt b/ext/uri/tests/rfc3986/modification/userinfo_error_reserved.phpt new file mode 100644 index 0000000000000..a5f820b0d59f1 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/userinfo_error_reserved.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - userinfo - reserved characters +--EXTENSIONS-- +uri +--FILE-- +withUserInfo("us/r:password"); // us/r:password +} catch (Uri\InvalidUriException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified userinfo is malformed diff --git a/ext/uri/tests/rfc3986/modification/userinfo_success_empty.phpt b/ext/uri/tests/rfc3986/modification/userinfo_success_empty.phpt new file mode 100644 index 0000000000000..ab753e6de507a --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/userinfo_success_empty.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - userinfo - empty string +--EXTENSIONS-- +uri +--FILE-- +withUserInfo(""); + +var_dump($uri1->getRawUserInfo()); +var_dump($uri2->getRawUserInfo()); +var_dump($uri2->getUserInfo()); + +?> +--EXPECT-- +NULL +string(0) "" +string(0) "" diff --git a/ext/uri/tests/rfc3986/modification/userinfo_success_encoded.phpt b/ext/uri/tests/rfc3986/modification/userinfo_success_encoded.phpt new file mode 100644 index 0000000000000..a4b7409d67063 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/userinfo_success_encoded.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - userinfo - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withUserInfo("%75s%2Fr:password"); // us/r:password + +var_dump($uri1->getRawUserInfo()); +var_dump($uri2->getRawUserInfo()); +var_dump($uri2->toRawString()); +var_dump($uri2->getUserInfo()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +string(17) "%75s%2Fr:password" +string(37) "https://%75s%2Fr:password@example.com" +string(15) "us%2Fr:password" +string(35) "https://us%2Fr:password@example.com" diff --git a/ext/uri/tests/rfc3986/modification/userinfo_success_existing.phpt b/ext/uri/tests/rfc3986/modification/userinfo_success_existing.phpt new file mode 100644 index 0000000000000..a13e091075cb6 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/userinfo_success_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - userinfo - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withUserInfo("user:password"); + +var_dump($uri1->getRawUserInfo()); +var_dump($uri2->getRawUserInfo()); +var_dump($uri2->toRawString()); +var_dump($uri2->getUserInfo()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(5) ":pass" +string(13) "user:password" +string(33) "https://user:password@example.com" +string(13) "user:password" +string(33) "https://user:password@example.com" diff --git a/ext/uri/tests/rfc3986/modification/userinfo_success_new.phpt b/ext/uri/tests/rfc3986/modification/userinfo_success_new.phpt new file mode 100644 index 0000000000000..dc49c10d7526a --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/userinfo_success_new.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - userinfo - adding a new one +--EXTENSIONS-- +uri +--FILE-- +withUserInfo("user:password"); + +var_dump($uri1->getRawUserInfo()); +var_dump($uri2->getRawUserInfo()); +var_dump($uri2->toRawString()); +var_dump($uri2->getUserInfo()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +string(13) "user:password" +string(33) "https://user:password@example.com" +string(13) "user:password" +string(33) "https://user:password@example.com" diff --git a/ext/uri/tests/rfc3986/modification/userinfo_success_unset_existing.phpt b/ext/uri/tests/rfc3986/modification/userinfo_success_unset_existing.phpt new file mode 100644 index 0000000000000..0f4e7219cbd35 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/userinfo_success_unset_existing.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - userinfo - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withUserInfo(null); + +var_dump($uri1->getRawUserInfo()); +var_dump($uri2->getRawUserInfo()); +var_dump($uri2->toRawString()); +var_dump($uri2->getUserInfo()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +string(13) "user:password" +NULL +string(19) "https://example.com" +NULL +string(19) "https://example.com" diff --git a/ext/uri/tests/rfc3986/modification/userinfo_success_unset_non_existent.phpt b/ext/uri/tests/rfc3986/modification/userinfo_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..9aa2a5999ac43 --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/userinfo_success_unset_non_existent.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\Rfc3986\Uri component modification - userinfo - unsetting non-existent +--EXTENSIONS-- +uri +--FILE-- +withUserInfo(null); + +var_dump($uri1->getRawUserInfo()); +var_dump($uri2->getRawUserInfo()); +var_dump($uri2->toRawString()); +var_dump($uri2->getUserInfo()); +var_dump($uri2->toString()); + +?> +--EXPECT-- +NULL +NULL +string(8) "/foo/bar" +NULL +string(8) "/foo/bar" diff --git a/ext/uri/tests/whatwg/modification/fragment_success_auto_encode.phpt b/ext/uri/tests/whatwg/modification/fragment_success_auto_encode.phpt new file mode 100644 index 0000000000000..ac74b8668cd23 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_auto_encode.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - characters from the percent encode set +--EXTENSIONS-- +uri +--FILE-- +withFragment("<>"); + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(6) "%3C%3E" +string(27) "https://example.com/#%3C%3E" diff --git a/ext/uri/tests/whatwg/modification/fragment_success_empty.phpt b/ext/uri/tests/whatwg/modification/fragment_success_empty.phpt new file mode 100644 index 0000000000000..5b3aa9426232c --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_empty.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - empty string +--EXTENSIONS-- +uri +--FILE-- +withFragment(""); + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/fragment_success_encoded.phpt b/ext/uri/tests/whatwg/modification/fragment_success_encoded.phpt new file mode 100644 index 0000000000000..03aa593805462 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withFragment("foo%3dbar"); // foo=bar + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(9) "foo%3dbar" +string(30) "https://example.com/#foo%3dbar" diff --git a/ext/uri/tests/whatwg/modification/fragment_success_existing.phpt b/ext/uri/tests/whatwg/modification/fragment_success_existing.phpt new file mode 100644 index 0000000000000..0a7d253434d41 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withFragment("bar"); + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(3) "foo" +string(3) "bar" +string(24) "https://example.com/#bar" diff --git a/ext/uri/tests/whatwg/modification/fragment_success_unicode.phpt b/ext/uri/tests/whatwg/modification/fragment_success_unicode.phpt new file mode 100644 index 0000000000000..c609b5df042de --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_unicode.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - unicode characters +--EXTENSIONS-- +uri +--FILE-- +withFragment("ő"); + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(6) "%C5%91" +string(27) "https://example.com/#%C5%91" diff --git a/ext/uri/tests/whatwg/modification/fragment_success_unset_existing.phpt b/ext/uri/tests/whatwg/modification/fragment_success_unset_existing.phpt new file mode 100644 index 0000000000000..585707e497e5c --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_unset_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withFragment(null); + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(3) "foo" +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/fragment_success_unset_non_existent.phpt b/ext/uri/tests/whatwg/modification/fragment_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..21e295db23ec2 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_unset_non_existent.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - unsetting not-existent +--EXTENSIONS-- +uri +--FILE-- +withFragment(null); + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/fragment_success_with_leading_hashmark.phpt b/ext/uri/tests/whatwg/modification/fragment_success_with_leading_hashmark.phpt new file mode 100644 index 0000000000000..4523388223b68 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_with_leading_hashmark.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - with leading hashmark +--EXTENSIONS-- +uri +--FILE-- +withFragment("#fragment"); + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(8) "fragment" +string(29) "https://example.com/#fragment" diff --git a/ext/uri/tests/whatwg/modification/host_error_empty.phpt b/ext/uri/tests/whatwg/modification/host_error_empty.phpt new file mode 100644 index 0000000000000..f9f4739578604 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_empty.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - empty string +--EXTENSIONS-- +uri +--FILE-- +withHost(""); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified host is malformed (HostMissing) diff --git a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque1.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque1.phpt new file mode 100644 index 0000000000000..8aebc5f7057df --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque1.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - forbidden host code point +--EXTENSIONS-- +uri +--FILE-- +withHost("ex@mple.com"); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified host is malformed (HostInvalidCodePoint) diff --git a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque2.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque2.phpt new file mode 100644 index 0000000000000..6d8b0c8b6565e --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque2.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - forbidden host code point +--EXTENSIONS-- +uri +--FILE-- +withHost("ex#mple.com"); + +var_dump($url1->getAsciiHost()); +var_dump($url2->getAsciiHost()); + +?> +--EXPECT-- +string(11) "example.com" +string(2) "ex" 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 new file mode 100644 index 0000000000000..940d4c9db73a1 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque3.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - forbidden host codepoint +--EXTENSIONS-- +uri +--FILE-- +withHost("ex:mple.com"); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified host is malformed diff --git a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special1.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special1.phpt new file mode 100644 index 0000000000000..a27c26381b4e5 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special1.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - forbidden domain code point +--EXTENSIONS-- +uri +--FILE-- +withHost("ex@mple.com"); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified host is malformed (DomainInvalidCodePoint) diff --git a/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special2.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special2.phpt new file mode 100644 index 0000000000000..a0626d99c51a6 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special2.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - forbidden domain code point +--EXTENSIONS-- +uri +--FILE-- +withHost("ex:mple.com"); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified host is malformed diff --git a/ext/uri/tests/whatwg/modification/host_error_unset_existing.phpt b/ext/uri/tests/whatwg/modification/host_error_unset_existing.phpt new file mode 100644 index 0000000000000..ca5d5a0201d7c --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_unset_existing.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withHost(null); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified host is malformed (HostMissing) diff --git a/ext/uri/tests/whatwg/modification/host_success_encoded.phpt b/ext/uri/tests/whatwg/modification/host_success_encoded.phpt new file mode 100644 index 0000000000000..72008c19b89fe --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_success_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withHost("t%65st.com"); // test.com + +var_dump($url1->getAsciiHost()); +var_dump($url2->getAsciiHost()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(11) "example.com" +string(8) "test.com" +string(17) "https://test.com/" diff --git a/ext/uri/tests/whatwg/modification/host_success_existing.phpt b/ext/uri/tests/whatwg/modification/host_success_existing.phpt new file mode 100644 index 0000000000000..a8ad1cffae75c --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_success_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withHost("test.com"); + +var_dump($url1->getAsciiHost()); +var_dump($url2->getAsciiHost()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(11) "example.com" +string(8) "test.com" +string(17) "https://test.com/" diff --git a/ext/uri/tests/whatwg/modification/host_success_idna.phpt b/ext/uri/tests/whatwg/modification/host_success_idna.phpt new file mode 100644 index 0000000000000..919e22934dfa2 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_success_idna.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - IDNA characters +--EXTENSIONS-- +uri +--FILE-- +withHost("éxämple.com"); + +var_dump($url1->getAsciiHost()); +var_dump($url2->getAsciiHost()); +var_dump($url2->toAsciiString()); +var_dump($url2->getUnicodeHost()); +var_dump($url2->toUnicodeString()); + +?> +--EXPECT-- +string(11) "example.com" +string(19) "xn--xmple-gra7a.com" +string(28) "https://xn--xmple-gra7a.com/" +string(13) "éxämple.com" +string(22) "https://éxämple.com/" diff --git a/ext/uri/tests/whatwg/modification/host_success_ipv4.phpt b/ext/uri/tests/whatwg/modification/host_success_ipv4.phpt new file mode 100644 index 0000000000000..fef9e0fc63761 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_success_ipv4.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - IPv4 address +--EXTENSIONS-- +uri +--FILE-- +withHost("192.168.0.1"); + +var_dump($url1->getAsciiHost()); +var_dump($url2->getAsciiHost()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(11) "example.com" +string(11) "192.168.0.1" +string(20) "https://192.168.0.1/" diff --git a/ext/uri/tests/whatwg/modification/host_success_ipv6.phpt b/ext/uri/tests/whatwg/modification/host_success_ipv6.phpt new file mode 100644 index 0000000000000..2124b70ef56d7 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_success_ipv6.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - IPv6 address +--EXTENSIONS-- +uri +--FILE-- +withHost("[2001:0db8:3333:4444:5555:6666:7777:8888]"); + +var_dump($url1->getAsciiHost()); +var_dump($url2->getAsciiHost()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(11) "example.com" +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/password_success_auto_encoded.phpt b/ext/uri/tests/whatwg/modification/password_success_auto_encoded.phpt new file mode 100644 index 0000000000000..5db68cb90a622 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_auto_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - password - characters from the percent encode set +--EXTENSIONS-- +uri +--FILE-- +withPassword("p:s/"); + +var_dump($url1->getPassword()); +var_dump($url2->getPassword()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(8) "password" +string(8) "p%3As%2F" +string(34) "https://user:p%3As%2F@example.com/" diff --git a/ext/uri/tests/whatwg/modification/password_success_encoded.phpt b/ext/uri/tests/whatwg/modification/password_success_encoded.phpt new file mode 100644 index 0000000000000..82b172d914af1 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - password - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withPassword("p%61ssword"); + +var_dump($url1->getPassword()); +var_dump($url2->getPassword()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(10) "p%61ssword" +string(32) "https://:p%61ssword@example.com/" diff --git a/ext/uri/tests/whatwg/modification/password_success_existing.phpt b/ext/uri/tests/whatwg/modification/password_success_existing.phpt new file mode 100644 index 0000000000000..9c1a38be30055 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - password - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withPassword("password"); + +var_dump($url1->getPassword()); +var_dump($url2->getPassword()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(8) "password" +string(30) "https://:password@example.com/" diff --git a/ext/uri/tests/whatwg/modification/password_success_new.phpt b/ext/uri/tests/whatwg/modification/password_success_new.phpt new file mode 100644 index 0000000000000..8357b9972109d --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_new.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - adding a new one +--EXTENSIONS-- +uri +--FILE-- +withPassword("password"); + +var_dump($url1->getPassword()); +var_dump($url2->getPassword()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(8) "password" +string(30) "https://:password@example.com/" diff --git a/ext/uri/tests/whatwg/modification/password_success_unset_existing.phpt b/ext/uri/tests/whatwg/modification/password_success_unset_existing.phpt new file mode 100644 index 0000000000000..59ea81bc152d9 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_unset_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withPassword(null); + +var_dump($url1->getPassword()); +var_dump($url2->getPassword()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(8) "password" +NULL +string(29) "https://username@example.com/" diff --git a/ext/uri/tests/whatwg/modification/password_success_unset_non_existent.phpt b/ext/uri/tests/whatwg/modification/password_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..95649f6edfc43 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_unset_non_existent.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - unsetting non-existent +--EXTENSIONS-- +uri +--FILE-- +withPassword(null); + +var_dump($url1->getPassword()); +var_dump($url2->getPassword()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/path_success_auto_encoded.phpt b/ext/uri/tests/whatwg/modification/path_success_auto_encoded.phpt new file mode 100644 index 0000000000000..59f539124c68b --- /dev/null +++ b/ext/uri/tests/whatwg/modification/path_success_auto_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - path - characters from the percent encode set +--EXTENSIONS-- +uri +--FILE-- +withPath("/p^th#"); + +var_dump($url1->getPath()); +var_dump($url2->getPath()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(1) "/" +string(8) "/p^th%23" +string(27) "https://example.com/p^th%23" diff --git a/ext/uri/tests/whatwg/modification/path_success_empty.phpt b/ext/uri/tests/whatwg/modification/path_success_empty.phpt new file mode 100644 index 0000000000000..9e8d3495445a4 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/path_success_empty.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - path - empty string +--EXTENSIONS-- +uri +--FILE-- +withPath(""); + +var_dump($url1->getPath()); +var_dump($url2->getPath()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(1) "/" +string(1) "/" +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/path_success_encoded.phpt b/ext/uri/tests/whatwg/modification/path_success_encoded.phpt new file mode 100644 index 0000000000000..cb4e78610f734 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/path_success_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - path - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withPath("/foo%2Fbar"); // /foo/bar + +var_dump($url1->getPath()); +var_dump($url2->getPath()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(1) "/" +string(10) "/foo%2Fbar" +string(29) "https://example.com/foo%2Fbar" diff --git a/ext/uri/tests/whatwg/modification/path_success_existing.phpt b/ext/uri/tests/whatwg/modification/path_success_existing.phpt new file mode 100644 index 0000000000000..113c8c88d48bd --- /dev/null +++ b/ext/uri/tests/whatwg/modification/path_success_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - path - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withPath("/baz"); + +var_dump($url1->getPath()); +var_dump($url2->getPath()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(8) "/foo/bar" +string(4) "/baz" +string(23) "https://example.com/baz" diff --git a/ext/uri/tests/whatwg/modification/path_success_unicode.phpt b/ext/uri/tests/whatwg/modification/path_success_unicode.phpt new file mode 100644 index 0000000000000..d195a6dadbc18 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/path_success_unicode.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - path - unicode characters +--EXTENSIONS-- +uri +--FILE-- +withPath("/ő"); + +var_dump($url1->getPath()); +var_dump($url2->getPath()); +var_dump($url2->toAsciiString()); +?> +--EXPECT-- +string(1) "/" +string(7) "/%C5%91" +string(26) "https://example.com/%C5%91" diff --git a/ext/uri/tests/whatwg/modification/path_success_without_leading_slash.phpt b/ext/uri/tests/whatwg/modification/path_success_without_leading_slash.phpt new file mode 100644 index 0000000000000..1149287dc5319 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/path_success_without_leading_slash.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - path - without leading slash +--EXTENSIONS-- +uri +--FILE-- +withPath("foo/bar"); + +var_dump($url1->getPath()); +var_dump($url2->getPath()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(1) "/" +string(8) "/foo/bar" +string(27) "https://example.com/foo/bar" diff --git a/ext/uri/tests/whatwg/modification/port_error_negative.phpt b/ext/uri/tests/whatwg/modification/port_error_negative.phpt new file mode 100644 index 0000000000000..c0d070ffaf931 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_error_negative.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - negative +--EXTENSIONS-- +uri +--FILE-- +withPort(-1); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified port is malformed diff --git a/ext/uri/tests/whatwg/modification/port_error_overflow.phpt b/ext/uri/tests/whatwg/modification/port_error_overflow.phpt new file mode 100644 index 0000000000000..4faac86e632e4 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_error_overflow.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - too large port numbers don't overflow +--EXTENSIONS-- +uri +--FILE-- +withPort(9223372036854775808); + } else { + $url->withPort(2147483648); + } +} catch (TypeError $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +Uri\WhatWg\Url::withPort(): Argument #1 ($port) must be of type ?int, float given diff --git a/ext/uri/tests/whatwg/modification/port_error_too_large.phpt b/ext/uri/tests/whatwg/modification/port_error_too_large.phpt new file mode 100644 index 0000000000000..4060056b0a565 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_error_too_large.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - larger than a 16-bit unsigned integer +--EXTENSIONS-- +uri +--FILE-- +withPort(65536); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified port is malformed (PortOutOfRange) diff --git a/ext/uri/tests/whatwg/modification/port_success_existing.phpt b/ext/uri/tests/whatwg/modification/port_success_existing.phpt new file mode 100644 index 0000000000000..e5ea806bd1a40 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_success_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withPort(443); + +var_dump($url1->getPort()); +var_dump($url2->getPort()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +int(80) +int(443) +string(24) "scheme://example.com:443" diff --git a/ext/uri/tests/whatwg/modification/port_success_new.phpt b/ext/uri/tests/whatwg/modification/port_success_new.phpt new file mode 100644 index 0000000000000..85098b21b7b32 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_success_new.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - adding a new one +--EXTENSIONS-- +uri +--FILE-- +withPort(443); + +var_dump($url1->getPort()); +var_dump($url2->getPort()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +int(443) +string(24) "scheme://example.com:443" diff --git a/ext/uri/tests/whatwg/modification/port_success_special1.phpt b/ext/uri/tests/whatwg/modification/port_success_special1.phpt new file mode 100644 index 0000000000000..ba85449e43536 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_success_special1.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - adding a new one for a special URL +--EXTENSIONS-- +uri +--FILE-- +withPort(80); + +var_dump($url1->getPort()); +var_dump($url2->getPort()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +int(88) +NULL +string(19) "http://example.com/" diff --git a/ext/uri/tests/whatwg/modification/port_success_special2.phpt b/ext/uri/tests/whatwg/modification/port_success_special2.phpt new file mode 100644 index 0000000000000..d9f0074f05329 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_success_special2.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - adding a new one for a special URL +--EXTENSIONS-- +uri +--FILE-- +withPort(443); + +var_dump($url1->getPort()); +var_dump($url2->getPort()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/port_success_unset_existing.phpt b/ext/uri/tests/whatwg/modification/port_success_unset_existing.phpt new file mode 100644 index 0000000000000..c280c181b19a4 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_success_unset_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withPort(null); + +var_dump($url1->getPort()); +var_dump($url2->getPort()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +int(80) +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/port_success_unset_non_existent.phpt b/ext/uri/tests/whatwg/modification/port_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..d364c72d7002b --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_success_unset_non_existent.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - unsetting non-existent +--EXTENSIONS-- +uri +--FILE-- +withPort(null); + +var_dump($url2->getPort()); +var_dump($url2->getPort()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(18) "ftp://example.com/" diff --git a/ext/uri/tests/whatwg/modification/query_success_auto_encoded.phpt b/ext/uri/tests/whatwg/modification/query_success_auto_encoded.phpt new file mode 100644 index 0000000000000..fc487f33797d5 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_auto_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - characters from the percent encode set +--EXTENSIONS-- +uri +--FILE-- +withQuery("#foo "); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(9) "%23foo%20" +string(30) "https://example.com/?%23foo%20" diff --git a/ext/uri/tests/whatwg/modification/query_success_context_senstivie_reserved.phpt b/ext/uri/tests/whatwg/modification/query_success_context_senstivie_reserved.phpt new file mode 100644 index 0000000000000..cb220a0a33ef3 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_context_senstivie_reserved.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - context-sensitive reserved character +--EXTENSIONS-- +uri +--FILE-- +withQuery("?foo=bar"); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(7) "foo=bar" +string(28) "https://example.com/?foo=bar" diff --git a/ext/uri/tests/whatwg/modification/query_success_empty.phpt b/ext/uri/tests/whatwg/modification/query_success_empty.phpt new file mode 100644 index 0000000000000..dcb98bc37689d --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_empty.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - empty string +--EXTENSIONS-- +uri +--FILE-- +withQuery(""); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/query_success_encoded.phpt b/ext/uri/tests/whatwg/modification/query_success_encoded.phpt new file mode 100644 index 0000000000000..60a55138ec8c8 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withQuery("foo%3dbar"); // foo=bar + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(9) "foo%3dbar" +string(30) "https://example.com/?foo%3dbar" diff --git a/ext/uri/tests/whatwg/modification/query_success_existing.phpt b/ext/uri/tests/whatwg/modification/query_success_existing.phpt new file mode 100644 index 0000000000000..b3429b58b8651 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - changing an existing one +--EXTENSIONS-- +uri +--FILE-- +withQuery("foo=bar&baz=qux"); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(7) "foo=bar" +string(15) "foo=bar&baz=qux" +string(36) "https://example.com/?foo=bar&baz=qux" diff --git a/ext/uri/tests/whatwg/modification/query_success_unicode.phpt b/ext/uri/tests/whatwg/modification/query_success_unicode.phpt new file mode 100644 index 0000000000000..526138f8954af --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_unicode.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - unicode characters +--EXTENSIONS-- +uri +--FILE-- +withQuery("ő"); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(6) "%C5%91" +string(27) "https://example.com/?%C5%91" diff --git a/ext/uri/tests/whatwg/modification/query_success_unset_existing.phpt b/ext/uri/tests/whatwg/modification/query_success_unset_existing.phpt new file mode 100644 index 0000000000000..cb5a2a701e24a --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_unset_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withQuery(null); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(7) "foo=bar" +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/query_success_unset_non_existent.phpt b/ext/uri/tests/whatwg/modification/query_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..6456dcacac7f9 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_unset_non_existent.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - unsetting not-existent +--EXTENSIONS-- +uri +--FILE-- +withQuery(null); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(20) "https://example.com/" diff --git a/ext/uri/tests/whatwg/modification/query_success_with_leading_question_mark.phpt b/ext/uri/tests/whatwg/modification/query_success_with_leading_question_mark.phpt new file mode 100644 index 0000000000000..ce67dcb6bb352 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_with_leading_question_mark.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - with leading question mark +--EXTENSIONS-- +uri +--FILE-- +withQuery("?foo=bar"); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(7) "foo=bar" +string(35) "https://example.com/foo/bar?foo=bar" diff --git a/ext/uri/tests/whatwg/modification/scheme_error_empty.phpt b/ext/uri/tests/whatwg/modification/scheme_error_empty.phpt new file mode 100644 index 0000000000000..0460fa72945f6 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/scheme_error_empty.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - scheme - empty string +--EXTENSIONS-- +uri +--FILE-- +withScheme(""); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified scheme is malformed diff --git a/ext/uri/tests/whatwg/modification/scheme_error_encoded.phpt b/ext/uri/tests/whatwg/modification/scheme_error_encoded.phpt new file mode 100644 index 0000000000000..a52dc65dadd8a --- /dev/null +++ b/ext/uri/tests/whatwg/modification/scheme_error_encoded.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - scheme - URL encoded characters +--EXTENSIONS-- +uri +--FILE-- +withScheme("http%73"); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified scheme is malformed diff --git a/ext/uri/tests/whatwg/modification/scheme_error_invalid.phpt b/ext/uri/tests/whatwg/modification/scheme_error_invalid.phpt new file mode 100644 index 0000000000000..21cd04346a3c3 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/scheme_error_invalid.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - scheme - invalid characters +--EXTENSIONS-- +uri +--FILE-- +withScheme("http?"); +} catch (Uri\WhatWg\InvalidUrlException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +The specified scheme is malformed diff --git a/ext/uri/tests/whatwg/modification/scheme_success_basic.phpt b/ext/uri/tests/whatwg/modification/scheme_success_basic.phpt new file mode 100644 index 0000000000000..5104bd997de25 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/scheme_success_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - scheme - basic case +--EXTENSIONS-- +uri +--FILE-- +withScheme("http"); + +var_dump($url1->getScheme()); +var_dump($url2->getScheme()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(5) "https" +string(4) "http" +string(19) "http://example.com/" diff --git a/ext/uri/tests/whatwg/modification/scheme_success_colon.phpt b/ext/uri/tests/whatwg/modification/scheme_success_colon.phpt new file mode 100644 index 0000000000000..052eca6e247b0 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/scheme_success_colon.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - scheme - trailing colon +--EXTENSIONS-- +uri +--FILE-- +withScheme("http:"); + +var_dump($url1->getScheme()); +var_dump($url2->getScheme()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(5) "https" +string(4) "http" +string(19) "http://example.com/" diff --git a/ext/uri/tests/whatwg/modification/scheme_success_full.phpt b/ext/uri/tests/whatwg/modification/scheme_success_full.phpt new file mode 100644 index 0000000000000..957a1fab7aff2 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/scheme_success_full.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - scheme - trailing colon and double slash +--EXTENSIONS-- +uri +--FILE-- +withScheme("http://"); + +var_dump($url1->getScheme()); +var_dump($url2->getScheme()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(5) "https" +string(4) "http" +string(19) "http://example.com/" diff --git a/ext/uri/tests/whatwg/modification/username_success_auto_encoded.phpt b/ext/uri/tests/whatwg/modification/username_success_auto_encoded.phpt new file mode 100644 index 0000000000000..bc0beab496495 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_auto_encoded.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - characters from the percent encode set +--EXTENSIONS-- +uri +--FILE-- +withUsername("u:s/r"); + +var_dump($url1->getUsername()); +var_dump($url2->getUsername()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(4) "user" +string(9) "u%3As%2Fr" +string(39) "https://u%3As%2Fr:password@example.com/" diff --git a/ext/uri/tests/whatwg/modification/username_success_existing.phpt b/ext/uri/tests/whatwg/modification/username_success_existing.phpt new file mode 100644 index 0000000000000..83093ee63fc01 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - changing existing +--EXTENSIONS-- +uri +--FILE-- +withUsername("username"); + +var_dump($url1->getUsername()); +var_dump($url2->getUsername()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(8) "username" +string(29) "https://username@example.com/" diff --git a/ext/uri/tests/whatwg/modification/username_success_new.phpt b/ext/uri/tests/whatwg/modification/username_success_new.phpt new file mode 100644 index 0000000000000..56666a68ea7d2 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_new.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - adding a new one +--EXTENSIONS-- +uri +--FILE-- +withUsername("username"); + +var_dump($url1->getUsername()); +var_dump($url2->getUsername()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(8) "username" +string(29) "https://username@example.com/" diff --git a/ext/uri/tests/whatwg/modification/username_success_unset_existing.phpt b/ext/uri/tests/whatwg/modification/username_success_unset_existing.phpt new file mode 100644 index 0000000000000..f71deff3f207b --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_unset_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - unsetting existing +--EXTENSIONS-- +uri +--FILE-- +withUsername(null); + +var_dump($url1->getUsername()); +var_dump($url2->getUsername()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(8) "username" +NULL +string(30) "https://:password@example.com/" diff --git a/ext/uri/tests/whatwg/modification/username_success_unset_non_existent.phpt b/ext/uri/tests/whatwg/modification/username_success_unset_non_existent.phpt new file mode 100644 index 0000000000000..44a6486104242 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_unset_non_existent.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - username - unsetting non-existent +--EXTENSIONS-- +uri +--FILE-- +withUsername(null); + +var_dump($url1->getUsername()); +var_dump($url2->getUsername()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(20) "https://example.com/"