@@ -28,7 +28,7 @@ protected function tearDown()
28
28
public function testParseBadUrlThrowsInvalidArgumentException ()
29
29
{
30
30
$ this ->setExpectedException (
31
- '\InvalidArgumentException ' ,
31
+ '\InvalidArgumentException ' ,
32
32
'Invalid url http:///example.com '
33
33
);
34
34
@@ -95,14 +95,17 @@ public function testGetSubdomain($url, $publicSuffix, $registerableDomain, $subd
95
95
$ this ->assertSame ($ subdomain , $ pdpUrl ->host ->subdomain );
96
96
$ this ->assertSame ($ subdomain , $ this ->parser ->getSubdomain ($ hostPart ));
97
97
}
98
-
99
- /**
98
+
99
+ /**
100
100
* @dataProvider parseDataProvider
101
- */
102
- public function testPHPparse_urlCanReturnCorrectHost ($ url , $ publicSuffix , $ registerableDomain , $ subdomain , $ hostPart )
103
- {
104
- $ this ->assertEquals ($ hostPart , parse_url ('http:// ' . $ hostPart , PHP_URL_HOST ));
105
- }
101
+ */
102
+ public function testMbParseUrlCanReturnCorrectHost ($ url , $ publicSuffix , $ registerableDomain , $ subdomain , $ hostPart )
103
+ {
104
+ $ this ->assertEquals (
105
+ $ hostPart ,
106
+ $ this ->parser ->mbParseUrl ('http:// ' . $ hostPart , PHP_URL_HOST )
107
+ );
108
+ }
106
109
107
110
public function parseDataProvider ()
108
111
{
@@ -140,6 +143,14 @@ public function parseDataProvider()
140
143
array ('test.museum ' , 'museum ' , 'test.museum ' , null , 'test.museum ' ),
141
144
array ('bob.smith.name ' , 'name ' , 'smith.name ' , 'bob ' , 'bob.smith.name ' ),
142
145
array ('tons.of.info ' , 'info ' , 'of.info ' , 'tons ' , 'tons.of.info ' ),
146
+ // Test IDN parsing
147
+ // Related to https://github.com/jeremykendall/php-domain-parser/issues/29
148
+ array ('http://Яндекс.РФ ' , 'рф ' , 'яндекс.рф ' , null , 'яндекс.рф ' ),
149
+ array ('www.食狮.中国 ' , '中国 ' , '食狮.中国 ' , 'www ' , 'www.食狮.中国 ' ),
150
+ array ('食狮.com.cn ' , 'com.cn ' , '食狮.com.cn ' , null , '食狮.com.cn ' ),
151
+ // Test punycode URLs
152
+ array ('www.xn--85x722f.xn--fiqs8s ' , 'xn--fiqs8s ' , 'xn--85x722f.xn--fiqs8s ' , 'www ' , 'www.xn--85x722f.xn--fiqs8s ' ),
153
+ array ('xn--85x722f.com.cn ' , 'com.cn ' , 'xn--85x722f.com.cn ' , null , 'xn--85x722f.com.cn ' ),
143
154
);
144
155
}
145
156
}
0 commit comments