function testSetNameSuccess() { $webDAVDocmanDocument = new WebDAVDocmanDocumentTestVersion(); $utils = new MockWebDAVUtils(); $utils->setReturnValue('isWriteEnabled', true); $utils->expectOnce('processDocmanRequest'); $webDAVDocmanDocument->setReturnValue('getUtils', $utils); $project = new MockProject(); $webDAVDocmanDocument->setReturnValue('getProject', $project); $item = new MockDocman_Item(); $webDAVDocmanDocument->setReturnValue('getItem', $item); $webDAVDocmanDocument->setName('newName'); }
/** * Testing succeeded delete */ function testDeleteSucceede() { $webDAVFile = new WebDAVFRSFileTestVersion($this); $webDAVFile->setReturnValue('userCanWrite', true); $frsff = new MockFRSFileFactory(); $frsff->setReturnValue('delete_file', 1); $utils = new MockWebDAVUtils(); $utils->setReturnValue('getFileFactory', $frsff); $project = new MockProject(); $webDAVFile->setReturnValue('getProject', $project); $webDAVFile->setReturnValue('getUtils', $utils); $webDAVFile->delete(); }
/** * Testing creation of package succeed */ function testCreateDirectorysucceed() { $webDAVFRS = new WebDAVFRSTestVersion($this); $webDAVFRS->setReturnValue('userCanWrite', true); $frspf = new MockFRSPackageFactory(); $frspf->setReturnValue('isPackageNameExist', false); $utils = new MockWebDAVUtils(); $utils->setReturnValue('getPackageFactory', $frspf); $pm = new MockPermissionsManager(); $utils->setReturnValue('getPermissionsManager', $pm); $webDAVFRS->setReturnValue('getUtils', $utils); $webDAVFRS->createDirectory('pkg'); }
function testCreateFileSucceed() { $webDAVDocmanFolder = new WebDAVDocmanFolderTestVersion(); $utils = new MockWebDAVUtils(); $utils->setReturnValue('isWriteEnabled', true); $utils->expectOnce('processDocmanRequest'); $webDAVDocmanFolder->setReturnValue('getUtils', $utils); $project = new MockProject(); $webDAVDocmanFolder->setReturnValue('getProject', $project); $item = new MockDocman_Item(); $webDAVDocmanFolder->setReturnValue('getItem', $item); $webDAVDocmanFolder->setReturnValue('getMaxFileSize', 2000); $data = fopen(dirname(__FILE__) . '/_fixtures/test.txt', 'r'); $webDAVDocmanFolder->createFile('name', $data); }
/** * 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); }
/** * Testing creation of release succeed */ function testCreateDirectorysucceed() { // Values we expect for the package to create $refPackageToCreate = array('name' => 'release', 'package_id' => 42, 'notes' => '', 'changes' => '', 'status_id' => 1); // Values we expect for the package once created $refPackage = $refPackageToCreate; $refPackage['release_id'] = 15; $webDAVFRSPackage = new WebDAVFRSPackageTestVersion($this); $webDAVFRSPackage->setReturnValue('getPackageId', 42); $webDAVFRSPackage->setReturnValue('userCanWrite', true); $frsrf = new MockFRSReleaseFactory(); $frsrf->setReturnValue('isReleaseNameExist', false); $frsrf->expectOnce('create', array($refPackageToCreate)); $frsrf->setReturnValue('create', 15); $frsrf->expectOnce('setDefaultPermissions', array(new FRSRelease($refPackage))); $utils = new MockWebDAVUtils(); $utils->setReturnValue('getReleaseFactory', $frsrf); $pm = new MockPermissionsManager(); $utils->setReturnValue('getPermissionsManager', $pm); $webDAVFRSPackage->setReturnValue('getUtils', $utils); $webDAVFRSPackage->createDirectory('release'); }
function testMoveDocmanWrongDestinationItemType() { $tree = new TestTreeTestVersion(); $utils = new MockWebDAVUtils(); $utils->setReturnValue('isWriteEnabled', true); $tree->setReturnValue('getUtils', $utils); $destination = new TestDocmanFile(); $tree->setReturnValue('getNodeForPath', $destination, array('destination')); $source = new TestFolder(); $tree->setReturnValue('getNodeForPath', $source, array('source')); $sourceItem = new MockDocman_Item(); $source->setItem($sourceItem); $destinationItem = new MockDocman_Item(); $destination->setItem($destinationItem); $dpm = new MockDocman_PermissionsManager(); $this->expectException('Sabre_DAV_Exception_MethodNotAllowed'); $tree->move('source', 'destination/item'); }