/** * @dataProvider provideServerVars */ public function testUriMethods($server, $expectedRequestUri, $expectedBaseUrl, $expectedPathInfo) { $request = new ApacheRequest(); $request->server->replace($server); $this->assertEquals($expectedRequestUri, $request->getRequestUri(), '->getRequestUri() is correct'); $this->assertEquals($expectedBaseUrl, $request->getBaseUrl(), '->getBaseUrl() is correct'); $this->assertEquals($expectedPathInfo, $request->getPathInfo(), '->getPathInfo() is correct'); }
<?php use Symfony\Component\ClassLoader\ApcClassLoader; use Symfony\Component\HttpFoundation\ApacheRequest; umask(00); $loader = (require_once __DIR__ . '/../app/bootstrap.php.cache'); $loader = new ApcClassLoader('SymfonyBigaEdition', $loader); $loader->register(true); require_once __DIR__ . '/../app/AppKernel.php'; $kernel = new AppKernel('prod', false); $kernel->loadClassCache(); $response = $kernel->handle($request = ApacheRequest::createFromGlobals()); $response->send(); $kernel->terminate($request, $response);
public function testGetBaseUrlIncludesScriptName() { $request = new ApacheRequest(); $request->server->replace(array('REQUEST_URI' => '/index.php/foo/bar', 'SCRIPT_NAME' => '/index.php')); $this->assertEquals('/index.php', $request->getBaseUrl(), '->getBaseUrl() includes the script name'); }