function testSendNotificationsFirstIsFailure()
 {
     $feedback = new MockFeedback($this);
     // First message fail
     $mail1 = new MockMail($this);
     $mail1->setReturnValue('send', false);
     // Second succeed
     $mail2 = new MockMail($this);
     $mail2->setReturnValue('send', true);
     // Raises an error
     $feedback->expectOnce('log', array('warning', '*'));
     $project = new MockProject($this);
     $project->setReturnValue('getPublicName', 'Guinea Pig');
     $itemFty = new MockDocman_ItemFactory($this);
     $notifDao = new MockNotificationsDao($this);
     $nm = new Docman_NotificationsManager_TestVersion($this);
     $nm->setReturnValue('_getDao', $notifDao);
     $nm->setReturnValue('_getItemFactory', $itemFty);
     $nm->setReturnValue('_groupGetObject', $project);
     $nm->setReturnValueAt(0, '_getMail', $mail1);
     $nm->setReturnValueAt(1, '_getMail', $mail2);
     $nm->__construct(101, '/toto', $feedback);
     $user = new MockUser($this);
     $user->setReturnValue('getEmail', '*****@*****.**');
     $nm->_messages[] = array('title' => 'Move 1', 'content' => 'Changed 1', 'to' => array($user));
     $nm->_messages[] = array('title' => 'Move 2', 'content' => 'Changed 2', 'to' => array($user));
     $nm->sendNotifications('', '');
 }
 public function testExecutes_ForkCrossProject_ActionWithForkRepositoriesView()
 {
     $groupId = 101;
     $toProjectId = 100;
     $toProject = new MockProject();
     $toProject->setReturnValue('getId', $toProjectId);
     $repo = new GitRepository();
     $repos = array($repo);
     $repo_ids = array(200);
     $user = new MockUser();
     $user->setReturnValue('isMember', true);
     $usermanager = new MockUserManager();
     $usermanager->setReturnValue('getCurrentUser', $user);
     $projectManager = new MockProjectManager();
     $projectManager->setReturnValue('getProject', $toProject, array($toProjectId));
     $repositoryFactory = new MockGitRepositoryFactory();
     $repositoryFactory->setReturnValue('getRepositoryById', $repo, array($repo_ids[0]));
     $request = new Codendi_Request(array('choose_destination' => 'project', 'to_project' => $toProjectId, 'repos' => $repo_ids));
     $git = TestHelper::getPartialMock('Git', array('definePermittedActions', '_informAboutPendingEvents', 'addAction', 'addView', 'checkSynchronizerToken'));
     $git->setGroupId($groupId);
     $git->setRequest($request);
     $git->setUserManager($usermanager);
     $git->setProjectManager($projectManager);
     $git->setFactory($repositoryFactory);
     $git->expectCallCount('addAction', 2);
     $git->expectAt(0, 'addAction', array('fork', array($repos, $toProject, '', GitRepository::REPO_SCOPE_PROJECT, $user, $GLOBALS['HTML'], '/plugins/git/?group_id=100')));
     $git->expectAt(1, 'addAction', array('getProjectRepositoryList', array($groupId)));
     $git->expectOnce('addView', array('forkRepositories'));
     $git->_dispatchActionAndView('do_fork_repositories', null, null, $user);
 }
 function setUp()
 {
     $this->project_id = 110;
     $project = new MockProject();
     $project->setReturnValue('getId', $this->project_id);
     $this->tracker = aTracker()->withId(1)->withProject($project)->build();
     $this->child = aTracker()->withId(2)->build();
     $this->children = array($this->child);
     $this->hierarchical_tracker = new Tracker_Hierarchy_HierarchicalTracker($this->tracker, $this->children);
 }
 function testGetRepositoryFromFullPathAndGitRoot()
 {
     $dao = new MockGitDao();
     $projectManager = new MockProjectManager();
     $project = new MockProject();
     $project->setReturnValue('getID', 101);
     $project->setReturnValue('getUnixName', 'garden');
     $projectManager->setReturnValue('getProjectByUnixName', $project, array('garden'));
     $factory = new GitRepositoryFactory($dao, $projectManager);
     $dao->expectOnce('searchProjectRepositoryByPath', array(101, 'garden/diskinstaller.git'));
     $dao->setReturnValue('searchProjectRepositoryByPath', new MockDataAccessResult());
     $factory->getFromFullPath('/data/tuleap/gitroot/garden/diskinstaller.git');
 }
