Failed Conditions
Pull Request — master (#63)
by Jonathan
03:31 queued 01:39
created

PublicSuffixListTest::parseDataProvider()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 29
nc 1
nop 0
dl 0
loc 31
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Purl\Test;
6
7
use PHPUnit\Framework\TestCase;
8
use Purl\Url;
9
10
class PublicSuffixListTest extends TestCase
11
{
12
    /**
13
     * @dataProvider parseDataProvider
14
     */
15
    public function testPublicSuffixListImplementation(
16
        string $url,
17
        ?string $publicSuffix,
18
        ?string $registerableDomain,
19
        ?string $subdomain
20
    ) : void {
21
        $url = new Url($url);
22
        $this->assertEquals($subdomain, $url->subdomain);
23
        $this->assertEquals($registerableDomain, $url->registerableDomain);
24
        $this->assertEquals($publicSuffix, $url->publicSuffix);
25
    }
26
27
    /**
28
     * @return mixed[]
29
     */
30
    public function parseDataProvider() : array
31
    {
32
        return [
33
            ['http://www.waxaudio.com.au/audio/albums/the_mashening', 'com.au', 'waxaudio.com.au', 'www', 'www.waxaudio.com.au'],
34
            ['example.COM', 'com', 'example.com', null, 'example.com'],
35
            ['giant.yyyy', 'yyyy', 'giant.yyyy', null, 'giant.yyyy'],
36
            ['cea-law.co.il', 'co.il', 'cea-law.co.il', null, 'cea-law.co.il'],
37
            ['http://edition.cnn.com/WORLD/', 'com', 'cnn.com', 'edition', 'edition.cnn.com'],
38
            ['http://en.wikipedia.org/', 'org', 'wikipedia.org', 'en', 'en.wikipedia.org'],
39
            ['a.b.c.cy', 'c.cy', 'b.c.cy', 'a', 'a.b.c.cy'],
40
            ['https://test.k12.ak.us', 'k12.ak.us', 'test.k12.ak.us', null, 'test.k12.ak.us'],
41
            ['www.scottwills.co.uk', 'co.uk', 'scottwills.co.uk', 'www', 'www.scottwills.co.uk'],
42
            ['b.ide.kyoto.jp', 'ide.kyoto.jp', 'b.ide.kyoto.jp', null, 'b.ide.kyoto.jp'],
43
            ['a.b.example.uk.com', 'uk.com', 'example.uk.com', 'a.b', 'a.b.example.uk.com'],
44
            ['test.nic.ar', 'ar', 'nic.ar', 'test', 'test.nic.ar'],
45
            ['a.b.test.ck', 'test.ck', 'b.test.ck', 'a', 'a.b.test.ck'],
46
            ['baez.songfest.om', 'om', 'songfest.om', 'baez', 'baez.songfest.om'],
47
            ['politics.news.omanpost.om', 'om', 'omanpost.om', 'politics.news', 'politics.news.omanpost.om'],
48
            ['us.example.com', 'com', 'example.com', 'us', 'us.example.com'],
49
            ['us.example.na', 'na', 'example.na', 'us', 'us.example.na'],
50
            ['www.example.us.na', 'us.na', 'example.us.na', 'www', 'www.example.us.na'],
51
            ['us.example.org', 'org', 'example.org', 'us', 'us.example.org'],
52
            ['webhop.broken.biz', 'biz', 'broken.biz', 'webhop', 'webhop.broken.biz'],
53
            ['www.broken.webhop.biz', 'webhop.biz', 'broken.webhop.biz', 'www', 'www.broken.webhop.biz'],
54
            ['//www.broken.webhop.biz', 'webhop.biz', 'broken.webhop.biz', 'www', 'www.broken.webhop.biz'],
55
            ['ftp://www.waxaudio.com.au/audio/albums/the_mashening', 'com.au', 'waxaudio.com.au', 'www', 'www.waxaudio.com.au'],
56
            ['ftps://test.k12.ak.us', 'k12.ak.us', 'test.k12.ak.us', null, 'test.k12.ak.us'],
57
            ['http://localhost', null, null, null, 'localhost'],
58
            ['test.museum', 'museum', 'test.museum', null, 'test.museum'],
59
            ['bob.smith.name', 'name', 'smith.name', 'bob', 'bob.smith.name'],
60
            ['tons.of.info', 'info', 'of.info', 'tons', 'tons.of.info'],
61
        ];
62
    }
63
}
64