コード例 #1
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');
     }
 }
コード例 #2
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);
 }
 public function itHasJsonRepresentation()
 {
     $timestamp = mktime(1, 1, 1, 9, 25, 2013);
     $changeset = partial_mock('Tracker_Artifact_Changeset', array('getChangeContentForJson'), array(15, aMockArtifact()->build(), 45, $timestamp, ''));
     $template_renderer = mock('TemplateRenderer');
     stub($template_renderer)->renderToString()->returns('body');
     $json_formatter = new Tracker_Artifact_ChangesetJsonFormatter($template_renderer);
     $this->assertEqual($json_formatter->format($changeset), array('id' => 15, 'submitted_by' => 45, 'submitted_on' => date('c', $timestamp), 'email' => '', 'html' => 'body'));
 }
コード例 #4
0
 public function itReturnsZeroWhenUserDoesntHavePermissions()
 {
     $user = aUser()->build();
     $artifact_value = stub('Tracker_Artifact_ChangesetValue_Float')->getValue()->returns(123.45);
     $artifact = aMockArtifact()->withValue($artifact_value)->build();
     $field = TestHelper::getPartialMock('Tracker_FormElement_Field_Float', array('userCanRead'));
     stub($field)->userCanRead($user)->returns(false);
     $actual_value = $field->getComputedValue($user, $artifact);
     $this->assertEqual(0, $actual_value);
 }
コード例 #5
0
 public function setUp()
 {
     parent::setUp();
     $tracker = mock('Tracker');
     $this->field_id = 77777;
     $this->field = stub('Tracker_FormElement_Field_MultiselectBox')->getId()->returns($this->field_id);
     $this->artifact = aMockArtifact()->withTracker($tracker)->build();
     $this->card_presenter = stub('Cardwall_CardPresenter')->getArtifact()->returns($this->artifact);
     $this->field_provider = stub('Cardwall_FieldProviders_IProvideFieldGivenAnArtifact')->getField($tracker)->returns($this->field);
 }
コード例 #6
0
 public function itReturnsNullIfThereIsACustomMappingButNoFieldChoosenYet()
 {
     $tracker = aTracker()->build();
     $artifact = aMockArtifact()->withTracker($tracker)->build();
     $status_field = mock('Tracker_FormElement_Field_OpenList');
     $status_retriever = stub('Cardwall_FieldProviders_SemanticStatusFieldRetriever')->getField()->returns($status_field);
     $mapping = stub('Cardwall_OnTop_Config_TrackerMapping')->getField()->returns(null);
     $config = stub('Cardwall_OnTop_Config')->getMappingFor($tracker)->returns($mapping);
     $provider = new Cardwall_OnTop_Config_MappedFieldProvider($config, $status_retriever);
     $this->assertEqual(null, $provider->getField($artifact));
 }
コード例 #7
0
 public function itDisplaysASelectorOfArtifactWhenThereAreNoMilestoneSelected()
 {
     $current_milstone = new Planning_NoMilestone(mock('Project'), $this->sprint_planning);
     $milstone_1001 = aMilestone()->withArtifact(aMockArtifact()->withId(1001)->withTitle('An open artifact')->build())->build();
     $milstone_1002 = aMilestone()->withArtifact(aMockArtifact()->withId(1002)->withTitle('Another open artifact')->build())->build();
     stub($this->milestone_factory)->getAllBareMilestones($this->current_user, $this->sprint_planning)->returns(array($milstone_1001, $milstone_1002));
     $this->pane_factory = new Planning_MilestonePaneFactory4Tests($this->request, $this->milestone_factory, $this->pane_presenter_builder_factory, mock('AgileDashboard_Milestone_Pane_Planning_SubmilestoneFinder'), mock('AgileDashboard_PaneInfoFactory'));
     $selectable_artifacts = $this->pane_factory->getAvailableMilestones($current_milstone);
     $this->assertCount($selectable_artifacts, 2);
     $this->assertEqual(array_shift($selectable_artifacts), $milstone_1001);
     $this->assertEqual(array_shift($selectable_artifacts), $milstone_1002);
 }
