Example #1
0
 function testRestoreFileInDeletedRelease()
 {
     $fileFactory = new FRSFileFactoryTestRestore();
     // Create temp file
     $filepath = dirname(__FILE__) . '/_fixtures/DELETED/prj/p3_r1/toto.xls.12';
     mkdir(dirname($filepath), 0750, true);
     touch($filepath);
     $this->assertTrue(is_dir(dirname($filepath)));
     $release = new MockFRSRelease($this);
     $release->setReturnValue('isDeleted', true);
     $releaseFactory = new MockFRSReleaseFactory($this);
     $releaseFactory->setReturnValue('getFRSReleaseFromDb', $release);
     $fileFactory->setReturnValue('_getFRSReleaseFactory', $releaseFactory);
     $dao = new MockFRSFileDao($this);
     $dao->expectOnce('cancelRestore');
     $fileFactory->setReturnValue('_getFRSFileDao', $dao);
     $file = new MockFRSFile($this);
     $backend = new MockBackendSystem($this);
     $this->assertFalse($fileFactory->restoreFile($file, $backend));
     $this->assertTrue(is_dir(dirname($filepath)));
     $this->assertFalse(file_exists($GLOBALS['ftp_frs_dir_prefix'] . '/prj/p3_r1/toto.xls'));
     $this->assertFalse(is_dir($GLOBALS['ftp_frs_dir_prefix'] . '/prj/p3_r1'));
     // Cleanup
     unlink($GLOBALS['ftp_frs_dir_prefix'] . '/DELETED/prj/p3_r1/toto.xls.12');
     rmdir($GLOBALS['ftp_frs_dir_prefix'] . '/DELETED/prj/p3_r1');
     rmdir($GLOBALS['ftp_frs_dir_prefix'] . '/DELETED/prj');
 }
Example #2
0
 /**
  * Testing creation of file succeed
  */
 function testCreateFilesucceed()
 {
     $webDAVFRSRelease = new WebDAVFRSReleaseTestVersion($this);
     $webDAVFRSRelease->setReturnValue('userCanWrite', true);
     $frsff = new MockFRSFileFactory();
     $frsff->setReturnValue('isFileBaseNameExists', false);
     $frsff->setReturnValue('createFile', true);
     $release = new MockFRSRelease($this);
     $release->setReturnValue('getReleaseID', 1234);
     $webDAVFRSRelease->setReturnValue('getRelease', $release);
     $frsrf = new MockFRSReleaseFactory($this);
     $frsrf->expectOnce('emailNotification');
     $utils = new MockWebDAVUtils();
     $utils->setReturnValue('getFileFactory', $frsff);
     $utils->setReturnValue('getIncomingFileSize', 64);
     $utils->setReturnValue('getReleaseFactory', $frsrf);
     $project = new MockProject();
     $webDAVFRSRelease->setReturnValue('getProject', $project);
     $user = new MockUser();
     $webDAVFRSRelease->setReturnValue('getUser', $user);
     $webDAVFRSRelease->setReturnValue('getUtils', $utils);
     $data = fopen(dirname(__FILE__) . '/_fixtures/test.txt', 'r');
     $webDAVFRSRelease->setReturnValue('getMaxFileSize', 64);
     $webDAVFRSRelease->createFile('release', $data);
 }