public function RequestTest::testGetUri in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/http-foundation/Tests/RequestTest.php \Symfony\Component\HttpFoundation\Tests\RequestTest::testGetUri()
- 8 vendor/symfony/browser-kit/Tests/RequestTest.php \Symfony\Component\BrowserKit\Tests\RequestTest::testGetUri()
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/Tests/RequestTest.php \Symfony\Component\HttpFoundation\Tests\RequestTest::testGetUri()
@covers Symfony\Component\HttpFoundation\Request::getUri
File
- vendor/
symfony/ http-foundation/ Tests/ RequestTest.php, line 368
Class
Namespace
Symfony\Component\HttpFoundation\TestsCode
public function testGetUri() {
$server = array();
// Standard Request on non default PORT
// http://host:8080/index.php/path/info?query=string
$server['HTTP_HOST'] = 'host:8080';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '8080';
$server['QUERY_STRING'] = 'query=string';
$server['REQUEST_URI'] = '/index.php/path/info?query=string';
$server['SCRIPT_NAME'] = '/index.php';
$server['PATH_INFO'] = '/path/info';
$server['PATH_TRANSLATED'] = 'redirect:/index.php/path/info';
$server['PHP_SELF'] = '/index_dev.php/path/info';
$server['SCRIPT_FILENAME'] = '/some/where/index.php';
$request = new Request();
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://host:8080/index.php/path/info?query=string', $request
->getUri(), '->getUri() with non default port');
// Use std port number
$server['HTTP_HOST'] = 'host';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '80';
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://host/index.php/path/info?query=string', $request
->getUri(), '->getUri() with default port');
// Without HOST HEADER
unset($server['HTTP_HOST']);
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '80';
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://servername/index.php/path/info?query=string', $request
->getUri(), '->getUri() with default port without HOST_HEADER');
// Request with URL REWRITING (hide index.php)
// RewriteCond %{REQUEST_FILENAME} !-f
// RewriteRule ^(.*)$ index.php [QSA,L]
// http://host:8080/path/info?query=string
$server = array();
$server['HTTP_HOST'] = 'host:8080';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '8080';
$server['REDIRECT_QUERY_STRING'] = 'query=string';
$server['REDIRECT_URL'] = '/path/info';
$server['SCRIPT_NAME'] = '/index.php';
$server['QUERY_STRING'] = 'query=string';
$server['REQUEST_URI'] = '/path/info?toto=test&1=1';
$server['SCRIPT_NAME'] = '/index.php';
$server['PHP_SELF'] = '/index.php';
$server['SCRIPT_FILENAME'] = '/some/where/index.php';
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://host:8080/path/info?query=string', $request
->getUri(), '->getUri() with rewrite');
// Use std port number
// http://host/path/info?query=string
$server['HTTP_HOST'] = 'host';
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '80';
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://host/path/info?query=string', $request
->getUri(), '->getUri() with rewrite and default port');
// Without HOST HEADER
unset($server['HTTP_HOST']);
$server['SERVER_NAME'] = 'servername';
$server['SERVER_PORT'] = '80';
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://servername/path/info?query=string', $request
->getUri(), '->getUri() with rewrite, default port without HOST_HEADER');
// With encoded characters
$server = array(
'HTTP_HOST' => 'host:8080',
'SERVER_NAME' => 'servername',
'SERVER_PORT' => '8080',
'QUERY_STRING' => 'query=string',
'REQUEST_URI' => '/ba%20se/index_dev.php/foo%20bar/in+fo?query=string',
'SCRIPT_NAME' => '/ba se/index_dev.php',
'PATH_TRANSLATED' => 'redirect:/index.php/foo bar/in+fo',
'PHP_SELF' => '/ba se/index_dev.php/path/info',
'SCRIPT_FILENAME' => '/some/where/ba se/index_dev.php',
);
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request
->getUri());
// with user info
$server['PHP_AUTH_USER'] = 'fabien';
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request
->getUri());
$server['PHP_AUTH_PW'] = 'symfony';
$request
->initialize(array(), array(), array(), array(), array(), $server);
$this
->assertEquals('http://host:8080/ba%20se/index_dev.php/foo%20bar/in+fo?query=string', $request
->getUri());
}