function testUpdateShouldUpdateAllProjects() { $id = 1002; $type = LDAP_UserManager::EVENT_UPDATE_LOGIN; $parameters = '101::102'; $priority = SystemEvent::PRIORITY_MEDIUM; $status = SystemEvent::STATUS_RUNNING; $create_date = ''; $process_date = ''; $end_date = ''; $log = ''; $se = TestHelper::getPartialMock('SystemEvent_PLUGIN_LDAP_UPDATE_LOGIN', array('getUserManager', 'getBackendSVN', 'getProject')); $user1 = new MockUser(); $user1->setReturnValue('getAllProjects', array(201, 202)); $user1->setReturnValue('isActive', true); $user2 = new MockUser(); $user2->setReturnValue('getAllProjects', array(202, 203)); $user2->setReturnValue('isActive', true); $um = new MockUserManager(); $um->setReturnValue('getUserById', $user1, array('101')); $um->setReturnValue('getUserById', $user2, array('102')); $se->setReturnValue('getUserManager', $um); $prj1 = new MockProject(); $prj2 = new MockProject(); $prj3 = new MockProject(); $se->setReturnValue('getProject', $prj1, array(201)); $se->setReturnValue('getProject', $prj2, array(202)); $se->setReturnValue('getProject', $prj3, array(203)); $backend = new MockBackendSVN(); $backend->expectCallCount('updateProjectSVNAccessFile', 3); $backend->expect('updateProjectSVNAccessFile', array($prj1)); $backend->expect('updateProjectSVNAccessFile', array($prj2)); $backend->expect('updateProjectSVNAccessFile', array($prj3)); $se->setReturnValue('getBackendSVN', $backend); $se->__construct($id, $type, $parameters, $priority, $status, $create_date, $process_date, $end_date, $log); $se->process(); }
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()); }
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()); }
/** * 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()); }
/** * 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()); }
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')); }