Skip to content

Commit 43b5f64

Browse files
committed
review: improved tests
1 parent 4111d0e commit 43b5f64

63 files changed

Lines changed: 648 additions & 599 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ext/uri/tests/rfc3986/serialization/array_cast_success.phpt renamed to ext/uri/tests/rfc3986/general/array_cast_success.phpt

File renamed without changes.
File renamed without changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Test Uri\Rfc3986\Uri __construct() - error - reinitialization
3+
--FILE--
4+
<?php
5+
6+
$uri = new Uri\Rfc3986\Uri('https://example.com');
7+
8+
try {
9+
$uri->__construct('ftp://example.org');
10+
} catch (Throwable $e) {
11+
echo $e::class, ': ', $e->getMessage(), "\n";
12+
}
13+
14+
var_dump($uri);
15+
var_dump($uri->toRawString());
16+
var_dump($uri->toString());
17+
18+
?>
19+
--EXPECTF--
20+
Error: Cannot modify readonly object of class Uri\Rfc3986\Uri
21+
object(Uri\Rfc3986\Uri)#%d (8) {
22+
["scheme"]=>
23+
string(5) "https"
24+
["username"]=>
25+
NULL
26+
["password"]=>
27+
NULL
28+
["host"]=>
29+
string(11) "example.com"
30+
["port"]=>
31+
NULL
32+
["path"]=>
33+
string(0) ""
34+
["query"]=>
35+
NULL
36+
["fragment"]=>
37+
NULL
38+
}
39+
string(19) "https://example.com"
40+
string(19) "https://example.com"
File renamed without changes.

ext/uri/tests/rfc3986/parsing/instantiate_without_constructor_error.phpt renamed to ext/uri/tests/rfc3986/general/instantiate_without_constructor_error.phpt

File renamed without changes.

‎ext/uri/tests/rfc3986/getters/basic_success.phpt‎

Lines changed: 0 additions & 48 deletions
This file was deleted.

‎ext/uri/tests/rfc3986/modification/host_success_ipv4_to_ipv6.phpt‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@ Test Uri\Rfc3986\Uri component modification - host - changing IPv4 to IPv6
44
<?php
55

66
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
7-
$uri2 = $uri1->withHost(null);
8-
$uri3 = $uri2->withHost("192.168.0.1");
9-
$uri4 = $uri3->withHost("[2001:db8:3333:4444:5555:6666:7777:8888]");
7+
$uri2 = $uri1->withHost("192.168.0.1");
8+
$uri3 = $uri2->withHost("[2001:db8:3333:4444:5555:6666:7777:8888]");
9+
10+
var_dump($uri2->getRawHost());
11+
var_dump($uri2->getHost());
12+
var_dump($uri2->toRawString());
13+
var_dump($uri2->toString());
1014

1115
var_dump($uri3->getRawHost());
1216
var_dump($uri3->getHost());
13-
var_dump($uri4->getRawHost());
14-
var_dump($uri4->getHost());
17+
var_dump($uri3->toRawString());
18+
var_dump($uri3->toString());
1519

1620
?>
1721
--EXPECT--
1822
string(11) "192.168.0.1"
1923
string(11) "192.168.0.1"
24+
string(19) "https://192.168.0.1"
25+
string(19) "https://192.168.0.1"
2026
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
2127
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
28+
string(49) "https://[2001:0db8:3333:4444:5555:6666:7777:8888]"
29+
string(49) "https://[2001:0db8:3333:4444:5555:6666:7777:8888]"

‎ext/uri/tests/rfc3986/modification/host_success_percent_encoded_reserved.phpt‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@ Test Uri\Rfc3986\Uri component modification - host - URL encoded reserved charac
44
<?php
55

66
$uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
7-
$uri1->withHost("t%3As%2Ft.com");
7+
$uri2 = $uri1->withHost("t%3As%2Ft.com");
8+
9+
var_dump($uri1->getRawHost());
10+
var_dump($uri1->toRawString());
11+
var_dump($uri1->getHost());
12+
var_dump($uri1->toString());
13+
14+
var_dump($uri2->getRawHost());
15+
var_dump($uri2->toRawString());
16+
var_dump($uri2->getHost());
17+
var_dump($uri2->toString());
818

919
?>
1020
--EXPECT--
21+
string(11) "example.com"
22+
string(19) "https://example.com"
23+
string(11) "example.com"
24+
string(19) "https://example.com"
25+
string(13) "t%3As%2Ft.com"
26+
string(21) "https://t%3As%2Ft.com"
27+
string(13) "t%3As%2Ft.com"
28+
string(21) "https://t%3As%2Ft.com"

‎ext/uri/tests/rfc3986/modification/port_success_empty_host.phpt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ $uri1 = Uri\Rfc3986\Uri::parse("file:///foo/bar");
77
$uri2 = $uri1->withPort(80);
88

99
var_dump($uri1->getPort());
10+
var_dump($uri1->toRawString());
11+
1012
var_dump($uri2->getPort());
13+
var_dump($uri2->toRawString());
1114

1215
?>
1316
--EXPECT--
1417
NULL
18+
string(15) "file:///foo/bar"
1519
int(80)
20+
string(18) "file://:80/foo/bar"

‎ext/uri/tests/rfc3986/modification/port_success_unset_without_host.phpt‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ Test Uri\Rfc3986\Uri component modification - port - unsetting without a host
33
--FILE--
44
<?php
55

6-
$uri1 = Uri\Rfc3986\Uri::parse("/foo");
6+
$uri1 = Uri\Rfc3986\Uri::parse('https://:80/foo/bar');
77
$uri2 = $uri1->withPort(null);
88

9+
var_dump($uri1->getPort());
10+
var_dump($uri1->toString());
11+
912
var_dump($uri2->getPort());
13+
var_dump($uri2->toString());
1014

1115
?>
1216
--EXPECT--
17+
int(80)
18+
string(19) "https://:80/foo/bar"
1319
NULL
20+
string(16) "https:///foo/bar"

0 commit comments

Comments
 (0)