コード例 #8
0
 public function setUp()
 {
     parent::setUp();
     $this->artifact_id = 123;
     $this->changeset_id = 456;
     $this->value_id = 789;
     $this->artifact = aMockArtifact()->withId($this->artifact_id)->build();
     $this->tracker = $this->artifact->getTracker();
     $this->artifact_factory = aMockArtifactFactory()->withArtifact($this->artifact)->build();
     $this->semantic_title_factory = aMockSemanticTitleFactory()->build();
     $this->field = aMockField()->withValueForChangesetId($this->value_id, $this->changeset_id)->build();
     $this->setText('Open', array('plugin_tracker_crosssearch', 'semantic_status_open'));
     $this->setText('Closed', array('plugin_tracker_crosssearch', 'semantic_status_closed'));
 }
コード例 #9
0
ファイル: ConfigTest.php プロジェクト: nterray/tuleap
 public function setUp()
 {
     parent::setUp();
     $value_none = new Tracker_FormElement_Field_List_Bind_StaticValue(100, 'None', '', 0, 0);
     $value_todo = new Tracker_FormElement_Field_List_Bind_StaticValue(101, 'Todo', '', 0, 0);
     $value_inprogress = new Tracker_FormElement_Field_List_Bind_StaticValue(102, 'In Progress', '', 0, 0);
     $value_done = new Tracker_FormElement_Field_List_Bind_StaticValue(103, 'Done', '', 0, 0);
     $mapping_none = new Cardwall_OnTop_Config_ValueMapping($value_none, 10);
     $mapping_todo = new Cardwall_OnTop_Config_ValueMapping($value_todo, 10);
     $mapping_ongoing = new Cardwall_OnTop_Config_ValueMapping($value_inprogress, 11);
     $mapping_done = new Cardwall_OnTop_Config_ValueMapping($value_done, 12);
     $this->value_mappings = array(100 => $mapping_none, 101 => $mapping_todo, 102 => $mapping_ongoing, 103 => $mapping_done);
     $this->mapping = new Cardwall_OnTop_Config_TrackerMappingStatus(mock('Tracker'), array(), $this->value_mappings, aSelectBoxField()->build());
     $this->config = partial_mock('Cardwall_OnTop_Config', array('getMappingFor'));
     $this->artifact = aMockArtifact()->withTracker(aTracker()->build())->build();
 }
コード例 #10
0
 public function itReturnsABoardWithaSwimline()
 {
     $child_artifact = aMockArtifact()->withId('child')->allUsersCanView()->build();
     $swimline_artifact = aMockArtifact()->withId('whatever')->allUsersCanView()->build();
     stub($swimline_artifact)->getChildrenForUser()->returns(array($child_artifact));
     stub($this->swimline_factory)->getCells()->returns(array());
     $row = array('id' => 'whatever');
     stub($this->artifact_factory)->getInstanceFromRow($row)->returns($swimline_artifact);
     stub($this->dao)->getBacklogArtifacts()->returnsDar($row);
     stub($this->card_in_cell_presenter_builder)->getCardInCellPresenter()->returns(mock('Cardwall_CardInCellPresenter'));
     stub($this->card_in_cell_presenter_builder)->getCardInCellPresenters()->returns(array(mock('Cardwall_CardInCellPresenter')));
     $pane_builder = new Cardwall_PaneBoardBuilder($this->card_in_cell_presenter_builder, $this->artifact_factory, $this->dao, $this->swimline_factory);
     $board = $pane_builder->getBoard($this->user, $this->milestone_artifact, $this->columns, $this->mapping_collection);
     $this->assertCount($board->swimlines, 1);
     $this->assertIsA($board->swimlines[0], 'Cardwall_Swimline');
 }