示例#5
0
 public function testArchiveCreatesATarGz()
 {
     $this->GivenThereIsARepositorySetUp();
     $project = new MockProject();
     $project->setReturnValue('getUnixName', 'zorblub');
     $repo = new MockGitRepository();
     $repo->setReturnValue('getPath', 'gitolite-admin-ref');
     $repo->setReturnValue('getName', 'gitolite-admin-ref');
     $repo->setReturnValue('getDeletionDate', '2012-01-26');
     $repo->setReturnValue('getProject', $project);
     $backend = new GitBackendTestVersion();
     $backend->setGitRootPath($this->_tmpDir);
     $backend->setGitBackupDir($this->backupDir);
     $backend->archive($repo);
     $this->ThenCleanTheWorkspace();
 }
 public function testRemoveMailByProjectPrivateRepositoryErrorDaoRemoving()
 {
     $prm = new PostReceiveMailManagerTestVersion();
     $user = mock('PFUser');
     $user->setReturnValue('isMember', False);
     $user->setReturnValue('getEmail', "*****@*****.**");
     $prj = new MockProject($this);
     $prj->setReturnValue('getId', 1750);
     $repositoryList = array(array('project_id' => '1750', 'repository_id' => 2515));
     $gitDao = new MockGitDao($this);
     $prm->setReturnValue('_getGitDao', $gitDao);
     $gitDao->setReturnValue('getProjectRepositoryList', $repositoryList);
     foreach ($repositoryList as $row) {
         $repo = new MockGitRepository($this);
         $prm->setReturnValue('_getGitRepository', $repo);
         $repo->setReturnValue('isPrivate', True);
         $repo->setReturnValue('load', True);
         $backend = new MockGitBackend();
         $repo->SetReturnValue('getBackend', $backend);
     }
     $prm->setReturnValue('removeMailByRepository', False);
     $GLOBALS['Language']->setReturnValue('getText', 'Mail not removed');
     $GLOBALS['Response']->expectOnce('addFeedback', array('error', $GLOBALS['Language']->getText('plugin_git', 'dao_error_remove_notification')));
     $prm->removeMailByProjectPrivateRepository($prj->getId(), $user);
 }
示例#7
0
 function testRenameProjectTest()
 {
     $rem = new Docman_VersionFactoryTestVersion2($this);
     $docman_root = dirname(__FILE__) . '/../tests/_fixtures/docman/';
     $old_name = 'toto';
     $new_name = 'TestProj';
     mkdir($docman_root . $old_name);
     $project = new MockProject($this);
     $project->setReturnValue('getUnixName', $old_name, array(true));
     $fact = new Docman_VersionFactoryTestVersion2($this);
     $this->assertEqual(rename($docman_root . $old_name, $docman_root . $new_name), true);
     $dao = new MockDocman_VersionDao($fact);
     $fact->setReturnValue('_getVersionDao', $dao);
     $dao->setReturnValue('renameProject', true, array($docman_root, $project, $new_name));
     $this->assertFalse(is_dir($docman_root . $old_name), "Docman old rep should be renamed");
     $this->assertTrue(is_dir($docman_root . $new_name), "Docman new Rep should be created");
     rmdir($docman_root . "/" . $new_name);
 }
 function testSendNotificationsSuccess()
 {
     $mail = new MockMail($this);
     $mail->setReturnValue('send', true);
     $feedback = new MockFeedback($this);
     $project = new MockProject($this);
     $project->setReturnValue('getPublicName', 'Guinea Pig');
     $itemFty = new MockDocman_ItemFactory($this);
     $notifDao = new MockNotificationsDao($this);
     $project = aMockProject()->withId(101)->build();
     $mail_builder = new MailBuilder(TemplateRendererFactory::build());
     $nm = new Docman_NotificationsManager_TestVersion($this);
     $nm->setReturnValue('_getDao', $notifDao);
     $nm->setReturnValue('_getItemFactory', $itemFty);
     $nm->setReturnValue('_groupGetObject', $project);
     $nm->__construct($project, '/toto', $feedback, $mail_builder);
     $user = mock('PFUser');
     $user->setReturnValue('getEmail', '*****@*****.**');
     $nm->_messages = array(array('title' => 'Move', 'content' => 'Changed', 'to' => array($user)));
     $nm->sendNotifications('', '');
 }
