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 00000000000..4b3c3dd00a9 --- /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 00000000000..bbb1e2ffe87 --- /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 00000000000..f0a05d5bb5b --- /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 00000000000..b1b1081ff81 --- /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%3db%61r"); // 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(11) "foo%3db%61r" +string(31) "https://example.com#foo%3db%61r" +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 00000000000..fe534e84650 --- /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 00000000000..7532c35e0fe --- /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 00000000000..1c6fa898dde --- /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 00000000000..81d60bc2e40 --- /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 00000000000..b337674841c --- /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 00000000000..d9db6003b15 --- /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("%65xample.net"); // example.net + +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) "%65xample.net" +string(21) "https://%65xample.net" +string(11) "example.net" +string(19) "https://example.net" 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 00000000000..f9d3da987ab --- /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("example.net"); + +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) "example.net" +string(19) "https://example.net" +string(11) "example.net" +string(19) "https://example.net" 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 00000000000..004210000cf --- /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 00000000000..850a32281ab --- /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 00000000000..47508884015 --- /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 00000000000..32661614007 --- /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 00000000000..521b6397ec4 --- /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 00000000000..b1793a31413 --- /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 00000000000..2da84e2689b --- /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 00000000000..9335132dad5 --- /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 00000000000..476e4ec873c --- /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 00000000000..58f5ab4baa6 --- /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 00000000000..a67eeae44ee --- /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 00000000000..05b62cafe25 --- /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%2Fb%61r"); // /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(12) "/foo%2Fb%61r" +string(31) "https://example.com/foo%2Fb%61r" +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 00000000000..6dafbc0a3ff --- /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 00000000000..598475b1e18 --- /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 00000000000..8451f1bcf46 --- /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 00000000000..36ccea04a94 --- /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 00000000000..574af3f6e3e --- /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 00000000000..a3fbdc5e874 --- /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 00000000000..f09e867a021 --- /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 00000000000..c8f51005974 --- /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_sensitive_reserved.phpt b/ext/uri/tests/rfc3986/modification/query_success_context_sensitive_reserved.phpt new file mode 100644 index 00000000000..d40a7f7e09e --- /dev/null +++ b/ext/uri/tests/rfc3986/modification/query_success_context_sensitive_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 00000000000..e668b44df9b --- /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 00000000000..7fd9707220d --- /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 00000000000..b5af7feee25 --- /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 00000000000..89d130eedc2 --- /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 00000000000..d9dfcd20831 --- /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 00000000000..4349764d4dd --- /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 00000000000..624abf2fc49 --- /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 00000000000..7d6e1e4d048 --- /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 00000000000..477be1d2331 --- /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 00000000000..683f46cc42a --- /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 00000000000..dd3bcc02f83 --- /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 00000000000..695cb9c7f1e --- /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 00000000000..67d447e8810 --- /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 00000000000..4aa9b2d9dd2 --- /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 00000000000..a5f820b0d59 --- /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 00000000000..ab753e6de50 --- /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 00000000000..a4b7409d670 --- /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 00000000000..a13e091075c --- /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 00000000000..dc49c10d752 --- /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 00000000000..0f4e7219cbd --- /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 00000000000..9aa2a5999ac --- /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 00000000000..ac74b8668cd --- /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 00000000000..5b3aa942623 --- /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 00000000000..9473ea9535f --- /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%3db%61r"); // foo=bar + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(11) "foo%3db%61r" +string(32) "https://example.com/#foo%3db%61r" 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 00000000000..0a7d253434d --- /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_hashmark.phpt b/ext/uri/tests/whatwg/modification/fragment_success_hashmark.phpt new file mode 100644 index 00000000000..12ce6d6e6b6 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/fragment_success_hashmark.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - fragment - only a hashmark character +--EXTENSIONS-- +uri +--FILE-- +withFragment("#"); + +var_dump($url1->getFragment()); +var_dump($url2->getFragment()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(21) "https://example.com/#" 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 00000000000..c609b5df042 --- /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 00000000000..585707e497e --- /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 00000000000..21e295db23e --- /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 00000000000..4523388223b --- /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 00000000000..f9f47395786 --- /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 00000000000..8aebc5f7057 --- /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 00000000000..6d8b0c8b656 --- /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 00000000000..7d32dcba2c6 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_opaque3.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - host - forbidden host codepoint +--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_special1.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special1.phpt new file mode 100644 index 00000000000..a27c26381b4 --- /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 00000000000..a0626d99c51 --- /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_forbidden_host_codepoint_special3.phpt b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special3.phpt new file mode 100644 index 00000000000..a0626d99c51 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/host_error_forbidden_host_codepoint_special3.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 00000000000..ca5d5a0201d --- /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 00000000000..9604476554f --- /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("%65xample.net"); // example.net + +var_dump($url1->getAsciiHost()); +var_dump($url2->getAsciiHost()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(11) "example.com" +string(11) "example.net" +string(20) "https://example.net/" 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 00000000000..57394c851c7 --- /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("example.net"); + +var_dump($url1->getAsciiHost()); +var_dump($url2->getAsciiHost()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(11) "example.com" +string(11) "example.net" +string(20) "https://example.net/" 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 00000000000..919e22934df --- /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 00000000000..fef9e0fc637 --- /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 00000000000..2124b70ef56 --- /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 00000000000..5db68cb90a6 --- /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_empty.phpt b/ext/uri/tests/whatwg/modification/password_success_empty.phpt new file mode 100644 index 00000000000..40c350cc1b3 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_empty.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - password - empty string +--EXTENSIONS-- +uri +--FILE-- +withPassword(""); + +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/password_success_encoded.phpt b/ext/uri/tests/whatwg/modification/password_success_encoded.phpt new file mode 100644 index 00000000000..82b172d914a --- /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 00000000000..61b0ce3909b --- /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-- +string(4) "pass" +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 00000000000..8357b997210 --- /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 00000000000..957973b062a --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_unset_existing.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - password - 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_existent1.phpt b/ext/uri/tests/whatwg/modification/password_success_unset_non_existent1.phpt new file mode 100644 index 00000000000..357b33b78c0 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_unset_non_existent1.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - password - 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/password_success_unset_non_existent2.phpt b/ext/uri/tests/whatwg/modification/password_success_unset_non_existent2.phpt new file mode 100644 index 00000000000..a2140669ee8 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/password_success_unset_non_existent2.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(29) "https://username@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 00000000000..59f539124c6 --- /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 00000000000..9e8d3495445 --- /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 00000000000..b698c4691b0 --- /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%2Fb%61r"); // /foo/bar + +var_dump($url1->getPath()); +var_dump($url2->getPath()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +string(1) "/" +string(12) "/foo%2Fb%61r" +string(31) "https://example.com/foo%2Fb%61r" 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 00000000000..113c8c88d48 --- /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 00000000000..d195a6dadbc --- /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 00000000000..1149287dc53 --- /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 00000000000..5de87d7e760 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/port_error_negative.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - port - negative number +--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_too_large.phpt b/ext/uri/tests/whatwg/modification/port_error_too_large.phpt new file mode 100644 index 00000000000..4060056b0a5 --- /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 00000000000..e5ea806bd1a --- /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 00000000000..85098b21b7b --- /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 00000000000..ba85449e435 --- /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 00000000000..d9f0074f053 --- /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 00000000000..c280c181b19 --- /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 00000000000..d364c72d700 --- /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 00000000000..fc487f33797 --- /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_sensitive_reserved.phpt b/ext/uri/tests/whatwg/modification/query_success_context_sensitive_reserved.phpt new file mode 100644 index 00000000000..cb220a0a33e --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_context_sensitive_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 00000000000..dcb98bc3768 --- /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 00000000000..f9935015f7b --- /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%3db%61r"); // foo=bar + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +string(11) "foo%3db%61r" +string(32) "https://example.com/?foo%3db%61r" 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 00000000000..b3429b58b86 --- /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_question_mark.phpt b/ext/uri/tests/whatwg/modification/query_success_question_mark.phpt new file mode 100644 index 00000000000..18a1593a981 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/query_success_question_mark.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test Uri\WhatWg\Url component modification - query - only a question mark character +--EXTENSIONS-- +uri +--FILE-- +withQuery("?"); + +var_dump($url1->getQuery()); +var_dump($url2->getQuery()); +var_dump($url2->toAsciiString()); + +?> +--EXPECT-- +NULL +NULL +string(21) "https://example.com/?" 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 00000000000..526138f8954 --- /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 00000000000..cb5a2a701e2 --- /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 00000000000..6456dcacac7 --- /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 00000000000..ce67dcb6bb3 --- /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 00000000000..0460fa72945 --- /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 00000000000..a52dc65dadd --- /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 00000000000..21cd04346a3 --- /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 00000000000..6f66b30b2b7 --- /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 00000000000..052eca6e247 --- /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 00000000000..957a1fab7af --- /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 00000000000..bc0beab4964 --- /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 00000000000..2506acf85d7 --- /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-- +string(4) "user" +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 00000000000..56666a68ea7 --- /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 00000000000..f71deff3f20 --- /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_existent1.phpt b/ext/uri/tests/whatwg/modification/username_success_unset_non_existent1.phpt new file mode 100644 index 00000000000..44a64861042 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_unset_non_existent1.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/" diff --git a/ext/uri/tests/whatwg/modification/username_success_unset_non_existent2.phpt b/ext/uri/tests/whatwg/modification/username_success_unset_non_existent2.phpt new file mode 100644 index 00000000000..e5af4efb223 --- /dev/null +++ b/ext/uri/tests/whatwg/modification/username_success_unset_non_existent2.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(30) "https://:password@example.com/"