コード例 #11
0
ファイル: ItemTest.php プロジェクト: nterray/tuleap
 public function setUp()
 {
     parent::setUp();
     $this->edit_uri = 'http://someurl';
     $this->xref = 'some #xref';
     $this->title = 'do something interresting';
     $this->id = '234872';
     $epics_tracker_id = 123;
     $stories_tracker_id = 456;
     $this->allowed_children_types = array(aTracker()->withId($stories_tracker_id)->build());
     $this->epics_tracker = aTracker()->withId($epics_tracker_id)->build();
     $this->stories_tracker = aTracker()->withId($stories_tracker_id)->build();
     $this->planning = aPlanning()->withBacklogTrackerId($epics_tracker_id)->build();
     $this->epic = aMockArtifact()->withUri($this->edit_uri)->withXRef($this->xref)->withTitle($this->title)->withTracker($this->epics_tracker)->withAllowedChildrenTypes($this->allowed_children_types)->withId($this->id)->build();
     $this->story = aMockArtifact()->withTracker($this->stories_tracker)->build();
     $this->item = new Planning_Item($this->epic, $this->planning);
 }
コード例 #12
0
 public function setUp()
 {
     parent::setUp();
     ForgeConfig::store();
     ForgeConfig::set('codendi_dir', AGILEDASHBOARD_BASE_DIR . '/../../..');
     $this->plugin_path = '/plugin/path';
     $this->product = aMilestone()->withArtifact(aMockArtifact()->withId(1)->withTitle('Product X')->build())->build();
     $this->release = aMilestone()->withArtifact(aMockArtifact()->withId(2)->withTitle('Release 1.0')->build())->build();
     $this->sprint = aMilestone()->withArtifact(aMockArtifact()->withId(3)->withTitle('Sprint 1')->build())->build();
     $this->nomilestone = stub('Planning_NoMilestone')->getPlanning()->returns(mock('Planning'));
     $this->milestone_factory = mock('Planning_MilestoneFactory');
     $this->project_manager = mock('ProjectManager');
     $this->current_user = aUser()->build();
     $this->request = aRequest()->withUser($this->current_user)->with('group_id', 102)->build();
     $this->project = mock('Project');
     stub($this->project_manager)->getProject(102)->returns($this->project);
 }
コード例 #13
0
ファイル: ArtifactLinkerTest.php プロジェクト: nickl-/tuleap
 public function itLinksWithAllHierarchyWhenItWasLinkedToAnAssociatedTracker()
 {
     $user = aUser()->build();
     $epic_id = 2;
     $epic = aMockArtifact()->withId(2)->build();
     stub($epic)->getAllAncestors($user)->returns(array());
     $product = aMockArtifact()->withId(56)->build();
     $release_id = 7777;
     $release = aMockArtifact()->withId($release_id)->build();
     stub($release)->getAllAncestors($user)->returns(array($product));
     $request = aRequest()->with('link-artifact-id', "{$release_id}")->withUser($user)->build();
     $epic->expectNever('linkArtifact');
     $release->expectNever('linkArtifact');
     $product->expectOnce('linkArtifact', array($epic_id, $user));
     $artifact_factory = mock('Tracker_ArtifactFactory');
     stub($artifact_factory)->getArtifactById($release_id)->returns($release);
     $linker = new Planning_ArtifactLinker($artifact_factory);
     $linker->linkWithParents($request, $epic);
 }
コード例 #14
0
 public function itCreatesAnArtifactNodeForEveryArtifactId()
 {
     $provider = new Cardwall_ArtifactNodeTreeProvider();
     $artifact_factory = mock('Tracker_ArtifactFactory');
     $artifact4 = aMockArtifact()->withId(4)->build();
     $artifact5 = aMockArtifact()->withId(5)->build();
     $artifact6 = aMockArtifact()->withId(6)->build();
     stub($artifact_factory)->getArtifactById(4)->returns($artifact4);
     stub($artifact_factory)->getArtifactById(5)->returns($artifact5);
     stub($artifact_factory)->getArtifactById(6)->returns($artifact6);
     $cards = $provider->getCards(array(4, 5, 6), $artifact_factory);
     $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');
     }
 }