示例#9
0
 private function GivenAnElementWithManyCopies()
 {
     $factory = new MockTracker_FormElementFactory();
     $project = new MockProject();
     $project->setReturnValue('getPublicName', 'Project');
     $element = new FakeFormElement(1, null, null, null, null, null, null, null, null, null, null, null);
     $element->setFormElementFactory($factory);
     $tracker1 = new MockTracker();
     $tracker1->setReturnValue('getId', '123');
     $tracker1->setReturnValue('getName', 'Canard');
     $tracker1->setReturnValue('getProject', $project);
     $copy1 = new FakeFormElement(10, null, null, null, null, null, null, null, null, null, null, $element);
     $copy2 = new FakeFormElement(20, null, null, null, null, null, null, null, null, null, null, $element);
     $copy1->setTracker($tracker1);
     $copy2->setTracker($tracker1);
     $tracker3 = new MockTracker();
     $tracker3->setReturnValue('getId', '124');
     $tracker3->setReturnValue('getName', 'Saucisse');
     $tracker3->setReturnValue('getProject', $project);
     $copy3 = new FakeFormElement(30, null, null, null, null, null, null, null, null, null, null, $element);
     $copy3->setTracker($tracker3);
     $factory->setReturnValue('getSharedTargets', array($copy1, $copy2, $copy3), array($element));
     return $element;
 }
示例#10
0
 private function GivenAProject($id, $name, $unixName = null, $useGit = true)
 {
     $project = new MockProject();
     $project->setReturnValue('getId', $id);
     $project->setReturnValue('getPublicName', htmlspecialchars($name));
     //see create_project()
     $project->setReturnValue('getUnixName', $unixName);
     $project->setReturnValue('usesService', $useGit, array(GitPlugin::SERVICE_SHORTNAME));
     return $project;
 }
示例#11
0
 public function testImpossibleToCreateTrackerWithAlreadyUsedShortName()
 {
     $tracker_factory = new TrackerFactoryTestVersion2();
     $dao = new MockTrackerDao();
     $dao->setReturnValue('duplicate', 999);
     $tracker_factory->setReturnReference('getDao', $dao);
     $project = new MockProject();
     $project->setReturnValue('isError', false);
     $pm = new MockProjectManager();
     $pm->setReturnReference('getProject', $project, array(456));
     $tracker_factory->setReturnReference('getProjectManager', $pm);
     $rm = new MockReferenceManager();
     $rm->setReturnValue('_isKeywordExists', false, array("MyNewTracker", 123));
     // keyword is not alreay used
     $tracker_factory->setReturnReference('getReferenceManager', $rm);
     $tracker = new MockTracker();
     $tracker_factory->setReturnReference('getTrackerById', $tracker, array(999));
     $tracker_factory->setReturnValue('isNameExists', false, array("My New Tracker", 123));
     // name is not already used
     $tracker_factory->setReturnValue('isShortNameExists', true, array("MyNewTracker", 123));
     // shortname is  already used
     // check that an error is returned if we try to create a tracker
     // with a name (not shortname) already used
     $project_id = 123;
     $group_id_template = 456;
     $id_template = 789;
     $name = 'My New Tracker';
     $description = 'My New Tracker to manage my brand new artifacts';
     $itemname = 'MyNewTracker';
     $this->assertFalse($tracker_factory->create($project_id, $group_id_template, $id_template, $name, $description, $itemname));
 }
示例#12
0
 function testCheckRestrictedAccessUserIsMember()
 {
     $GLOBALS['sys_allow_restricted_users'] = 1;
     $pm = new ProjectManagerTestVersion();
     $um = new MockUserManager();
     $user = new MockUser();
     $user->setReturnValue('isRestricted', true);
     $um->setReturnValue('getCurrentUser', $user);
     $pm->setReturnValue('_getUserManager', $um);
     $project = new MockProject();
     $project->setReturnValue('userIsMember', true);
     $this->assertTrue($pm->checkRestrictedAccess($project));
     $pm->expectOnce('_getUserManager');
 }
