/** * @dataProvider mergeDataProvider */ public function testMerge($first_url, $second_url, array $expected_components) { $url_parser = new Parser($first_url); $url_parser->merge(new Parser($second_url)); foreach ($expected_components as $expected_component => $expected_value) { $this->assertEquals($expected_value, $url_parser->getComponent($expected_component), 'The "' . $expected_component . '" has expected value.'); } }
/** * Returns normalized url. * * @param PageUrlAnnotation $annotation The page url annotation. * * @return array */ public function normalize(PageUrlAnnotation $annotation) { $parser = new Parser($this->baseUrl); $parser->merge(new Parser($annotation->url)); $parser->setParams(array_merge($parser->getParams(), $annotation->params)); $ret = $parser->getComponents(); if ($annotation->secure !== null && !empty($ret['scheme'])) { $ret['scheme'] = $annotation->secure ? 'https' : 'http'; } return $ret; }
/** * @dataProvider mergeDataProvider */ public function testMerge($first_url, $second_url, $expected_component, $expected_value) { $url_parser = new Parser($first_url); $url_parser->merge(new Parser($second_url)); $this->assertEquals($expected_value, $url_parser->getComponent($expected_component)); }