コード例 #15
0
 public function itReturnsJson()
 {
     $artifact_id = 55;
     $artifact_title = 'bla';
     $cross_ref = 'task #22';
     $edit_url = 'edit';
     $accent_color = 'rgb(12,12,12)';
     $swimline_id = 215;
     $drop_into = array('5', '7');
     $artifact = aMockArtifact()->withId($artifact_id)->build();
     $card_fields = mock('Cardwall_CardFields');
     $field1 = mock('Tracker_FormElement_Field_Float');
     $field2 = mock('Tracker_FormElement_Field_Selectbox');
     $field3 = mock('Tracker_FormElement_Field_Selectbox');
     stub($field1)->getJsonValue()->returns(5.1);
     stub($field2)->getJsonValue()->returns(array(101, 201));
     stub($field3)->getJsonValue()->returns(236);
     stub($field1)->fetchCardValue()->returns("5.1");
     stub($field2)->fetchCardValue()->returns('<a href');
     stub($field3)->fetchCardValue()->returns('<span>Decorator</span>');
     stub($field1)->getName()->returns(Tracker::REMAINING_EFFORT_FIELD_NAME);
     stub($field2)->getName()->returns(Tracker::ASSIGNED_TO_FIELD_NAME);
     stub($field3)->getName()->returns(Tracker::IMPEDIMENT_FIELD_NAME);
     $card_presenter = mock('Cardwall_CardPresenter');
     stub($card_presenter)->getTitle()->returns($artifact_title);
     stub($card_presenter)->getXRef()->returns($cross_ref);
     stub($card_presenter)->getEditUrl()->returns($edit_url);
     stub($card_presenter)->getAccentColor()->returns($accent_color);
     stub($card_presenter)->getSwimlineId()->returns($swimline_id);
     $card_in_cell_presenter = mock('Cardwall_CardInCellPresenter');
     stub($card_in_cell_presenter)->getCardPresenter()->returns($card_presenter);
     stub($card_in_cell_presenter)->getDropIntoIds()->returns($drop_into);
     stub($card_in_cell_presenter)->getArtifact()->returns($artifact);
     stub($card_fields)->getFields()->returns(array($field1, $field2, $field3));
     $single_card = new Cardwall_SingleCard($card_in_cell_presenter, $card_fields, mock('Cardwall_UserPreferences_UserPreferencesDisplayUser'), 1111, mock('Cardwall_OnTop_Config_TrackerMapping'));
     $card_controller = new Cardwall_CardController(aRequest()->withUser(mock('PFUser'))->build(), $single_card);
     $expected = array($artifact_id => array('title' => $artifact_title, 'xref' => $cross_ref, 'edit_url' => $edit_url, 'accent_color' => $accent_color, 'column_id' => 1111, 'drop_into' => $drop_into, 'fields' => array('remaining_effort' => 5.1, 'assigned_to' => array(101, 201), 'impediment' => 236), 'html_fields' => array('remaining_effort' => '5.1', 'assigned_to' => '<a href', 'impediment' => '<span>Decorator</span>')));
     expect($GLOBALS['Response'])->sendJSON($expected)->once();
     $card_controller->getCard();
 }