示例#13
0
 /**
  * Testing when The user is group admin filerelease admin and super user
  */
 function testUserIsAdminSuperUserGroupAdminFRSAdmin()
 {
     $utils = new WebDAVUtilsTestVersion($this);
     $user = mock('PFUser');
     $user->setReturnValue('isSuperUser', true);
     $project = new MockProject();
     $user->setReturnValue('isMember', true);
     $this->assertEqual($utils->UserIsAdmin($user, $project->getGroupId()), true);
 }
示例#14
0
 public function testClonePermsCrossProjectFork()
 {
     $old_repo_id = 110;
     $old_project = new MockProject();
     $old_project->setReturnValue('getId', 1);
     $new_repo_id = 220;
     $new_project = new MockProject();
     $new_project->setReturnValue('getId', 2);
     $old = new MockGitRepository();
     $old->setReturnValue('getId', $old_repo_id);
     $old->setReturnValue('getProject', $old_project);
     $new = new MockGitRepository();
     $new->setReturnValue('getId', $new_repo_id);
     $new->setReturnValue('getProject', $new_project);
     $backend = $this->_GivenABackendGitolite();
     $permissionsManager = $backend->getPermissionsManager();
     $permissionsManager->expectOnce('duplicateWithoutStatic', array($old_repo_id, $new_repo_id, Git::allPermissionTypes()));
     $backend->clonePermissions($old, $new);
 }
示例#15
0
 function testCheckCVSModeNeedOwnerUpdate()
 {
     $cvsdir = $GLOBALS['cvs_prefix'] . '/TestProj';
     mkdir($cvsdir . '/CVSROOT', 0700, true);
     chmod($cvsdir . '/CVSROOT', 04700);
     $project = new MockProject($this);
     $project->setReturnValue('getUnixName', 'TestProj', array(false));
     $project->setReturnValue('isPublic', true);
     $project->setReturnValue('isCVSPrivate', false);
     $project->setReturnValue('getMembersUserNames', array());
     $backend = $this->GivenACVSRepositoryWithWrongOwnership($project, $cvsdir);
     $backend->expectOnce('log', array('Restoring ownership on CVS dir: ' . $cvsdir, 'info'));
     $this->assertTrue($backend->checkCVSMode($project));
 }
示例#16
0
 /**
  *
  * @return Project_SOAPServer
  */
 private function GivenASOAPServerReadyToCreate()
 {
     $server = $this->GivenASOAPServer();
     $another_user = new MockUser();
     $another_user->setReturnValue('isLoggedIn', true);
     $this->um->setReturnValue('getCurrentUser', $another_user, array('789'));
     $template = new MockProject();
     $template->services = array();
     $template->setReturnValue('isTemplate', true);
     $this->pm->setReturnValue('getProject', $template, array(100));
     $new_project = new MockProject();
     $new_project->setReturnValue('getID', 3459);
     $this->pc->setReturnValue('create', $new_project, array('toto', 'Mon Toto', '*'));
     $this->pm->setReturnValue('activate', $new_project, true);
     return $server;
 }
示例#17
0
 function testUserCanAccessPrivateShouldLetUserPassWhenProjectIsPublic()
 {
     $urlVerification = TestHelper::getPartialMock('URLVerification', array('getProjectManager', 'exitError', 'displayRestrictedUserError', 'displayPrivateProjectError'));
     $GLOBALS['group_id'] = 120;
     $project = new MockProject();
     $project->setReturnValue('isError', false);
     $project->setReturnValue('isActive', true);
     $project->setReturnValue('isPublic', true);
     $projectManager = new MockProjectManager();
     $projectManager->setReturnValue('getProject', $project);
     $urlVerification->setReturnValue('getProjectManager', $projectManager);
     $urlVerification->expectNever('exitError');
     $urlVerification->expectNever('displayRestrictedUserError');
     $urlVerification->expectNever('displayPrivateProjectError');
     $urlVerification->assertValidUrl(array('SCRIPT_NAME' => '/stuff', 'REQUEST_URI' => '/stuff'));
 }
