@@ -23,11 +23,12 @@ protected function tearDown()
2323
2424 /**
2525 * @covers Pdp\Parser::parseUrl()
26+ * @covers Pdp\Parser::mbParseUrl()
2627 */
2728 public function testParseBadUrlThrowsInvalidArgumentException ()
2829 {
2930 $ this ->setExpectedException (
30- '\InvalidArgumentException ' ,
31+ '\InvalidArgumentException ' ,
3132 'Invalid url http:///example.com '
3233 );
3334
@@ -94,21 +95,24 @@ public function testGetSubdomain($url, $publicSuffix, $registerableDomain, $subd
9495 $ this ->assertSame ($ subdomain , $ pdpUrl ->host ->subdomain );
9596 $ this ->assertSame ($ subdomain , $ this ->parser ->getSubdomain ($ hostPart ));
9697 }
97-
98- /**
98+
99+ /**
99100 * @dataProvider parseDataProvider
100- */
101- public function testPHPparse_urlCanReturnCorrectHost ($ url , $ publicSuffix , $ registerableDomain , $ subdomain , $ hostPart )
102- {
103- $ this ->assertEquals ($ hostPart , parse_url ('http:// ' . $ hostPart , PHP_URL_HOST ));
104- }
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+ }
105109
106110 public function parseDataProvider ()
107111 {
108112 // url, public suffix, registerable domain, subdomain, host part
109113 return array (
110114 array ('http://www.waxaudio.com.au/audio/albums/the_mashening ' , 'com.au ' , 'waxaudio.com.au ' , 'www ' , 'www.waxaudio.com.au ' ),
111- array ('example.com ' , 'com ' , 'example.com ' , null , 'example.com ' ),
115+ array ('example.COM ' , 'com ' , 'example.com ' , null , 'example.com ' ),
112116 array ('giant.yyyy ' , 'yyyy ' , 'giant.yyyy ' , null , 'giant.yyyy ' ),
113117 array ('cea-law.co.il ' , 'co.il ' , 'cea-law.co.il ' , null , 'cea-law.co.il ' ),
114118 array ('http://edition.cnn.com/WORLD/ ' , 'com ' , 'cnn.com ' , 'edition ' , 'edition.cnn.com ' ),
@@ -139,6 +143,15 @@ public function parseDataProvider()
139143 array ('test.museum ' , 'museum ' , 'test.museum ' , null , 'test.museum ' ),
140144 array ('bob.smith.name ' , 'name ' , 'smith.name ' , 'bob ' , 'bob.smith.name ' ),
141145 array ('tons.of.info ' , 'info ' , 'of.info ' , 'tons ' , 'tons.of.info ' ),
146+ // Test IDN parsing
147+ // BEGIN https://github.com/jeremykendall/php-domain-parser/issues/29
148+ array ('http://Яндекс.РФ ' , 'рф ' , 'яндекс.рф ' , null , 'яндекс.рф ' ),
149+ // END https://github.com/jeremykendall/php-domain-parser/issues/29
150+ array ('www.食狮.中国 ' , '中国 ' , '食狮.中国 ' , 'www ' , 'www.食狮.中国 ' ),
151+ array ('食狮.com.cn ' , 'com.cn ' , '食狮.com.cn ' , null , '食狮.com.cn ' ),
152+ // Test punycode URLs
153+ array ('www.xn--85x722f.xn--fiqs8s ' , 'xn--fiqs8s ' , 'xn--85x722f.xn--fiqs8s ' , 'www ' , 'www.xn--85x722f.xn--fiqs8s ' ),
154+ array ('xn--85x722f.com.cn ' , 'com.cn ' , 'xn--85x722f.com.cn ' , null , 'xn--85x722f.com.cn ' ),
142155 );
143156 }
144157}
0 commit comments