1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.5'

* PHP-8.5:
  Reorganize ext/uri tests - withers (#19970)
This commit is contained in:
Máté Kocsis
2025-10-25 14:47:33 +02:00
119 changed files with 2371 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - fragment - reserved characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withFragment("#fragment");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified fragment is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - fragment - unicode characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withFragment("ő");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified fragment is malformed

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - fragment - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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#"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - fragment - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - fragment - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com#foo");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - fragment - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com#foo");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - fragment - unsetting not-existent
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - reserved characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withHost("ex#mple.com");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified host is malformed

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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://"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - IP future address
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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]"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - IPv4 address
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - IPv6 address
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->withHost("[2001:0db8:3333:4444:5555:6666:7777:8888]");
var_dump($uri1->getRawHost());
var_dump($uri2->getRawHost());
var_dump($uri2->toRawString());
var_dump($uri2->getHost());
var_dump($uri2->toString());
?>
--EXPECT--
string(11) "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]"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - adding a new one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("/foo/bar");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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:/"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - unsetting non-existent
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("/foo/bar");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - path - reserved characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withPath("/[foo]");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified path is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - path - unicode characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withPath("/ő");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified path is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - path - without leading slash
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withPath("foo");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified path is malformed

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - path - using an email format
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - path - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - path - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - path - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com/foo/bar");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - host - too small number
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withPort(-1);
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified port is malformed

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - port - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com:80");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - port - adding a new one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->withPort(443);
var_dump($uri1->getPort());
var_dump($uri2->getPort());
var_dump($uri2->toRawString());
?>
--EXPECT--
NULL
int(443)
string(23) "https://example.com:443"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - port - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com:80");
$uri2 = $uri1->withPort(null);
var_dump($uri1->getPort());
var_dump($uri2->getPort());
var_dump($uri2->toRawString());
?>
--EXPECT--
int(80)
NULL
string(19) "https://example.com"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - port - unsetting non-existent
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("ftp://example.com");
$uri2 = $uri1->withPort(null);
var_dump($uri2->getPort());
var_dump($uri2->getPort());
var_dump($uri2->toRawString());
?>
--EXPECT--
NULL
NULL
string(17) "ftp://example.com"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - query - reserved characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withQuery("#foo");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified query is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - query - unicode characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withQuery("ő");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified query is malformed

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - query - context-sensitive reserved character
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - query - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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?"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - query - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - query - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com?foo=bar");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - query - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com?foo=bar");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - query - unsetting not-existent
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,24 @@
--TEST--
Test Uri\Rfc3986\Uri component modification when roundtripping is not guaranteed - case 1
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("path1");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,20 @@
--TEST--
Test Uri\Rfc3986\Uri component modification when roundtripping is not guaranteed - case 2
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("scheme:path1:");
$uri2 = $uri1->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:"

View File