示例#18
0
 function testCheckRestrictedAccessUserIsMember()
 {
     ForgeConfig::set(ForgeAccess::CONFIG, ForgeAccess::RESTRICTED);
     $user = mock('PFUser');
     $user->setReturnValue('isRestricted', true);
     $this->user_manager->setReturnValue('getCurrentUser', $user);
     $project = new MockProject();
     $project->setReturnValue('userIsMember', true);
     $this->project_manager_test_version->expectOnce('_getUserManager');
     $this->assertTrue($this->project_manager_test_version->checkRestrictedAccess($project));
 }
示例#19
0
 function testCreateFileDbEntryMovedFile()
 {
     // Create toto.txt in the release directory
     mkdir($GLOBALS['ftp_frs_dir_prefix'] . '/prj/p123_r456');
     touch($GLOBALS['ftp_frs_dir_prefix'] . '/prj/p123_r456/toto.txt');
     touch($GLOBALS['ftp_incoming_dir'] . '/toto.txt');
     $p = new MockProject();
     $p->setReturnValue('getUnixName', 'prj');
     $r = new FRSRelease();
     $r->setReleaseID(456);
     $r->setPackageID(123);
     $r->setProject($p);
     $f = new FRSFile();
     $f->setFileName('toto.txt');
     $f->setRelease($r);
     $f->setFileLocation($GLOBALS['ftp_frs_dir_prefix'] . '/prj/p123_r456');
     $ff = new FRSFileFactoryTestCreateFiles();
     $ff->setReturnValue('moveFileForge', True);
     $ff->setReturnValue('create', False);
     try {
         $ff->createFile($f, ~FRSFileFactory::COMPUTE_MD5);
     } catch (Exception $e) {
         $this->assertIsA($e, 'FRSFileDbException');
     }
     //Cleanup
     unlink($GLOBALS['ftp_frs_dir_prefix'] . '/prj/p123_r456/toto.txt');
     unlink($GLOBALS['ftp_incoming_dir'] . '/toto.txt');
     rmdir($GLOBALS['ftp_frs_dir_prefix'] . '/prj/p123_r456');
 }
示例#20
0
 function testUserCanAccessPrivateShouldBlockWhenUserIsNotMemberOfPrivateProject()
 {
     $urlVerification = TestHelper::getPartialMock('URLVerification', array('getProjectManager', 'getCurrentUser'));
     $GLOBALS['group_id'] = 120;
     $project = new MockProject();
     $project->setReturnValue('isError', false);
     $project->setReturnValue('isPublic', false);
     $projectManager = new MockProjectManager();
     $projectManager->setReturnValue('getProject', $project, array(120));
     $urlVerification->setReturnValue('getProjectManager', $projectManager);
     $user = new MockUser();
     $user->setReturnValue('isMember', false);
     $urlVerification->setReturnValue('getCurrentUser', $user);
     $this->assertFalse($urlVerification->userCanAccessPrivate(new MockUrl(), 'stuff'));
 }
示例#21
0
 /**
  * testproject -> projecttest
  */
 public function testRenameProjectHomeDirectoryLowerCase()
 {
     $project = new MockProject($this);
     $project->setReturnValue('getUnixName', 'testproject', array(false));
     $project->setReturnValue('getUnixName', 'testproject', array(true));
     $pm = new MockProjectManager();
     $pm->setReturnReference('getProject', $project, array(142));
     $backend = new BackendTestVersion($this);
     $backend->setReturnValue('getProjectManager', $pm);
     $backend->createProjectHome(142);
     $this->assertEqual($backend->renameProjectHomeDirectory($project, "projecttest"), true);
     $this->assertFalse(file_exists($GLOBALS['grpdir_prefix'] . "/testproject"), "Old project home should no longer exists");
     $this->assertTrue(is_dir($GLOBALS['grpdir_prefix'] . "/projecttest"), "Project home should be renamed");
     // Cleanup
     $backend->recurseDeleteInDir($GLOBALS['grpdir_prefix'] . "/projecttest");
     rmdir($GLOBALS['grpdir_prefix'] . "/projecttest");
     rmdir($GLOBALS['ftp_anon_dir_prefix'] . "/testproject");
     rmdir($GLOBALS['ftp_frs_dir_prefix'] . "/testproject");
 }
 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());
 }
