public function itThrowsAProjectDeletionExceptionIfThereAreOpenChanges()
 {
     $exception = new Git_Driver_Gerrit_RemoteSSHCommandFailure(1, '', 'error');
     stub($this->ssh)->execute()->throws($exception);
     $this->expectException('ProjectDeletionException');
     $this->driver->deleteProject($this->gerrit_server, 'project');
 }
Exemplo n.º 2
0
 public function itDoesNotDisableIfItIsNotAlreadyTheCase()
 {
     $request = aRequest()->with('use_freestyle_columns', '0')->build();
     stub($this->dao)->isFreestyleEnabled($this->tracker_id)->returns(false);
     stub($this->dao)->disableFreestyleColumns()->never();
     $this->command->execute($request);
 }
Exemplo n.º 3
0
 public function setUp()
 {
     parent::setUp();
     $this->bc1 = stub('BreadCrumb_BreadCrumbGenerator')->getCrumbs()->returns(array('lvl1' => "Toto", 'lvl2' => "Tata"));
     $this->bc2 = stub('BreadCrumb_BreadCrumbGenerator')->getCrumbs()->returns(array('lvl3' => "Tutu"));
     $this->bc3 = stub('BreadCrumb_BreadCrumbGenerator')->getCrumbs()->returns(array('lvl4' => "Tralala"));
 }
    public function itRemovesAllIncludedGroups()
    {
        $groupname = "parent group";
        $url_get_members = $this->gerrit_server_host . ':' . $this->gerrit_server_port . '/a/groups/' . urlencode($groupname) . '/groups';
        $response_with_included_groups = <<<EOS
)]}'
[
  {
    "kind": "gerritcodereview#group",
    "url": "#/admin/groups/uuid-6ef56904c11e6d53c8f2f3657353faaac74bfc6d",
    "options": {},
    "group_id": 7,
    "owner": "enalean",
    "owner_id": "6ef56904c11e6d53c8f2f3657353faaac74bfc6d",
    "id": "6ef56904c11e6d53c8f2f3657353faaac74bfc6d",
    "name": "enalean"
  },
  {
    "kind": "gerritcodereview#group",
    "url": "#/admin/groups/uuid-b99e4455ca98f2ec23d9250f69617e34ceae6bd6",
    "options": {},
    "group_id": 6,
    "owner": "another group",
    "owner_id": "b99e4455ca98f2ec23d9250f69617e34ceae6bd6",
    "id": "b99e4455ca98f2ec23d9250f69617e34ceae6bd6",
    "name": "another group"
  }
]
EOS;
        stub($this->guzzle_client)->get($url_get_members, '*')->returns($this->getGuzzleRequestWithTextResponse($response_with_included_groups));
        $url = $this->gerrit_server_host . ':' . $this->gerrit_server_port . '/a/groups/' . urlencode($groupname) . '/groups.delete';
        expect($this->guzzle_client)->post($url, array(Git_Driver_GerritREST::HEADER_CONTENT_TYPE => Git_Driver_GerritREST::MIME_JSON, 'verify' => false), json_encode(array('groups' => array('enalean', 'another group'))))->once();
        stub($this->guzzle_client)->post()->returns($this->guzzle_request);
        $this->driver->removeAllIncludedGroups($this->gerrit_server, $groupname);
    }
 public function itDeletesTheRepository()
 {
     $event = TestHelper::getPartialMock('SystemEvent_GIT_REPO_DELETE', array('getRepositoryFactory'));
     $event->setParameters($this->project_id . SystemEvent::PARAMETER_SEPARATOR . $this->repository_id);
     stub($event)->getRepositoryFactory()->returns($this->git_repository_factory);
     $event->process();
 }
 public function itDoesNotDisableIfItIsNotAlreadyTheCase()
 {
     $request = aRequest()->with('cardwall_on_top', '0')->build();
     stub($this->dao)->isEnabled($this->tracker_id)->returns(false);
     stub($this->dao)->disable()->never();
     $this->command->execute($request);
 }
 public function itThrowsAnExceptionIfFieldIsNotAlphaNumeric()
 {
     $values = array('msb' => 'whatever');
     stub($this->form_element_factory)->getUsedFieldByName(101, 'msb')->returns($this->field_msb);
     $this->expectException('Tracker_FormElement_RESTValueByField_NotImplementedException');
     $this->validator->getFieldsDataOnCreateFromValuesByField($values, $this->tracker);
 }
 public function itDoesNotCallTheAfterMethodOnWorkflowWhenSaveOfArtifactFails()
 {
     stub($this->changeset_dao)->create()->returns(true);
     stub($this->artifact_factory)->save()->returns(false);
     expect($this->workflow)->after()->never();
     $this->creator->create($this->artifact, $this->fields_data, $this->submitter, $this->submitted_on);
 }