コード例 #16
0
 public function setUp()
 {
     parent::setUp();
     $this->factory = mock('Tracker_FormElementFactory');
     $this->new_changeset_fields_validator = new Tracker_Artifact_Changeset_NewChangesetFieldsValidator($this->factory);
     $this->initial_changeset_fields_validator = new Tracker_Artifact_Changeset_InitialChangesetFieldsValidator($this->factory);
     $this->field1 = $this->getFieldWithId(101);
     $this->field2 = $this->getFieldWithId(102);
     $this->field3 = $this->getFieldWithId(103);
     $this->factory->setReturnValue('getAllFormElementsForTracker', array());
     $this->factory->setReturnValue('getUsedFields', array($this->field1, $this->field2, $this->field3));
     $this->workflow = mock('Workflow');
     $this->artifact = aMockArtifact()->withTracker(mock('Tracker'))->build();
     stub($this->artifact)->getWorkflow()->returns($this->workflow);
     $this->changeset = mock('Tracker_Artifact_Changeset');
     $this->changeset_value1 = mock('Tracker_Artifact_ChangesetValue');
     $this->changeset_value2 = mock('Tracker_Artifact_ChangesetValue');
     $this->changeset_value3 = mock('Tracker_Artifact_ChangesetValue');
     stub($this->changeset)->getValue($this->field1)->returns($this->changeset_value1);
     $this->artifact_update = aMockArtifact()->withTracker(mock('Tracker'))->withlastChangeset($this->changeset)->build();
     stub($this->artifact_update)->getWorkflow()->returns($this->workflow);
 }
 public function setUp()
 {
     parent::setUp();
     $this->dao = mock('AgileDashboard_BacklogItemDao');
     $this->artifact_factory = mock('Tracker_ArtifactFactory');
     $this->form_element_factory = mock('Tracker_FormElementFactory');
     $this->milestone_factory = mock('Planning_MilestoneFactory');
     $this->planning_factory = mock('PlanningFactory');
     $this->backlog_item_builder = new AgileDashboard_Milestone_Backlog_BacklogItemBuilder();
     $this->user = mock('PFUser');
     $planning = mock('Planning');
     stub($planning)->getBacklogTrackers()->returns(array(mock('Tracker')));
     stub($planning)->getPlanningTracker()->returns(mock('Tracker'));
     $artifact = aMockArtifact()->build();
     $this->milestone = aMilestone()->withArtifact($artifact)->withPlanning($planning)->build();
     $this->factory = partial_mock('AgileDashboard_Milestone_Backlog_BacklogItemCollectionFactory', array('userCanReadBacklogTitleField', 'userCanReadBacklogStatusField', 'getInitialEffortField'), array($this->dao, $this->artifact_factory, $this->form_element_factory, $this->milestone_factory, $this->planning_factory, $this->backlog_item_builder));
     stub($this->factory)->userCanReadBacklogTitleField()->returns(true);
     stub($this->factory)->userCanReadBacklogStatusField()->returns(true);
     $this->tracker1 = mock('Tracker');
     $this->tracker2 = mock('Tracker');
     $this->tracker3 = mock('Tracker');
     $this->story1 = anArtifact()->userCanView($this->user)->withTitle('story 1')->withId($this->open_story_id)->withTracker($this->tracker1)->build();
     $this->story2 = anArtifact()->userCanView($this->user)->withTitle('story 2')->withId($this->open_unplanned_story_id)->withTracker($this->tracker2)->build();
     $this->story3 = anArtifact()->userCanView($this->user)->withTitle('story 3')->withId($this->closed_story_id)->withTracker($this->tracker3)->build();
     $backlog_items = new AgileDashboard_Milestone_Backlog_DescendantItemsCollection();
     $backlog_items->push($this->story1);
     $backlog_items->push($this->story2);
     $backlog_items->push($this->story3);
     $this->backlog_strategy = stub('AgileDashboard_Milestone_Backlog_BacklogStrategy')->getArtifacts($this->user)->returns($backlog_items);
     stub($this->backlog_strategy)->getMilestoneBacklogArtifactsTracker()->returns(mock('Tracker'));
     $this->redirect_to_self = 'whatever';
     stub($this->dao)->getArtifactsSemantics()->returnsDar(array('id' => $this->open_story_id, Tracker_Semantic_Title::NAME => 'Story is open', Tracker_Semantic_Status::NAME => AgileDashboard_BacklogItemDao::STATUS_OPEN), array('id' => $this->open_unplanned_story_id, Tracker_Semantic_Title::NAME => 'Story is open and unplanned', Tracker_Semantic_Status::NAME => AgileDashboard_BacklogItemDao::STATUS_OPEN), array('id' => $this->closed_story_id, Tracker_Semantic_Title::NAME => 'Story is closed', Tracker_Semantic_Status::NAME => AgileDashboard_BacklogItemDao::STATUS_CLOSED));
     $sub_milestone1 = stub('Planning_Milestone')->getArtifactId()->returns(121);
     $sub_milestone2 = stub('Planning_Milestone')->getArtifactId()->returns(436);
     stub($this->milestone_factory)->getSubMilestones()->returns(array($sub_milestone1, $sub_milestone2));
     stub($this->artifact_factory)->getParents()->returns(array());
 }