示例#23
0
 /**
  * Testing when project is public and user is member and restricted
  */
 function testUserCanReadWhenPublicMemberRestricted()
 {
     $webDAVProject = new WebDAVProjectTestVersion($this);
     $project = new MockProject();
     $project->setReturnValue('isPublic', true);
     $project->setReturnValue('userIsMember', true);
     $webDAVProject->setReturnValue('getProject', $project);
     $utils = new MockWebDAVUtils();
     $webDAVProject->setReturnValue('getUtils', $utils);
     $user = new MockUser();
     $user->setReturnValue('isRestricted', true);
     $webDAVProject->setReturnValue('getUser', $user);
     $this->assertEqual($webDAVProject->userCanRead(), true);
 }
示例#24
0
 /**
  * Testing when project is public and user is member and restricted
  */
 function testUserCanReadWhenPublicMemberRestricted()
 {
     $webDAVFRS = new WebDAVFRSTestVersion($this);
     $project = new MockProject();
     $project->setReturnValue('isPublic', true);
     $project->setReturnValue('userIsMember', true);
     $webDAVFRS->setReturnValue('getProject', $project);
     $user = mock('PFUser');
     $user->setReturnValue('isRestricted', true);
     $webDAVFRS->setReturnValue('getUser', $user);
     $this->assertEqual($webDAVFRS->userCanRead(), true);
 }
 public function testRewindAccessRightsToGerritUserWhenRepoIsMigratedToGerrit()
 {
     $prj = new MockProject($this);
     $prj->setReturnValue('getUnixName', 'project1');
     $prj->setReturnValue('getId', 404);
     // List all repo
     stub($this->repository_factory)->getAllRepositoriesOfProject($prj)->once()->returns(array(aGitRepository()->withProject($prj)->withId(4)->withName('before_migration_to_gerrit')->withNamespace('')->build(), aGitRepository()->withId(5)->withProject($prj)->withName('after_migration_to_gerrit')->withNamespace('')->withRemoteServerId(1)->build()));
     stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 4, 'PLUGIN_GIT_READ')->returns(array('2'));
     stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 4, 'PLUGIN_GIT_WRITE')->returns(array('3'));
     stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 4, 'PLUGIN_GIT_WPLUS')->returns(array('125'));
     stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 5, 'PLUGIN_GIT_READ')->returns(array('2'));
     stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 5, 'PLUGIN_GIT_WRITE')->returns(array('3'));
     stub($this->permissions_manager)->getAuthorizedUGroupIdsForProject($prj, 5, 'PLUGIN_GIT_WPLUS')->returns(array('125'));
     // Ensure file is correct
     $result = $this->project_serializer->dumpProjectRepoConf($prj);
     $expected = file_get_contents($this->_fixDir . '/perms/migrated_to_gerrit.conf');
     $this->assertIdentical($expected, $result);
 }
 public function itCanMoveATrackerAndSonsToAnothersTrackerNotInTheSameBranchAtTheSameTime()
 {
     $project_id = 110;
     $project = new MockProject();
     $project->setReturnValue('getID', $project_id);
     $project_trackers = array('117' => aTracker()->withId(117)->withName('Project')->build(), '118' => aTracker()->withId(118)->withName('Releases')->build(), '120' => aTracker()->withId(120)->withName('Stories')->withProject($project)->build(), '121' => aTracker()->withId(121)->withName('Tasks')->build(), '122' => aTracker()->withId(122)->withName('Bugs')->build(), '119' => aTracker()->withId(119)->withName('Epics')->build());
     $tracker = $project_trackers['120'];
     $hierarchy_dar = new ArrayIterator(array(array('parent_id' => 120, 'child_id' => 118), array('parent_id' => 120, 'child_id' => 117), array('parent_id' => 119, 'child_id' => 120), array('parent_id' => 120, 'child_id' => 122)));
     $expected_hierarchy = $this->getHierarchyAsTreeNode(array(array('name' => 'Epics', 'id' => 119, 'children' => array(array('name' => 'Stories', 'id' => 120, 'children' => array(array('name' => 'Releases', 'id' => 118, 'children' => array()), array('name' => 'Projects', 'id' => 117, 'children' => array()), array('name' => 'Bugs', 'id' => 122, 'children' => array()))))), array('name' => 'Tasks', 'id' => 121, 'children' => array())));
     $dao = $this->aMockDaoWith($project_id, $hierarchy_dar);
     $tracker_factory = $this->aMockTrackerFactoryWith($project_id, $project_trackers);
     $factory = new Tracker_Hierarchy_HierarchicalTrackerFactory($tracker_factory, $dao);
     $this->assertEqual($expected_hierarchy->__toString(), $factory->getHierarchy($tracker)->__toString());
 }