Exemplo n.º 9
0
 public function withValueForChangesetId($value_id, $changeset_id)
 {
     $bind = mock('Tracker_FormElement_Field_List_Bind_Static');
     stub($this->field)->getBind()->returns($bind);
     stub($bind)->getChangesetValues($changeset_id)->returns(array(array('id' => $value_id)));
     return $this;
 }
Exemplo n.º 10
0
 public function setUp()
 {
     $this->_globals = $GLOBALS;
     $this->fixturesPath = dirname(__FILE__) . '/_fixtures';
     $git_plugin = stub('GitPlugin')->areFriendlyUrlsActivated()->returns(false);
     $this->url_manager = new Git_GitRepositoryUrlManager($git_plugin);
 }
Exemplo n.º 11
0
 public function build()
 {
     $ugroup = mock('ProjectUGroup');
     stub($ugroup)->getId()->returns($this->id);
     stub($ugroup)->getNormalizedName()->returns($this->normalized_name);
     return $ugroup;
 }
Exemplo n.º 12
0
 public function itThrowsAnExceptionIfUserNotAdmin()
 {
     stub($this->kanban_actions_checker)->checkUserCanAdministrate($this->user, $this->kanban)->throws(new AgileDashboard_UserNotAdminException($this->user));
     expect($this->column_dao)->setColumnWipLimit($this->kanban_id, $this->column_id, $this->wip_limit)->never();
     $this->expectException("AgileDashboard_UserNotAdminException");
     $this->kanban_column_manager->updateWipLimit($this->user, $this->kanban, $this->column, $this->wip_limit);
 }
Exemplo n.º 13
0
 public function itCreatesUserWithNoSuffixByDefault()
 {
     $project_name = 'vla';
     stub($this->project)->getUnixName()->returns($project_name);
     $generic_user = $this->factory->create('120', 'my_password');
     $this->assertEqual(substr($generic_user->getUnixName(), -strlen($project_name)), $project_name);
 }
Exemplo n.º 14
0
 public function itDelegatesToPlanningItem()
 {
     $trackers = array(mock('Tracker'), mock('Tracker'));
     $planning_item = stub('Planning_Item')->getAllowedChildrenTypes()->returns($trackers);
     $presenter = new Planning_ItemPresenter($planning_item, mock('Tracker_CardFields'));
     $this->assertEqual($trackers, $presenter->allowedChildrenTypes());
 }
 public function itFallsBackToValueStringProcessing()
 {
     $soap_value = (object) array('field_name' => '', 'field_label' => '', 'field_value' => (object) array('value' => 'Bravo,Zoulou'));
     expect($this->bind)->getFieldData('Bravo,Zoulou', true)->once();
     stub($this->bind)->getFieldData()->returns(array(1586, 2894));
     $this->assertIdentical(array(1586, 2894), $this->field->getFieldDataFromSoapValue($soap_value));
 }
Exemplo n.º 16
0
 public function setUp()
 {
     $artifact = aMockArtifact()->withId(123)->withTitle('Foo')->withXRef('milestone #123')->build();
     $project = stub('Project')->getID()->returns(456);
     $this->milestone = aMilestone()->withArtifact($artifact)->withGroup($project)->withPlanningId(789)->build();
     $this->presenter = new Planning_MilestoneLinkPresenter($this->milestone);
 }