コード例 #18
0
 public function itIntegratesWithThe_ArtifactNodeTreeProvider()
 {
     $plugin = $id = $report = $name = $description = $rank = $field_id = $enable_qr_code = null;
     $renderer = new Cardwall_Renderer(mock('Plugin'), mock('Cardwall_OnTop_Config'), $id, $report, $name, $description, $rank, $field_id, $enable_qr_code);
     $artifact_factory = mock('Tracker_ArtifactFactory');
     $artifact4 = aMockArtifact()->withId(4)->build();
     $artifact5 = aMockArtifact()->withId(5)->build();
     $artifact6 = aMockArtifact()->withId(6)->build();
     stub($artifact_factory)->getArtifactById(4)->returns($artifact4);
     stub($artifact_factory)->getArtifactById(5)->returns($artifact5);
     stub($artifact_factory)->getArtifactById(6)->returns($artifact6);
     $root_node = $renderer->getForestsOfArtifacts(array(4, 5, 6), $artifact_factory);
     $this->assertTrue($root_node->hasChildren());
     $this->assertTrue($root_node->getChild(0)->hasChildren());
     $tasks = $root_node->getChild(0)->getChildren();
     $this->assertEqual(3, count($tasks));
     foreach ($tasks as $task) {
         $id = $task->getId();
         $this->assertBetweenClosedInterval($id, 4, 6);
         $artifact = $task->getArtifact();
         $this->assertBetweenClosedInterval($artifact->getId(), 4, 6);
         $this->assertIsA($artifact, 'Tracker_Artifact');
     }
 }
コード例 #19
0
 public function itDisplaysASelectorOfArtifactWhenThereAreNoMilestoneSelected()
 {
     $project = mock('Project');
     $planning = mock('Planning');
     $current_milstone = new Planning_NoMilestone($project, $planning);
     $milstone_1001 = aMilestone()->withArtifact(aMockArtifact()->withId(1001)->withTitle('An open artifact')->build())->build();
     $milstone_1002 = aMilestone()->withArtifact(aMockArtifact()->withId(1002)->withTitle('Another open artifact')->build())->build();
     stub($this->milestone_factory)->getMilestoneWithPlannedArtifactsAndSubMilestones()->returns($current_milstone);
     stub($this->milestone_factory)->getAllMilestones($this->current_user, $planning)->returns(array($milstone_1001, $milstone_1002));
     $this->controller = new Planning_MilestoneControllerTrapPresenter($this->request, $this->milestone_factory, $this->project_manager);
     $selectable_artifacts = $this->getSelectableArtifacts();
     $this->assertCount($selectable_artifacts, 2);
     $this->assertEqual(array_shift($selectable_artifacts), array('id' => 1001, 'title' => 'An open artifact', 'selected' => ''));
     $this->assertEqual(array_shift($selectable_artifacts), array('id' => 1002, 'title' => 'Another open artifact', 'selected' => ''));
 }
