public function testWriteFile()
{
$filesystem = $this->getMock('League\\Flysystem\\FilesystemInterface');
$filesystem->expects($this->once())->method('writeStream')->will($this->returnValue(true));
$filesystem->expects($this->exactly(3))->method('delete')->will($this->returnValue(true));
$filesystem->expects($this->once())->method('rename')->will($this->returnValue(true));
$this->assertTrue($this->writer->writeFile($filesystem, $this->vfs->path('/tmp/tempfile'), 'path'));
$filesystem = $this->getMock('League\\Flysystem\\FilesystemInterface');
$filesystem->expects($this->once())->method('writeStream')->will($this->returnValue(false));
$filesystem->expects($this->exactly(2))->method('delete')->will($this->returnValue(true));
$filesystem->expects($this->never())->method('rename');
$this->assertFalse($this->writer->writeFile($filesystem, $this->vfs->path('/tmp/tempfile'), 'path'));
$filesystem = $this->getMock('League\\Flysystem\\FilesystemInterface');
$filesystem->expects($this->once())->method('writeStream')->will($this->returnValue(true));
$filesystem->expects($this->exactly(3))->method('delete')->will($this->returnValue(true));
$filesystem->expects($this->once())->method('rename')->will($this->returnValue(false));
$this->assertFalse($this->writer->writeFile($filesystem, $this->vfs->path('/tmp/tempfile'), 'path'));
}