示例#27
0
 public function itverifiesUserGroupMembersAreProjectMembersWhenProjectIsPrivate()
 {
     $user1 = mock('PFUser');
     $user1->setReturnValue('getUserName', 'user1');
     $user2 = mock('PFUser');
     $user2->setReturnValue('getUserName', 'user2');
     $project = new MockProject($this);
     $project->setReturnValue('getMembers', array($user2));
     $project->setReturnValue('isPublic', false);
     $usergroup_dao = new MockUGroupDao();
     $usergroup_dao->setReturnValue('searchByGroupId', array(array('name' => 'Perms')));
     $this->backend->setReturnValue('getUGroupDao', $usergroup_dao);
     $ugroup = new MockProjectUGroup($this);
     $ugroup->setReturnValue('getMembers', array($user1, $user2));
     $ugroup->setReturnValue('getName', 'Perms');
     $this->backend->setReturnValue('getUGroupFromRow', $ugroup);
     $ugroup_members_line = $this->backend->getSVNAccessUserGroupMembers($project);
     $this->assertEqual($ugroup_members_line, "Perms = user2\n\n");
 }
示例#28
0
 public function testForkCrossProjectsRedirectToCrossProjectGitRepositories()
 {
     $repo_id = '1';
     $project_id = 2;
     $user = new MockUser();
     $user->setReturnValue('getId', 123);
     $user->setReturnValue('isMember', true, array($project_id, 'A'));
     $to_project = new MockProject();
     $to_project->setReturnValue('getId', $project_id);
     $repo = new MockGitRepository();
     $repo->setReturnValue('getId', $repo_id);
     $repo->setReturnValue('userCanRead', true, array($user));
     $repo->expectOnce('fork');
     $repos = array($repo);
     $systemEventManager = new MockSystemEventManager();
     $layout = new MockLayout();
     $layout->expectOnce('redirect');
     $action = $this->GivenAGitActions();
     $action->getController()->expectOnce('addInfo', array('successfully_forked'));
     $action->fork($repos, $to_project, '', null, $user, $layout, null);
 }
 private function ThenICompareProjectSharedFieldsWithExpectedResult($factory, $project_id, $expectedResult)
 {
     $project = new MockProject();
     $project->setReturnValue('getId', $project_id);
     $this->assertEqual($factory->getProjectSharedFields($project), $expectedResult);
 }
示例#30
0
 public function testUpdateSVNAccessForGivenMember()
 {
     $backend = new BackendSVNAccessTestVersion($this);
     // The user
     $user = mock('PFUser');
     $user->setReturnValue('getId', array(142));
     $project1 = new MockProject($this);
     $project1->setReturnValue('getId', 102);
     $project2 = new MockProject($this);
     $project2->setReturnValue('getId', 101);
     $projects = array(102, 101);
     $user->setReturnValue('getAllProjects', $projects);
     $pm = new MockProjectManager();
     $backend->setReturnValue('getProjectManager', $pm);
     $pm->setReturnReference('getProject', $project1, array(102));
     $pm->setReturnReference('getProject', $project2, array(101));
     $backend->setReturnValue('repositoryExists', true);
     $backend->setReturnValue('updateSVNAccess', true);
     $this->assertEqual($backend->updateSVNAccessForGivenMember($user), true);
     $backend->expectCallCount('repositoryExists', 2);
     $backend->expectAt(0, 'repositoryExists', array($project1));
     $backend->expectAt(1, 'repositoryExists', array($project2));
     $backend->expectCallCount('updateSVNAccess', 2);
     $backend->expectAt(0, 'updateSVNAccess', array(102));
     $backend->expectAt(1, 'updateSVNAccess', array(101));
 }