コード例 #20
0
 public function setUp()
 {
     parent::setUp();
     $this->fields_data = array();
     $this->submitter = aUser()->withId(74)->build();
     $this->changeset_dao = mock('Tracker_Artifact_ChangesetDao');
     $this->changesets = array(new Tracker_Artifact_Changeset_Null());
     $factory = mock('Tracker_FormElementFactory');
     stub($factory)->getAllFormElementsForTracker()->returns(array());
     stub($factory)->getUsedFields()->returns(array());
     $this->artifact_factory = mock('Tracker_ArtifactFactory');
     $this->workflow = mock('Workflow');
     $this->changeset_factory = mock('Tracker_Artifact_ChangesetFactory');
     stub($this->changeset_factory)->getChangeset()->returns(new Tracker_Artifact_Changeset(123, aMockArtifact()->build(), 12, 21, ''));
     $tracker = stub('Tracker')->getWorkflow()->returns($this->workflow);
     $this->artifact = anArtifact()->withId(42)->withChangesets($this->changesets)->withTracker($tracker)->build();
     $this->submitted_on = $_SERVER['REQUEST_TIME'];
     $fields_validator = mock('Tracker_Artifact_Changeset_NewChangesetFieldsValidator');
     stub($fields_validator)->validate()->returns(true);
     $comment_dao = stub('Tracker_Artifact_Changeset_CommentDao')->createNewVersion()->returns(true);
     $this->creator = new Tracker_Artifact_Changeset_NewChangesetCreator($fields_validator, $factory, $this->changeset_dao, $comment_dao, $this->artifact_factory, mock('EventManager'), mock('ReferenceManager'));
 }
コード例 #21
0
 private function getArtifact($id, Tracker $tracker, array $ancestors)
 {
     reset($ancestors);
     $parent = current($ancestors);
     $artifact = aMockArtifact()->withId($id)->withTracker($tracker)->withParent($parent)->build();
     $milestone = mock('Planning_ArtifactMilestone');
     stub($artifact)->getAllAncestors($this->user)->returns($ancestors);
     stub($this->artifact_factory)->getArtifactById($id)->returns($artifact);
     stub($this->milestone_factory)->getMilestoneFromArtifactWithPlannedArtifacts(new EqualExpectation($artifact), $this->user)->returns($milestone);
     return array($artifact, $milestone);
 }
コード例 #22
0
 private function getArtifact($id, Tracker $tracker)
 {
     $artifact = aMockArtifact()->withId($id)->withTracker($tracker)->build();
     stub($this->artifact_factory)->getArtifactById($id)->returns($artifact);
     return $artifact;
 }
コード例 #23
0
ファイル: CreateArtifactTest.php プロジェクト: nterray/tuleap
 public function itDoesntRedirectWhenNewArtifactAlreadyHasAParent()
 {
     stub($this->new_artifact)->getAllAncestors()->returns(array(aMockArtifact()->build()));
     stub($this->tracker)->getParent()->returns($this->parent_tracker);
     stub($this->formelement_factory)->getAnArtifactLinkField()->returns($this->art_link_field);
     $this->action->redirectToParentCreationIfNeeded($this->new_artifact, $this->current_user, $this->redirect);
     $this->assertNull($this->redirect->query_parameters);
 }
コード例 #24
0
 public function setUp()
 {
     parent::setUp();
     $this->user = mock('PFUser');
     $this->artifact = aMockArtifact()->withLinkedArtifacts(array(anArtifact()->withId(112)->build(), anArtifact()->withId(113)->build(), anArtifact()->withId(114)->build(), anArtifact()->withId(115)->build()))->build();
     $this->milestone = aMilestone()->withArtifact($this->artifact)->build();
     $this->milestone_resource_validator = partial_mock('Tuleap\\AgileDashboard\\REST\\v1\\MilestoneResourceValidator', array('validateArtifactsFromBodyContentWithClosedItems'));
 }
コード例 #25
0
ファイル: MilestoneTest.php プロジェクト: nterray/tuleap
 public function itGetsTheLinkedArtifactsOfChildNodes()
 {
     $root_artifact = aMockArtifact()->withId(9999)->withTitle('root artifact')->build();
     $linked_artifact_1 = aMockArtifact()->build();
     $linked_artifact_2 = aMockArtifact()->build();
     $artifact = aMockArtifact()->withId(1111)->withUniqueLinkedArtifacts(array($linked_artifact_1, $linked_artifact_2))->build();
     $planned_artifacts = aNode()->withObject($root_artifact)->withChild(aNode()->withObject($artifact))->build();
     $milestone = new Planning_ArtifactMilestone($this->project, mock('Planning'), $root_artifact, $planned_artifacts);
     $all_artifacts = $milestone->getLinkedArtifacts(mock('User'));
     $this->assertEqual(count($all_artifacts), 3);
 }
