Example #1
0
 public function testReturnResolvedImageUrlOnResolve()
 {
     $s3 = $this->getS3ClientMock();
     $s3->expects($this->once())->method('getObjectUrl')->with('images.example.com', 'thumb/some-folder/path.jpg', 0, array())->will($this->returnValue('http://images.example.com/some-folder/path.jpg'));
     $resolver = new AwsS3Resolver($s3, 'images.example.com');
     $this->assertEquals('http://images.example.com/some-folder/path.jpg', $resolver->resolve('/some-folder/path.jpg', 'thumb'));
 }
 public function testResolveRedirectsOnExisting()
 {
     $s3 = $this->getMock('Aws\\S3\\S3Client');
     $s3->expects($this->once())->method('doesObjectExist')->will($this->returnValue(true));
     $s3->expects($this->once())->method('getObjectUrl')->with('images.example.com', 'thumb/some-folder/targetpath.jpg', 0, array())->will($this->returnValue('http://images.example.com/some-folder/targetpath.jpg'));
     $resolver = new AwsS3Resolver($s3, 'images.example.com');
     $response = $resolver->resolve(new Request(), '/some-folder/targetpath.jpg', 'thumb');
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertEquals(301, $response->getStatusCode());
     $this->assertEquals('http://images.example.com/some-folder/targetpath.jpg', $response->headers->get('Location'));
 }