/** * @dataProvider getCurrentUrlWithoutFilename * @group Core */ public function testGetCurrentUrlWithoutFilename($expected, $https, $host, $path) { $this->resetGlobalVariables(); if ($https) { $_SERVER['HTTPS'] = $https; } else { unset($_SERVER['HTTPS']); } $_SERVER['REQUEST_URI'] = $path; $_SERVER['HTTP_HOST'] = $host; Config::getInstance()->General['trusted_hosts'] = array($host); $url = Url::getCurrentUrlWithoutFilename(); $this->assertEquals($expected, $url); }
/** * @dataProvider getCurrentUrlWithoutFilename * @group Core */ public function testGetCurrentUrlWithoutFilename($expected, $https, $host, $path) { $names = array('PATH_INFO', 'REQUEST_URI', 'SCRIPT_NAME', 'SCRIPT_FILENAME', 'argv', 'HTTPS', 'HTTP_HOST', 'QUERY_STRING', 'HTTP_REFERER'); foreach ($names as $name) { unset($_SERVER[$name]); } if ($https) { $_SERVER['HTTPS'] = $https; } else { unset($_SERVER['HTTPS']); } $_SERVER['REQUEST_URI'] = $path; $_SERVER['HTTP_HOST'] = $host; Config::getInstance()->General['trusted_hosts'] = array($host); $url = Url::getCurrentUrlWithoutFilename(); $this->assertEquals($expected, $url); }