public function testRewrite() { $asset = $this->createAssetMock(); $asset->expects($this->once())->method('getSourceRoot')->will($this->returnValue($sourceRoot = 'source_root')); $asset->expects($this->exactly(2))->method('getSourcePath')->will($this->returnValue($sourcePath = 'source_path')); $asset->expects($this->once())->method('getTargetPath')->will($this->returnValue($targetPath = 'target_path')); $reference = $this->createReference($path = 'foo.jpg'); $this->filesystem->expects($this->once())->method('exists')->with($this->identicalTo($absoluteSourcePath = $sourceRoot . DIRECTORY_SEPARATOR . $path))->will($this->returnValue(true)); $this->namer->expects($this->once())->method('name')->with($this->identicalTo($absoluteSourcePath))->will($this->returnValue($namedFile = 'named_file')); $webTargetPath = DIRECTORY_SEPARATOR . $this->rewriteDirectory . DIRECTORY_SEPARATOR . $namedFile; $this->filesystem->expects($this->once())->method($this->strategy)->with($this->identicalTo($absoluteSourcePath), $this->identicalTo($this->webDirectory . $webTargetPath), $this->isTrue()); $this->packages->expects($this->once())->method('getUrl')->with($this->identicalTo($webTargetPath))->will($this->returnValue($packagedPath = 'packaged_path')); $this->assertSame('url("' . $packagedPath . '")', $this->cssRewriter->rewrite($reference, $asset)); }