Esempio n. 1
0
 public function testTempFileExists()
 {
     $filesystemMock = $this->getMock('Symfony\\Component\\Filesystem\\Filesystem');
     $filesystemMock->expects($this->once())->method('exists')->will($this->returnValue(true));
     $managerMock = $this->getMock('Neutron\\FormBundle\\Manager\\FileManagerInterface');
     $managerMock->expects($this->once())->method('getFileSystem')->will($this->returnValue($filesystemMock));
     $managerMock->expects($this->once())->method('getTempDir')->will($this->returnValue('/temp'));
     $file = new File();
     $file->setName('test.txt');
     $fileInfo = new FileInfo();
     $fileInfo->setFile($file);
     $fileInfo->setManager($managerMock);
     $this->assertTrue($fileInfo->tempFileExists());
 }
Esempio n. 2
0
 public function testRemoveAllFiles()
 {
     $filesystemMock = $this->getMock('Symfony\\Component\\Filesystem\\Filesystem');
     $filesystemMock->expects($this->exactly(2))->method('remove');
     $fileInfoMock = $this->getMock('Neutron\\FormBundle\\File\\fileInfoInterface');
     $fileInfoMock->expects($this->once())->method('getPathOfFile');
     $fileInfoMock->expects($this->once())->method('getPathOfTemporaryFile');
     $file = new File();
     $file->setName('test.txt');
     $manager = new FileManager();
     $manager->setFilesystem($filesystemMock);
     $manager->setFileInfo($fileInfoMock);
     $manager->setRootDir('root');
     $manager->setTempDir('temp');
     $manager->removeAllFiles($file);
 }