scratch – Blame information for rev 126
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
126 | office | 1 | <?php |
2 | |||
3 | namespace Aura\Uri; |
||
4 | |||
5 | class PublicSuffixListTest extends \PHPUnit_Framework_TestCase |
||
6 | { |
||
7 | /** |
||
8 | * @var \Aura\Uri\PublicSuffixList |
||
9 | */ |
||
10 | protected $psl; |
||
11 | |||
12 | protected function setUp() |
||
13 | { |
||
14 | parent::setUp(); |
||
15 | $file = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR |
||
16 | . 'data' . DIRECTORY_SEPARATOR |
||
17 | . 'public-suffix-list.php'; |
||
18 | $this->psl = new PublicSuffixList(require $file); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @dataProvider parseDataProvider |
||
23 | */ |
||
24 | public function testGetPublicSuffix($url, $publicSuffix, $registerableDomain, $subdomain, $hostPart) |
||
25 | { |
||
26 | $this->assertSame($publicSuffix, $this->psl->getPublicSuffix($hostPart)); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @dataProvider parseDataProvider |
||
31 | */ |
||
32 | public function testGetRegisterableDomain($url, $publicSuffix, $registerableDomain, $subdomain, $hostPart) |
||
33 | { |
||
34 | $this->assertSame($registerableDomain, $this->psl->getRegisterableDomain($hostPart)); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @dataProvider parseDataProvider |
||
39 | */ |
||
40 | public function testGetSubdomain($url, $publicSuffix, $registerableDomain, $subdomain, $hostPart) |
||
41 | { |
||
42 | $this->assertSame($subdomain, $this->psl->getSubdomain($hostPart)); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @dataProvider parseDataProvider |
||
47 | */ |
||
48 | public function testPHPparse_urlCanReturnCorrectHost($url, $publicSuffix, $registerableDomain, $subdomain, $hostPart) |
||
49 | { |
||
50 | $this->assertEquals($hostPart, parse_url('http://' . $hostPart, PHP_URL_HOST)); |
||
51 | } |
||
52 | |||
53 | public function parseDataProvider() |
||
54 | { |
||
55 | // $url, $publicSuffix, $registerableDomain, $subdomain, $hostPart |
||
56 | return array( |
||
57 | array('http://www.waxaudio.com.au/audio/albums/the_mashening', 'com.au', 'waxaudio.com.au', 'www', 'www.waxaudio.com.au'), |
||
58 | array('example.com', 'com', 'example.com', null, 'example.com'), |
||
59 | array('giant.yyyy', 'yyyy', 'giant.yyyy', null, 'giant.yyyy'), |
||
60 | array('cea-law.co.il', 'co.il', 'cea-law.co.il', null, 'cea-law.co.il'), |
||
61 | array('http://edition.cnn.com/WORLD/', 'com', 'cnn.com', 'edition', 'edition.cnn.com'), |
||
62 | array('http://en.wikipedia.org/', 'org', 'wikipedia.org', 'en', 'en.wikipedia.org'), |
||
63 | array('a.b.c.cy', 'c.cy', 'b.c.cy', 'a', 'a.b.c.cy'), |
||
64 | array('https://test.k12.ak.us', 'k12.ak.us', 'test.k12.ak.us', null, 'test.k12.ak.us'), |
||
65 | array('www.scottwills.co.uk', 'co.uk', 'scottwills.co.uk', 'www', 'www.scottwills.co.uk'), |
||
66 | array('b.ide.kyoto.jp', 'ide.kyoto.jp', 'b.ide.kyoto.jp', null, 'b.ide.kyoto.jp'), |
||
67 | array('a.b.example.uk.com', 'uk.com', 'example.uk.com', 'a.b', 'a.b.example.uk.com'), |
||
68 | array('test.nic.ar', 'ar', 'nic.ar', 'test', 'test.nic.ar'), |
||
69 | array('a.b.test.ck', 'test.ck', 'b.test.ck', 'a', 'a.b.test.ck'), |
||
70 | array('baez.songfest.om', 'om', 'songfest.om', 'baez', 'baez.songfest.om'), |
||
71 | array('politics.news.omanpost.om', 'om', 'omanpost.om', 'politics.news', 'politics.news.omanpost.om'), |
||
72 | array('http://localhost', null, null, null, 'localhost'), |
||
73 | ); |
||
74 | } |
||
75 | |||
76 | } |