public function testUpdateSVNAccessFailure() { $evt = new SystemEvent_USER_RENAME_TestVersion($this); $evt->__construct('1', SystemEvent::TYPE_USER_RENAME, '142' . SystemEvent::PARAMETER_SEPARATOR . 'tazmani', SystemEvent::PRIORITY_HIGH, SystemEvent::STATUS_RUNNING, $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'], ''); // The user $user = new MockUser($this); $user->setReturnValue('getUserName', 'mickey'); $evt->setReturnValue('getUser', $user, array('142')); // System $backendSystem = new MockBackendSystem($this); $backendSystem->setReturnValue('userHomeExists', true); $backendSystem->setReturnValue('isUserNameAvailable', true); $backendSystem->setReturnValue('renameUserHomeDirectory', true); $backendSystem->expectOnce('renameUserHomeDirectory', array($user, 'tazmani')); $evt->setReturnValue('getBackend', $backendSystem, array('System')); // DB $evt->setReturnValue('updateDB', true); // CVS $backendCVS = new MockBackendCVS($this); $backendCVS->setReturnValue('updateCVSWritersForGivenMember', true); $evt->setReturnValue('getBackend', $backendCVS, array('CVS')); // SVN $backendSVN = new MockBackendSVN($this); $backendSVN->setReturnValue('updateSVNAccessForGivenMember', false); $evt->setReturnValue('getBackend', $backendSVN, array('SVN')); // There is an error, the rename is not "done" $evt->expectNever('done'); $this->assertFalse($evt->process()); // Check errors $this->assertEqual($evt->getStatus(), SystemEvent::STATUS_ERROR); $this->assertPattern('/Could not update SVN access files for the user/i', $evt->getLog()); }
/** * 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()); }
function testMultipleErrorLogs() { $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')); // Error in SVN $backendSVN = new MockBackendSVN($this); $backendSVN->setReturnValue('repositoryExists', true); $backendSVN->setReturnValue('isNameAvailable', false); $evt->setReturnValue('getBackend', $backendSVN, array('SVN')); // Error in CVS $backendCVS = new MockBackendCVS($this); $backendCVS->setReturnValue('repositoryExists', true); $backendCVS->setReturnValue('isNameAvailable', false); $evt->setReturnValue('getBackend', $backendCVS, array('CVS')); // System $backendSystem = new MockBackendSystem($this); $backendSystem->setReturnValue('projectHomeExists', false); //FRS $backendSystem->setReturnValue('renameFileReleasedDirectory', true); // FTP $backendSystem->setReturnValue('renameAnonFtpDirectory', true); $evt->setReturnValue('getBackend', $backendSystem, array('System')); // DB $evt->setReturnValue('updateDB', true); // Event $em = new MockEventManager($this); $evt->setReturnValue('getEventManager', $em); $evt->process(); $this->assertEqual($evt->getStatus(), SystemEvent::STATUS_ERROR); $this->assertPattern('/.*SVN repository.*not available/', $evt->getLog()); $this->assertPattern('/.*CVS repository.*not available/', $evt->getLog()); }
function testIsNameAvailableSystemFailure() { $r = new Rule_ProjectNameTestVersion(); $backendSVN = new MockBackendSVN($this); $backendSVN->setReturnValue('isNameAvailable', true, array('foobar')); $r->setReturnValue('_getBackend', $backendSVN, array('SVN')); $backendCVS = new MockBackendCVS($this); $backendCVS->setReturnValue('isNameAvailable', true, array('foobar')); $r->setReturnValue('_getBackend', $backendCVS, array('CVS')); $backendSystem = new MockBackendSystem($this); $backendSystem->setReturnValue('isProjectNameAvailable', false, array('foobar')); $r->setReturnValue('_getBackend', $backendSystem, array('System')); $this->assertFalse($r->isNameAvailable('foobar')); }