@@ -0,0 +1,20 @@
--TEST--
Test Uri\Rfc3986\Uri component modification when roundtripping is not guaranteed - case 3
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("//host//path");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - scheme - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withScheme("");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified scheme is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - scheme - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withScheme("http%73");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified scheme is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - scheme - reserved characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withScheme("https:");
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified scheme is malformed

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - scheme - basic case
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - scheme - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - scheme - unsetting non-existent
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("/foo/bar");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - userinfo - reserved characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri = Uri\Rfc3986\Uri::parse("https://example.com");
try {
$uri->withUserInfo("us/r:password"); // us/r:password
} catch (Uri\InvalidUriException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified userinfo is malformed

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - userinfo - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->withUserInfo("");
var_dump($uri1->getRawUserInfo());
var_dump($uri2->getRawUserInfo());
var_dump($uri2->getUserInfo());
?>
--EXPECT--
NULL
string(0) ""
string(0) ""

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - userinfo - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - userinfo - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://:pass@example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - userinfo - adding a new one
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - userinfo - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("https://user:password@example.com");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\Rfc3986\Uri component modification - userinfo - unsetting non-existent
--EXTENSIONS--
uri
--FILE--
<?php
$uri1 = Uri\Rfc3986\Uri::parse("/foo/bar");
$uri2 = $uri1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - characters from the percent encode set
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withFragment("");
var_dump($url1->getFragment());
var_dump($url2->getFragment());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(20) "https://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com#foo");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - only a hashmark character
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withFragment("#");
var_dump($url1->getFragment());
var_dump($url2->getFragment());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(21) "https://example.com/#"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - unicode characters
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com#foo");
$url2 = $url1->withFragment(null);
var_dump($url1->getFragment());
var_dump($url2->getFragment());
var_dump($url2->toAsciiString());
?>
--EXPECT--
string(3) "foo"
NULL
string(20) "https://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - unsetting not-existent
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withFragment(null);
var_dump($url1->getFragment());
var_dump($url2->getFragment());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(20) "https://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - fragment - with leading hashmark
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://example.com");
try {
$url->withHost("");
} catch (Uri\WhatWg\InvalidUrlException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified host is malformed (HostMissing)

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - forbidden host code point
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("foo://example.com");
try {
$url = $url->withHost("ex@mple.com");
} catch (Uri\WhatWg\InvalidUrlException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified host is malformed (HostInvalidCodePoint)

View File

@@ -0,0 +1,17 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - forbidden host code point
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("foo://example.com");
$url2 = $url1->withHost("ex#mple.com");
var_dump($url1->getAsciiHost());
var_dump($url2->getAsciiHost());
?>
--EXPECT--
string(11) "example.com"
string(2) "ex"

View File

@@ -0,0 +1,17 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - forbidden host codepoint
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withHost("ex#mple.com");
var_dump($url1->getAsciiHost());
var_dump($url2->getAsciiHost());
?>
--EXPECT--
string(11) "example.com"
string(2) "ex"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - forbidden domain code point
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://example.com");
try {
$url = $url->withHost("ex@mple.com");
} catch (Uri\WhatWg\InvalidUrlException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified host is malformed (DomainInvalidCodePoint)

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - forbidden domain code point
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://example.com");
try {
$url = $url->withHost("ex:mple.com");
} catch (Uri\WhatWg\InvalidUrlException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified host is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - forbidden domain code point
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://example.com");
try {
$url = $url->withHost("ex:mple.com");
} catch (Uri\WhatWg\InvalidUrlException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified host is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://example.com");
try {
$url = $url->withHost(null);
} catch (Uri\WhatWg\InvalidUrlException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified host is malformed (HostMissing)

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,23 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - IDNA characters
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - IPv4 address
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - IPv6 address
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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]/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - password - characters from the percent encode set
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://user:password@example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - password - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://@example.com");
$url2 = $url1->withPassword("");
var_dump($url1->getPassword());
var_dump($url2->getPassword());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(20) "https://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - password - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - password - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://:pass@example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - username - adding a new one
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - password - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://username:password@example.com");
$url2 = $url1->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/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - password - unsetting non-existent
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withPassword(null);
var_dump($url1->getPassword());
var_dump($url2->getPassword());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(20) "https://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - username - unsetting non-existent
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://username:@example.com");
$url2 = $url1->withPassword(null);
var_dump($url1->getPassword());
var_dump($url2->getPassword());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(29) "https://username@example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - path - characters from the percent encode set
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com/");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - path - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withPath("");
var_dump($url1->getPath());
var_dump($url2->getPath());
var_dump($url2->toAsciiString());
?>
--EXPECT--
string(1) "/"
string(1) "/"
string(20) "https://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - path - URL encoded characters
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - path - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com/foo/bar");
$url2 = $url1->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"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - path - unicode characters
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - path - without leading slash
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - port - negative number
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://example.com");
try {
$url->withPort(-1);
} catch (Uri\WhatWg\InvalidUrlException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified port is malformed

View File

@@ -0,0 +1,18 @@
--TEST--
Test Uri\WhatWg\Url component modification - host - larger than a 16-bit unsigned integer
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse("https://example.com");
try {
$url->withPort(65536);
} catch (Uri\WhatWg\InvalidUrlException $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
The specified port is malformed (PortOutOfRange)

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - port - changing an existing one
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("scheme://example.com:80");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - port - adding a new one
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("scheme://example.com");
$url2 = $url1->withPort(443);
var_dump($url1->getPort());
var_dump($url2->getPort());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
int(443)
string(24) "scheme://example.com:443"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - port - adding a new one for a special URL
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("http://example.com:88");
$url2 = $url1->withPort(80);
var_dump($url1->getPort());
var_dump($url2->getPort());
var_dump($url2->toAsciiString());
?>
--EXPECT--
int(88)
NULL
string(19) "http://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - port - adding a new one for a special URL
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withPort(443);
var_dump($url1->getPort());
var_dump($url2->getPort());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(20) "https://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - port - unsetting existing
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com:80");
$url2 = $url1->withPort(null);
var_dump($url1->getPort());
var_dump($url2->getPort());
var_dump($url2->toAsciiString());
?>
--EXPECT--
int(80)
NULL
string(20) "https://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - port - unsetting non-existent
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("ftp://example.com");
$url2 = $url1->withPort(null);
var_dump($url2->getPort());
var_dump($url2->getPort());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(18) "ftp://example.com/"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - query - characters from the percent encode set
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - query - context-sensitive reserved character
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->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"

View File

@@ -0,0 +1,19 @@
--TEST--
Test Uri\WhatWg\Url component modification - query - empty string
--EXTENSIONS--
uri
--FILE--
<?php
$url1 = Uri\WhatWg\Url::parse("https://example.com");
$url2 = $url1->withQuery("");
var_dump($url1->getQuery());
var_dump($url2->getQuery());
var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(20) "https://example.com/"

Some files were not shown because too many files have changed in this diff Show More