/** * Project delete Succeed * * @return Void */ public function testProjectDeleteSucceed() { $evt = new SystemEvent_PROJECT_DELETE_TestVersion(); $evt->__construct('1', SystemEvent::TYPE_PROJECT_DELETE, SystemEvent::OWNER_ROOT, '142', SystemEvent::PRIORITY_HIGH, SystemEvent::STATUS_RUNNING, $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], ''); // The project $project = new MockProject(); $project->setReturnValue('usesCVS', true); $project->setReturnValue('usesSVN', true); $evt->setReturnValue('getProject', $project, array('142')); //Remove users from project $evt->setReturnValue('removeProjectMembers', true); $evt->setReturnValue('deleteMembershipRequestNotificationEntries', true); //Cleanup ProjectUGroup binding $evt->setReturnValue('cleanupProjectUgroupsBinding', true); //Cleanup FRS $evt->setReturnValue('cleanupProjectFRS', true); //Delete all trackers $atf = new MockArtifactTypeFactory(); $atf->setReturnValue('preDeleteAllProjectArtifactTypes', true); $evt->setReturnValue('getArtifactTypeFactory', $atf, array($project)); // System $backendSystem = new MockBackendSystem(); $backendSystem->setReturnValue('projectHomeExists', true); $backendSystem->setReturnValue('archiveProjectHome', true); $backendSystem->setReturnValue('archiveProjectFtp', true); $backendSystem->expectOnce('setNeedRefreshGroupCache'); $evt->setReturnValue('getBackend', $backendSystem, array('System')); // Wiki attachments $wa = new MockWikiAttachment(); $wa->setReturnValue('deleteProjectAttachments', true); $wa->expectOnce('deleteProjectAttachments'); $evt->setReturnValue('getWikiAttachment', $wa); // CVS $backendCVS = new MockBackendCVS(); $backendCVS->setReturnValue('repositoryExists', true); $backendCVS->setReturnValue('archiveProjectCVS', true); $backendCVS->expectOnce('setCVSRootListNeedUpdate'); $evt->setReturnValue('getBackend', $backendCVS, array('CVS')); // SVN $backendSVN = new MockBackendSVN(); $backendSVN->setReturnValue('repositoryExists', true); $backendSVN->setReturnValue('archiveProjectSVN', true); $backendSVN->expectOnce('setSVNApacheConfNeedUpdate'); $evt->setReturnValue('getBackend', $backendSVN, array('SVN')); // MailingList $backendMailingList = new MockBackendMailingList(); $backendMailingList->setReturnValue('deleteProjectMailingLists', true); $backendMailingList->expectOnce('deleteProjectMailingLists'); $evt->setReturnValue('getBackend', $backendMailingList, array('MailingList')); // Aliases $backendAliases = new MockBackendAliases(); $backendAliases->expectOnce('setNeedUpdateMailAliases'); $evt->setReturnValue('getBackend', $backendAliases, array('Aliases')); // Expect everything went OK $evt->expectOnce('done'); $evt->expectNever('error'); $em = new MockEventManager(); $evt->setReturnValue('getEventManager', $em); // Launch the event $this->assertTrue($evt->process()); }
public function testRenameSvnRepositoryFailure() { $evt = new SystemEvent_PROJECT_RENAME_TestVersion($this); $evt->__construct('1', SystemEvent::TYPE_PROJECT_RENAME, '142' . SystemEvent::PARAMETER_SEPARATOR . 'FooBar', SystemEvent::PRIORITY_HIGH, SystemEvent::STATUS_RUNNING, $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], ''); // The project $project = new MockProject($this); $project->setReturnValue('getUnixName', 'TestProj', array(false)); $project->setReturnValue('getUnixName', 'testproj', array(true)); $evt->setReturnValue('getProject', $project, array('142')); // SVN $backendSVN = new MockBackendSVN($this); $backendSVN->setReturnValue('repositoryExists', true); $backendSVN->setReturnValue('isNameAvailable', true); $backendSVN->expectOnce('renameSVNRepository', array($project, 'FooBar')); $backendSVN->setReturnValue('renameSVNRepository', array($project, 'FooBar'), array(false)); $backendSVN->expectNever('setSVNApacheConfNeedUpdate'); $evt->setReturnValue('getBackend', $backendSVN, array('SVN')); // CVS no rep, just ensure test $backendCVS = new MockBackendCVS($this); $backendCVS->setReturnValue('repositoryExists', false); $backendCVS->expectOnce('repositoryExists', false); $evt->setReturnValue('getBackend', $backendCVS, array('CVS')); // Project Home $backendSystem = new MockBackendSystem($this); $backendSystem->setReturnValue('projectHomeExists', false); $backendSystem->expectOnce('projectHomeExists', false); $backendSystem->expectNever('setNeedRefreshGroupCache'); // FRS $backendSystem->setReturnValue('renameFileReleasedDirectory', true); $backendSystem->expectOnce('renameFileReleasedDirectory', array($project, 'FooBar')); // FTP $backendSystem->setReturnValue('renameAnonFtpDirectory', true); $backendSystem->expectOnce('renameAnonFtpDirectory', array($project, 'FooBar')); $evt->setReturnValue('getBackend', $backendSystem, array('System')); // DB $evt->setReturnValue('updateDB', true); // Event $em = new MockEventManager($this); $em->expectOnce('processEvent', array('SystemEvent_PROJECT_RENAME', array('project' => $project, 'new_name' => 'FooBar'))); $evt->setReturnValue('getEventManager', $em); $evt->expectOnce('addProjectHistory', array('rename_with_error', 'TestProj :: FooBar (event n°1)', $project->getId())); // There is an error, the rename in not "done" $evt->expectNever('done'); $this->assertFalse($evt->process()); }
/** * ProjectUGroup modify Success * * @return Void */ public function testUgroupModifyProcessSuccess() { $evt = new SystemEvent_UGROUP_MODIFY_TestVersion(); $evt->__construct('1', SystemEvent::TYPE_UGROUP_MODIFY, SystemEvent::OWNER_ROOT, '1', SystemEvent::PRIORITY_HIGH, SystemEvent::STATUS_RUNNING, $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], ''); $evt->setReturnValue('getParametersAsArray', array(1, 2)); $evt->setReturnValue('processUgroupBinding', true); $project = new MockProject(); $project->setReturnValue('usesSVN', true); $evt->setReturnValue('getProject', $project, 1); $backendSVN = new MockBackendSVN(); $backendSVN->setReturnValue('updateSVNAccess', true); $backendSVN->expectOnce('updateSVNAccess'); $evt->setReturnValue('getBackend', $backendSVN, array('SVN')); $evt->expectOnce('getProject'); $evt->expectOnce('getBackend'); $evt->expectOnce('done'); $evt->expectNever('error'); // Launch the event $this->assertTrue($evt->process()); }