Exemplo n.º 17
0
 public function itHasAnArtifact()
 {
     $artifact = mock('Tracker_Artifact');
     $presenter = stub('Cardwall_CardInCellPresenter')->getArtifact()->returns($artifact);
     $presenter_node = new Cardwall_CardInCellPresenterNode(new TreeNode(), $presenter);
     $this->assertEqual($artifact, $presenter_node->getArtifact());
 }
 public function itCallsTheRightOptions()
 {
     $url = $this->gerrit_server_host . ':' . $this->gerrit_server_port . '/a/projects/' . urlencode($this->project_name);
     expect($this->guzzle_client)->get($url, '*')->once();
     stub($this->guzzle_client)->get()->returns($this->guzzle_request);
     $this->driver->doesTheParentProjectExist($this->gerrit_server, $this->project_name);
 }
Exemplo n.º 19
0
 public function withFieldForTracker($field, $tracker)
 {
     $semantic = mock('Tracker_Semantic_Title');
     stub($semantic)->getField()->returns($field);
     stub($this->factory)->getByTracker($tracker)->returns($semantic);
     return $this;
 }
 public function setUp()
 {
     /*
                    Epic
     Release  ----,-- Story
       Sprint ---'      Task
     */
     $this->epic_tracker = aTracker()->withId('epic')->withParent(null)->build();
     $this->story_tracker = aTracker()->withId('story')->withParent($this->epic_tracker)->build();
     $this->task_tracker = aTracker()->withId('task')->withParent($this->story_tracker)->build();
     $this->release_tracker = aTracker()->withId('release')->withParent(null)->build();
     $this->sprint_tracker = aTracker()->withId('sprint')->withParent($this->epic_tracker)->build();
     $release_planning = stub('Planning')->getPlanningTracker()->returns($this->release_tracker);
     stub($release_planning)->getPlanningTrackerId()->returns('release');
     $sprint_planning = stub('Planning')->getPlanningTracker()->returns($this->sprint_tracker);
     stub($sprint_planning)->getPlanningTrackerId()->returns('sprint');
     $this->hierarchy = mock('Tracker_Hierarchy');
     stub($this->hierarchy)->sortTrackerIds()->returns(array('release', 'sprint'));
     $this->hierarchy_factory = mock('Tracker_HierarchyFactory');
     stub($this->hierarchy_factory)->getHierarchy()->returns($this->hierarchy);
     $this->planning_factory = mock('PlanningFactory');
     stub($this->planning_factory)->getPlanningsByBacklogTracker($this->task_tracker)->returns(array());
     stub($this->planning_factory)->getPlanningsByBacklogTracker($this->story_tracker)->returns(array($sprint_planning, $release_planning));
     stub($this->planning_factory)->getPlanningsByBacklogTracker($this->epic_tracker)->returns(array());
     $this->provider = new AgileDashboard_Planning_NearestPlanningTrackerProvider($this->planning_factory);
 }
 public function itSavesNothingIfThereAreNoProjectLanguageAndMoreThanOneSystemLanguage()
 {
     ForgeConfig::set('sys_supported_languages', 'it_IT,ja_JP');
     stub($this->dao)->getUsedLanguageForProject()->returns(false);
     expect($this->dao)->updateLanguageOption()->never();
     $this->language_manager->getUsedLanguageForProject($this->project);
 }
Exemplo n.º 22
0
 public function itStopsTheExecutionWhenThereIsARemainingSystemEventRunning()
 {
     stub($this->process_manager)->isAlreadyRunning($this->process)->returns(true);
     expect($this->response)->error('There is still an event marked as running. Start again when all events marked as running are done.')->once();
     expect($this->response)->abort()->once();
     $this->command->execute();
 }
 public function itDoesntTransformExceptionsThatArentRelatedToGerrit()
 {
     $std_err = 'some gerrit exception';
     $this->expectException('Git_Driver_Gerrit_RemoteSSHCommandFailure');
     stub($this->ssh)->execute()->throws(new Git_Driver_Gerrit_RemoteSSHCommandFailure(255, '', $std_err));
     $this->driver->createProject($this->gerrit_server, $this->repository, $this->project_name);
 }
Exemplo n.º 24
0
 public function setUp()
 {
     $this->template = array('name' => 'template-name', 'id' => 120);
     $this->project = mock('Project');
     stub($this->project)->getGroupId()->returns(101);
     stub($this->project)->getUnixName()->returns('h1tst');
 }
