public function testWriteAssetWithVars() {
$asset = $this
->getMock('Assetic\\Asset\\AssetInterface');
$asset
->expects($this
->atLeastOnce())
->method('getVars')
->will($this
->returnValue(array(
'locale',
)));
$self = $this;
$expectedValues = array(
array(
'locale' => 'en',
),
array(
'locale' => 'de',
),
array(
'locale' => 'fr',
),
);
$asset
->expects($this
->exactly(3))
->method('setValues')
->will($this
->returnCallback(function ($values) use ($self, $expectedValues) {
static $counter = 0;
$self
->assertEquals($expectedValues[$counter++], $values);
}));
$asset
->expects($this
->exactly(3))
->method('getValues')
->will($this
->returnCallback(function () use ($expectedValues) {
static $counter = 0;
return $expectedValues[$counter++];
}));
$asset
->expects($this
->exactly(3))
->method('dump')
->will($this
->onConsecutiveCalls('en', 'de', 'fr'));
$asset
->expects($this
->atLeastOnce())
->method('getTargetPath')
->will($this
->returnValue('target.{locale}'));
$this->writer
->writeAsset($asset);
$this
->assertFileExists($this->dir . '/target.en');
$this
->assertFileExists($this->dir . '/target.de');
$this
->assertFileExists($this->dir . '/target.fr');
$this
->assertEquals('en', file_get_contents($this->dir . '/target.en'));
$this
->assertEquals('de', file_get_contents($this->dir . '/target.de'));
$this
->assertEquals('fr', file_get_contents($this->dir . '/target.fr'));
}