public function testCreatedObjectOnAmazon() { $binary = new Binary('aContent', 'image/jpeg', 'jpeg'); $s3 = $this->createAmazonS3Mock(); $s3->expects($this->once())->method('create_object')->will($this->returnValue($this->createCFResponseMock(true))); $resolver = new AmazonS3Resolver($s3, 'images.example.com'); $resolver->store($binary, 'foobar.jpg', 'thumb'); }
public function testCreatedObjectRedirects() { $response = new Response(); $response->setContent('foo'); $response->headers->set('Content-Type', 'image/jpeg'); $s3 = $this->getMock('AmazonS3'); $s3->expects($this->once())->method('create_object')->will($this->returnValue($this->getS3ResponseMock(true))); $s3->expects($this->once())->method('get_object_url')->with('images.example.com', 'thumb/foobar.jpg', 0, array())->will($this->returnValue('http://images.example.com/thumb/foobar.jpg')); $resolver = new AmazonS3Resolver($s3, 'images.example.com'); $this->assertSame($response, $resolver->store($response, 'thumb/foobar.jpg', 'thumb')); $this->assertEquals(301, $response->getStatusCode()); $this->assertEquals('http://images.example.com/thumb/foobar.jpg', $response->headers->get('Location')); }