public function testGetVariationNotStoredHavingReferences()
{
$originalPath = 'foo/bar/image.jpg';
$variationName = 'my_variation';
$reference1 = 'reference1';
$reference2 = 'reference2';
$configVariation = array('reference' => $reference1);
$configReference1 = array('reference' => $reference2);
$configReference2 = array();
$this->filterConfiguration->set($variationName, $configVariation);
$this->filterConfiguration->set($reference1, $configReference1);
$this->filterConfiguration->set($reference2, $configReference2);
$imageId = '123-45';
$imageValue = new ImageValue(array('id' => $originalPath, 'imageId' => $imageId));
$field = new Field(array('value' => $imageValue));
$expectedUrl = "http://localhost/foo/bar/image_{$variationName}.jpg";
$this->ioResolver->expects($this->once())->method('isStored')->with($originalPath, $variationName)->will($this->returnValue(false));
$this->logger->expects($this->once())->method('debug');
$binary = $this->getMock('\\Liip\\ImagineBundle\\Binary\\BinaryInterface');
$this->dataLoader->expects($this->once())->method('find')->with($originalPath)->will($this->returnValue($binary));
// Filter manager is supposed to be called 3 times to generate references, and then passed variation.
$this->filterManager->expects($this->at(0))->method('applyFilter')->with($binary, $reference2)->will($this->returnValue($binary));
$this->filterManager->expects($this->at(1))->method('applyFilter')->with($binary, $reference1)->will($this->returnValue($binary));
$this->filterManager->expects($this->at(2))->method('applyFilter')->with($binary, $variationName)->will($this->returnValue($binary));
$this->ioResolver->expects($this->once())->method('store')->with($binary, $originalPath, $variationName);
$this->ioResolver->expects($this->once())->method('resolve')->with($originalPath, $variationName)->will($this->returnValue($expectedUrl));
$expected = new ImageVariation(array('name' => $variationName, 'fileName' => "image_{$variationName}.jpg", 'dirPath' => 'http://localhost/foo/bar', 'uri' => $expectedUrl, 'imageId' => $imageId));
$this->assertEquals($expected, $this->aliasGenerator->getVariation($field, new VersionInfo(), $variationName));
}