/** * @depends testMissingRewrite * @depends testResolveWithBasePath */ public function testMissingRewriteWithBasePathWithScriptname() { $this->cacheManager->expects($this->atLeastOnce())->method('generateUrl')->will($this->returnValue('/sandbox/app_dev.php/media/cache/thumbnail/cats.jpeg')); $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request'); $request->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/sandbox')); $request->expects($this->atLeastOnce())->method('getBaseUrl')->will($this->returnValue('/sandbox/app_dev.php')); // The file has already been cached by this resolver. $targetPath = $this->resolver->resolve($request, 'cats.jpeg', 'thumbnail'); $this->filesystem->mkdir(dirname($targetPath)); file_put_contents($targetPath, file_get_contents($this->dataRoot . '/cats.jpeg')); $response = $this->resolver->resolve($request, 'cats.jpeg', 'thumbnail'); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response, '->resolve() returns a Response instance if the target file already exists.'); $this->assertEquals(302, $response->getStatusCode(), '->resolve() returns the HTTP response code "302 - Found".'); $this->assertEquals('/sandbox/media/cache/thumbnail/cats.jpeg', $response->headers->get('Location'), '->resolve() returns the expected Location of the cached image.'); }
public function testComposeSchemaHttpsAndCustomPortAndFileUrlOnResolve() { $requestContext = new RequestContext(); $requestContext->setScheme('https'); $requestContext->setHost('thehost'); $requestContext->setHttpsPort(444); $resolver = new WebPathResolver($this->createFilesystemMock(), $requestContext, '/aWebRoot', 'aCachePrefix'); $this->assertEquals('https://thehost:444/aCachePrefix/aFilter/aPath', $resolver->resolve('aPath', 'aFilter')); }