コード例 #26
0
 public function itDoesntCountSubElementsNotReadable()
 {
     stub($this->artifact_factory)->getArtifactById(36)->returns(aMockArtifact()->allUsersCanView()->build());
     stub($this->artifact_factory)->getArtifactById(37)->returns(aMockArtifact()->build());
     // userCanView will return false by default
     stub($this->artifact_factory)->getArtifactById(38)->returns(aMockArtifact()->allUsersCanView()->build());
     stub($this->backlog_dao)->getBacklogArtifacts(12)->returnsDar(array('id' => 36));
     stub($this->artifact_dao)->getArtifactsStatusByIds(array(36))->returnsDar(array('id' => 36, 'status' => Tracker_Artifact::STATUS_OPEN));
     stub($this->artifact_dao)->getChildrenForArtifacts()->returnsDar(array('id' => 37), array('id' => 38));
     stub($this->artifact_dao)->getArtifactsStatusByIds(array(38))->returnsDar(array('id' => 38, 'status' => Tracker_Artifact::STATUS_OPEN));
     $result = $this->counter->getStatus($this->user, 12);
     $this->assertEqual($result, array(Tracker_Artifact::STATUS_OPEN => 2, Tracker_Artifact::STATUS_CLOSED => 0));
 }
コード例 #27
0
 public function itDoesntLinkWhenItWasLinkedToAParent()
 {
     $story_id = 5698;
     $story = aMockArtifact()->withId($story_id)->build();
     $task = aMockArtifact()->withId(2)->build();
     stub($task)->getAllAncestors($this->user)->returns(array($story));
     $story->expectNever('linkArtifact');
     $this->request = aRequest()->with('link-artifact-id', "{$this->release_id}")->withUser($this->user)->build();
     $this->linker->linkBacklogWithPlanningItems($this->request, $task);
 }
コード例 #28
0
 public function itReturnsTheLastOpenArtifactOfPlanningTracker()
 {
     stub($this->artifact_factory)->getOpenArtifactsByTrackerIdUserCanView($this->current_user, $this->planning_tracker_id)->returns(array('115' => $this->sprint_1_artifact, '104' => aMockArtifact()));
     stub($this->milestone_factory)->getMilestoneFromArtifact($this->sprint_1_artifact)->returns($this->sprint_1_milestone);
     $milestone = $this->milestone_factory->getCurrentMilestone($this->current_user, $this->planning_id);
     $this->assertEqual($milestone, $this->sprint_1_milestone);
 }
コード例 #29
0
 public function __only__itReturnsNullWhenUserCannotSeeArtifacts()
 {
     $planning_tracker = aTracker()->withId(12)->withProject(mock('Project'))->build();
     stub($this->planning_factory)->getPlanningByPlanningTracker()->returns(aPlanning()->withId(4)->build());
     $artifact = aMockArtifact()->build();
     stub($artifact)->userCanView($this->user)->returns(false);
     stub($this->artifact_factory)->getArtifactById($this->artifact_id)->returns($artifact);
     $this->assertNull($this->milestone_factory->getBareMilestoneByArtifactId($this->user, $this->artifact_id));
 }
コード例 #30
0
 public function setUp()
 {
     parent::setUp();
     $this->user = aUser()->build();
     $this->hierarchy_factory = partial_mock('Tracker_HierarchyFactory', array('getParentArtifact'));
     $this->sprint_1 = anArtifact()->withId(1)->build();
     $this->sprint_2 = anArtifact()->withId(2)->build();
     $this->release_1 = aMockArtifact()->withId(101)->build();
 }