Exemplo n.º 25
0
 public function itIncludesBreadcrumbsForParentMilestones()
 {
     $this->sprint->setAncestors(array($this->release, $this->product));
     stub($this->milestone_factory)->getBareMilestone()->returns($this->sprint);
     $breadcrumbs = $this->getBreadcrumbs();
     $this->assertEqualToBreadCrumbWithAllMilestones($breadcrumbs);
 }
Exemplo n.º 26
0
 public function build()
 {
     stub($this->project)->getId()->returns($this->id);
     stub($this->project)->getUnixName()->returns($this->unix_name);
     stub($this->project)->isPublic()->returns($this->is_public);
     return $this->project;
 }
Exemplo n.º 27
0
 public function itCreatesAnArtifactNodeForEveryArtifactId()
 {
     $swmiline_id = 7;
     $artifact4 = aMockArtifact()->withId(4)->build();
     $artifact5 = aMockArtifact()->withId(5)->build();
     $artifact6 = aMockArtifact()->withId(6)->build();
     $node4 = new Cardwall_CardInCellPresenterNode(new Cardwall_CardInCellPresenter(new Cardwall_CardPresenter($artifact4, mock('Cardwall_CardFields'), '*', mock('Cardwall_UserPreferences_UserPreferencesDisplayUser'), 0, array()), 4));
     $node5 = new Cardwall_CardInCellPresenterNode(new Cardwall_CardInCellPresenter(new Cardwall_CardPresenter($artifact5, mock('Cardwall_CardFields'), '*', mock('Cardwall_UserPreferences_UserPreferencesDisplayUser'), 0, array()), 5));
     $node6 = new Cardwall_CardInCellPresenterNode(new Cardwall_CardInCellPresenter(new Cardwall_CardPresenter($artifact6, mock('Cardwall_CardFields'), '*', mock('Cardwall_UserPreferences_UserPreferencesDisplayUser'), 0, array()), 6));
     stub($this->artifact_factory)->getArtifactById(4)->returns($artifact4);
     stub($this->artifact_factory)->getArtifactById(5)->returns($artifact5);
     stub($this->artifact_factory)->getArtifactById(6)->returns($artifact6);
     stub($this->node_factory)->getCardInCellPresenterNode($artifact4, $swmiline_id)->returns($node4);
     stub($this->node_factory)->getCardInCellPresenterNode($artifact5, $swmiline_id)->returns($node5);
     stub($this->node_factory)->getCardInCellPresenterNode($artifact6, $swmiline_id)->returns($node6);
     $cards = $this->provider->getCards(array(4, 5, 6), $swmiline_id);
     $this->assertEqual(3, count($cards));
     foreach ($cards as $card) {
         $id = $card->getId();
         $this->assertBetweenClosedInterval($id, 4, 6);
         $artifact = $card->getArtifact();
         $this->assertBetweenClosedInterval($artifact->getId(), 4, 6);
         $this->assertIsA($artifact, 'Tracker_Artifact');
     }
 }
 public function itStoresTheLanguageIfThereIsOnlyOnePossibleLanguageForProject()
 {
     stub($this->language_manager)->getAvailableLanguages()->returns(array('en_US'));
     stub($this->language_manager)->getUsedLanguageForProject($this->project)->returns(null);
     expect($this->language_manager)->saveLanguageOption($this->project, 'en_US')->once();
     $this->welcome_page_manager->displayWelcomePage($this->project, $this->request);
 }
Exemplo n.º 29
0
 public function itReturnsTheTV5LinkIfIdIsMatching()
 {
     stub($this->artifact_factory)->getArtifactById(101)->returns($this->artifact);
     $reference = $this->tracker_reference_manager->getReference($this->keyword, $this->artifact_id);
     $this->assertNotNull($reference);
     $this->assertIsA($reference, 'Tracker_Reference');
 }
 public function itCatchesExceptionsThrownInPostActions()
 {
     stub($this->processor)->launchAs()->throws(new Exception('Something weird happend'));
     expect($this->logger)->error()->once();
     $category = SystemEvent::DEFAULT_QUEUE;
     $this->processor->execute($category);
 }