| Total Complexity | 4 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class ParserTest extends TestCase |
||
| 14 | { |
||
| 15 | /** @var Parser */ |
||
| 16 | private $parser; |
||
| 17 | |||
| 18 | protected function setUp() : void |
||
| 19 | { |
||
| 20 | parent::setUp(); |
||
| 21 | $pslManager = new PublicSuffixListManager(dirname(__DIR__, 2)) . '/data'); |
||
|
|
|||
| 22 | $pslParser = new PslParser($pslManager->getList()); |
||
| 23 | $this->parser = new Parser($pslParser); |
||
| 24 | } |
||
| 25 | |||
| 26 | protected function tearDown() : void |
||
| 27 | { |
||
| 28 | $this->parser = null; |
||
| 29 | parent::tearDown(); |
||
| 30 | } |
||
| 31 | |||
| 32 | public function testParseUrl() : void |
||
| 33 | { |
||
| 34 | $parts = $this->parser->parseUrl('https://sub.domain.jwage.com:443/about?param=value#fragment?param=value'); |
||
| 35 | $this->assertEquals([ |
||
| 36 | 'scheme' => 'https', |
||
| 37 | 'host' => 'sub.domain.jwage.com', |
||
| 38 | 'port' => 443, |
||
| 39 | 'user' => null, |
||
| 40 | 'pass' => null, |
||
| 41 | 'path' => '/about', |
||
| 42 | 'query' => 'param=value', |
||
| 43 | 'fragment' => 'fragment?param=value', |
||
| 44 | 'publicSuffix' => 'com', |
||
| 45 | 'registerableDomain' => 'jwage.com', |
||
| 46 | 'subdomain' => 'sub.domain', |
||
| 47 | 'canonical' => 'com.jwage.domain.sub/about?param=value', |
||
| 48 | 'resource' => '/about?param=value', |
||
| 49 | ], $parts); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @expectedException \InvalidArgumentException |
||
| 54 | * @expectedExceptionMessage Invalid url http:///example.com |
||
| 55 | */ |
||
| 56 | public function testParseBadUrlThrowsInvalidArgumentException() : void |
||
| 57 | { |
||
| 58 | $this->parser->parseUrl('http:///example.com/one/two?one=two#value'); |
||
| 59 | } |
||
| 61 |