public function setUp() { parent::setUp(); $this->artifact = anArtifact()->withId(9787)->build(); $this->data = array('somekey' => 'somevalue'); $this->node = new ArtifactNode($this->artifact, $this->data); }
public function setUp() { parent::setUp(); $tracker_factory = mock('TrackerFactory'); $this->xml_importer = mock('Tracker_Artifact_XMLImport'); $this->artifact_factory = mock('Tracker_ArtifactFactory'); $this->children_collector = new Tracker_XML_ChildrenCollector(); $this->importer = new Tracker_XML_Importer_ChildrenXMLImporter($this->xml_importer, $tracker_factory, $this->artifact_factory, $this->children_collector); $this->artifacts_imported_mapping = mock('Tracker_XML_Importer_ArtifactImportedMapping'); $this->tracker = aTracker()->withId(23)->build(); stub($tracker_factory)->getTrackerById(23)->returns($this->tracker); $this->tracker_2 = aTracker()->withId(24)->build(); stub($tracker_factory)->getTrackerById(24)->returns($this->tracker_2); $this->user = aUser()->build(); $artlink_field = anArtifactLinkField()->withId($this->field_id)->build(); $artlink_field_2 = anArtifactLinkField()->withId($this->field_id_2)->build(); $root_artifact_id = 456; $this->root_artifact = mock('Tracker_Artifact'); stub($this->root_artifact)->getId()->returns($root_artifact_id); stub($this->root_artifact)->getAnArtifactLinkField($this->user)->returns($artlink_field); stub($this->artifact_factory)->getArtifactById($root_artifact_id)->returns($this->root_artifact); $this->created_artifact = mock('Tracker_Artifact'); stub($this->created_artifact)->getId()->returns(1023); stub($this->created_artifact)->getAnArtifactLinkField($this->user)->returns($artlink_field_2); stub($this->artifact_factory)->getArtifactById(1023)->returns($this->created_artifact); $this->another_child_artifact = anArtifact()->withId(1024)->build(); stub($this->artifact_factory)->getArtifactById(1024)->returns($this->another_child_artifact); }
public function __construct() { $this->project = mock('Project'); $this->planning = aPlanning()->build(); $this->sub_milestones = array(); $this->artifact = anArtifact()->build(); }
public function setUp() { parent::setUp(); $this->milestone_1_id = 132; $this->milestone_1 = stub('Planning_ArtifactMilestone')->getArtifactId()->returns($this->milestone_1_id); $this->milestone_2_id = 853; $this->milestone_2 = stub('Planning_ArtifactMilestone')->getArtifactId()->returns($this->milestone_2_id); $this->virtual_top_milestone = stub('Planning_VirtualTopMilestone')->getArtifactId()->returns(null); $this->strategy_1 = mock('AgileDashboard_Milestone_Backlog_DescendantBacklogStrategy'); $this->strategy_2 = mock('AgileDashboard_Milestone_Backlog_DescendantBacklogStrategy'); $this->strategy_factory = mock('AgileDashboard_Milestone_Backlog_BacklogStrategyFactory'); stub($this->strategy_factory)->getBacklogStrategy($this->milestone_1)->returns($this->strategy_1); stub($this->strategy_factory)->getBacklogStrategy($this->milestone_2)->returns($this->strategy_2); $this->backlog_item_collection_factory = mock('AgileDashboard_Milestone_Backlog_BacklogItemCollectionFactory'); $this->sequence_id_manager = new AgileDashboard_SequenceIdManager($this->strategy_factory, $this->backlog_item_collection_factory); $this->user = aUser()->build(); $this->artifact_id_1 = 123; $this->artifact_id_2 = 456; $this->artifact_id_3 = 789; $this->artifact_1 = anArtifact()->withId($this->artifact_id_1)->build(); $this->artifact_2 = anArtifact()->withId($this->artifact_id_2)->build(); $this->artifact_3 = anArtifact()->withId($this->artifact_id_3)->build(); $this->artifact_id_4 = 254; $this->artifact_id_5 = 255; $this->artifact_id_6 = 256; $this->artifact_4 = anArtifact()->withId($this->artifact_id_4)->build(); $this->artifact_5 = anArtifact()->withId($this->artifact_id_5)->build(); $this->artifact_6 = anArtifact()->withId($this->artifact_id_6)->build(); $this->backlog_item_1 = stub('AgileDashboard_Milestone_Backlog_BacklogItem')->getArtifact()->returns($this->artifact_1); $this->backlog_item_2 = stub('AgileDashboard_Milestone_Backlog_BacklogItem')->getArtifact()->returns($this->artifact_2); $this->backlog_item_3 = stub('AgileDashboard_Milestone_Backlog_BacklogItem')->getArtifact()->returns($this->artifact_3); $this->items_collection = new AgileDashboard_Milestone_Backlog_BacklogItemCollection(); }
public function setUp() { parent::setUp(); $this->tracker = aTracker()->build(); $this->artifact_builder = anArtifact()->withTracker($this->tracker)->withChangesets(array(new Tracker_Artifact_Changeset_Null())); $this->formelement_factory = mock('Tracker_FormElementFactory'); $this->initializator = new Tracker_Artifact_Changeset_ChangesetDataInitializator($this->formelement_factory); }
public function setUp() { parent::setUp(); $this->trigger_rules_manager = mock('Tracker_Workflow_Trigger_RulesManager'); $this->field = anArtifactLinkField()->build(); $this->artifact = anArtifact()->build(); $this->user = aUser()->build(); $this->command = new Tracker_FormElement_Field_ArtifactLink_ProcessChildrenTriggersCommand($this->field, $this->trigger_rules_manager); }
public function setUp() { parent::setUp(); $this->client = mock('FullTextSearch_IIndexDocuments'); $this->tracker_data_factory = mock('ElasticSearch_1_2_RequestTrackerDataFactory'); $this->logger = mock('Logger'); $this->tracker = aTracker()->withId(455)->build(); $this->artifact = anArtifact()->withId(44)->withTracker($this->tracker)->build(); $this->actions = new FullTextSearchTrackerActions($this->client, $this->tracker_data_factory, $this->logger); }
public function setUp() { parent::setUp(); $this->setUpUsers(); $this->project = stub('Project')->getId()->returns($this->project_id); $this->tracker = aMockTracker()->withId(120)->withProject($this->project)->build(); $this->artifact_builder = anArtifact()->withTracker($this->tracker); $this->assignee_retriever = mock('Tracker_Permission_PermissionRetrieveAssignee'); $this->serializer = new Tracker_Permission_PermissionsSerializer($this->assignee_retriever); }
public function setUp() { parent::setUp(); $this->artifact_id = 123; $this->artifact = anArtifact()->withId($this->artifact_id)->build(); $this->milestone = aMilestone()->withArtifact($this->artifact)->build(); $this->user = aUser()->build(); $this->project = mock('Project'); $this->milestone_factory = stub('Planning_MilestoneFactory')->getBareMilestoneByArtifactId($this->user, $this->artifact_id)->returns($this->milestone); }
public function itCopiesAllTreeNodesIntoCardPresenterNodes() { $root_node = aNode()->withChildren(aNode()->withObject(anArtifact()->withTracker(mock('Tracker'))->withoutParent()->build()), aNode()->withObject(anArtifact()->withTracker(mock('Tracker'))->withoutParent()->build()))->build(); $card_mapper = new TreeNodeMapper(new Planning_ItemCardPresenterCallback(mock('Planning'), mock('Tracker_CardFields'), mock('User'), 'whatever-class')); $visited_node = $card_mapper->map($root_node); $all_nodes = $visited_node->flattenChildren(); $this->assertEqual(count($all_nodes), count($root_node->flattenChildren())); foreach ($all_nodes as $node) { $this->assertIsA($node, 'Tracker_TreeNode_CardPresenterNode'); } }
public function setUp() { parent::setUp(); $this->milestone = aMilestone()->withArtifact(anArtifact()->withId(3)->build())->build(); $this->backlog_tracker = aTracker()->withId(35)->build(); $this->dao = mock('Tracker_ArtifactDao'); $this->user = aUser()->build(); $this->strategy_factory = mock('AgileDashboard_Milestone_Backlog_BacklogStrategyFactory'); $this->backlog_item_collection_factory = mock('AgileDashboard_Milestone_Backlog_BacklogItemCollectionFactory'); $this->provider = new AgileDashboard_BacklogItem_SubBacklogItemProvider($this->dao, $this->strategy_factory, $this->backlog_item_collection_factory); }
public function itDoesNothingIfTheArtifactTrackerIsNotInParentMilestoneBacklogTrackers() { $artifact_added = anArtifact()->withId(101)->withTrackerId(201)->build(); $parent_milestone_artifact = mock('Tracker_Artifact'); $parent_milestone = stub('Planning_Milestone')->getArtifact()->returns($parent_milestone_artifact); $descendant_tracker = aTracker()->withId(202)->build(); stub($this->strategy)->getDescendantTrackers()->returns(array($descendant_tracker)); stub($this->milestone)->getParent()->returns($parent_milestone); expect($parent_milestone_artifact)->linkArtifact()->never(); $this->milestone_parent_linker->linkToMilestoneParent($this->milestone, $this->user, $artifact_added); }
public function setUp() { $this->reference_manager = mock('ReferenceManager'); $this->artifact_factory = mock('Tracker_ArtifactFactory'); $this->tracker_reference_manager = new Tracker_ReferenceManager($this->reference_manager, $this->artifact_factory); $this->keyword = 'art'; $this->artifact_id = 101; $tracker = aTracker()->withId(101)->withName('My tracker')->build(); $this->artifact = anArtifact()->withId(101)->withTracker($tracker)->build(); $GLOBALS['Language'] = mock('BaseLanguage'); }
public function setUp() { parent::setUp(); $this->planning_id = '321'; $this->user = aUser()->withId(12)->build(); $this->request = aRequest()->with('planning_id', $this->planning_id)->withUser($this->user)->build(); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->current_milestone_artifact_id = 444; $milestone = aMilestone()->withArtifact(anArtifact()->withId($this->current_milestone_artifact_id)->build())->build(); stub($this->milestone_factory)->getCurrentMilestone($this->user, $this->planning_id)->returns($milestone); }
public function itIgnoresPresentersIfThereIsNoMatchingColumn() { $artifact = anArtifact()->build(); $column = new Cardwall_Column(55, null, null, null); $columns = new Cardwall_OnTop_Config_ColumnCollection(); $columns[] = $column; $cardincell_presenter = stub('Cardwall_CardInCellPresenter')->getArtifact()->returns($artifact); stub($this->config)->isInColumn($artifact, '*', $column)->returns(false); $swimlines = $this->factory->getCells($columns, array($cardincell_presenter)); $expected = array(array('column_id' => 55, 'column_stacked' => true, 'cardincell_presenters' => array())); $this->assertIdentical($expected, $swimlines); }
public function setUp() { parent::setUp(); $this->card_in_cell_presenter_builder = mock('Cardwall_CardInCellPresenterBuilder'); $this->artifact_factory = mock('Tracker_ArtifactFactory'); $this->dao = mock('AgileDashboard_BacklogItemDao'); $this->swimline_factory = mock('Cardwall_SwimlineFactory'); $this->user = aUser()->build(); $this->milestone_artifact = anArtifact()->withId(1)->build(); $this->mapping_collection = mock('Cardwall_MappingCollection'); $this->columns = mock('Cardwall_OnTop_Config_ColumnCollection'); }
public function itComputesRemainingEffortAtAGivenTime() { $timestamp = mktime(23, 59, 59, 7, 3, 2012); $sub_artifact1 = anArtifact()->withId(1)->withTracker(aTracker()->build())->build(); $sub_artifact2 = anArtifact()->withId(2)->withTracker(aTracker()->build())->build(); $artifact = stub('Tracker_Artifact')->getLinkedArtifacts()->returns(array($sub_artifact1, $sub_artifact2)); $field = mock('Tracker_FormElement_Field_Float'); stub($field)->getComputedValue($this->user, $sub_artifact1, $timestamp, '*')->returns(5); stub($field)->getComputedValue($this->user, $sub_artifact2, $timestamp, '*')->returns(15); stub($this->formelement_factory)->getComputableFieldByNameForUser()->returns($field); $this->assertEqual(20, $this->field->getComputedValue($this->user, $artifact, $timestamp)); }
public function setUp() { parent::setUp(); ForgeConfig::store(); ForgeConfig::set('codendi_dir', AGILEDASHBOARD_BASE_DIR . '/../../..'); $this->planning_id = '321'; $this->user = aUser()->withId(12)->build(); $this->request = aRequest()->with('planning_id', $this->planning_id)->withUser($this->user)->build(); $this->milestone_factory = mock('Planning_MilestoneFactory'); $this->current_milestone_artifact_id = 444; $milestone = aMilestone()->withArtifact(anArtifact()->withId($this->current_milestone_artifact_id)->build())->build(); stub($this->milestone_factory)->getLastMilestoneCreated($this->user, $this->planning_id)->returns($milestone); }
public function itExportsTheFullHistory() { $changeset_01 = mock('Tracker_Artifact_Changeset'); $changeset_02 = mock('Tracker_Artifact_Changeset'); $changeset_03 = mock('Tracker_Artifact_Changeset'); $artifacts_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?> <tracker> <artifacts/> </tracker>'); $changesets = array($changeset_01, $changeset_02, $changeset_03); $artifact = anArtifact()->withId(101)->withChangesets($changesets)->build(); $this->changeset_exporter->expectCallCount('exportFullHistory', 3); $this->exporter->exportFullHistory($artifacts_xml, $artifact); }
public function setUp() { parent::setUp(); $this->story_tracker = aTracker()->withId(888)->build(); $this->task_tracker = aTracker()->withId(899)->build(); $this->parent = mock('Tracker_Artifact'); stub($this->parent)->getTracker()->returns($this->story_tracker); $this->artifact = anArtifact()->withChangesets(array(mock('Tracker_Artifact_Changeset')))->withParentWithoutPermissionChecking($this->parent)->withTracker($this->task_tracker)->build(); $this->target_field_id = 569; $this->target_field = aSelectBoxField()->withId($this->target_field_id)->withTracker($this->story_tracker)->build(); $this->target_value_id = 7; $this->target_value = aBindStaticValue()->withId($this->target_value_id)->build(); $this->trigger_field = aSelectBoxField()->withId(965)->withTracker($this->task_tracker)->build(); $this->trigger_value = aBindStaticValue()->withId(14)->build(); $this->rule = aTriggerRule()->applyValue(new Tracker_Workflow_Trigger_FieldValue($this->target_field, $this->target_value))->whenAllOf()->childHas(new Tracker_Workflow_Trigger_FieldValue($this->trigger_field, $this->trigger_value))->build(); }
public function setUp() { parent::setUp(); $this->dao = mock('Tracker_Artifact_Changeset_IncomingMailDao'); stub($this->dao)->searchByArtifactId(123)->returnsDar(array('changeset_id' => 1, 'raw_mail' => $this->raw_mail_creation), array('changeset_id' => 2, 'raw_mail' => $this->raw_mail_update)); stub($this->dao)->searchByArtifactId(456)->returnsEmptyDar(); $this->changeset_by_mail = stub('Tracker_Artifact_Changeset')->getId()->returns(1); $this->other_changeset_by_mail = stub('Tracker_Artifact_Changeset')->getId()->returns(2); $this->artifact_by_mail = anArtifact()->withId(123)->withChangesets(array($this->changeset_by_mail, $this->other_changeset_by_mail))->build(); stub($this->changeset_by_mail)->getArtifact()->returns($this->artifact_by_mail); stub($this->other_changeset_by_mail)->getArtifact()->returns($this->artifact_by_mail); $this->changeset_by_web = stub('Tracker_Artifact_Changeset')->getId()->returns(3); $this->artifact_by_web = anArtifact()->withId(456)->withChangesets(array($this->changeset_by_web, aChangeset()->withId(4)->build()))->build(); stub($this->changeset_by_web)->getArtifact()->returns($this->artifact_by_web); $this->retriever = new Tracker_Artifact_Changeset_IncomingMailGoldenRetriever($this->dao); }
public function setUp() { parent::setUp(); $this->artifact_xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><artifacts />'); $this->artifact_xml_exporter = new Tracker_XML_Exporter_ChildrenXMLExporterTest_ArtifactXMLExporter(); $this->file_updater = mock('Tracker_XML_Updater_TemporaryFileXMLUpdater'); $this->artifact_factory = mock('Tracker_ArtifactFactory'); $artifact_1 = anArtifact()->withId($this->artifact_id_1)->build(); $artifact_2 = anArtifact()->withId($this->artifact_id_2)->build(); $this->last_changeset_1 = aChangeset()->withArtifact($artifact_1)->build(); $this->last_changeset_2 = aChangeset()->withArtifact($artifact_2)->build(); $artifact_1->setChangesets(array($this->last_changeset_1)); $artifact_2->setChangesets(array($this->last_changeset_2)); stub($this->artifact_factory)->getArtifactById($this->artifact_id_1)->returns($artifact_1); stub($this->artifact_factory)->getArtifactById($this->artifact_id_2)->returns($artifact_2); $this->collector = new Tracker_XML_ChildrenCollector(); $this->exporter = new Tracker_XML_Exporter_ChildrenXMLExporter($this->artifact_xml_exporter, $this->file_updater, $this->artifact_factory, $this->collector); }
public function itRetrieveRemainingEffortEvolutionFromSeveralSubTrackers() { $task_tracker_id = 120; $task_tracker = aTracker()->withId($task_tracker_id)->build(); $task_54 = anArtifact()->withId(54)->withTracker($task_tracker)->build(); $task_ids = array(54); $bug_tracker_id = 126; $bug_tracker = aTracker()->withId($bug_tracker_id)->build(); $bug_55 = anArtifact()->withId(55)->withTracker($bug_tracker)->build(); $bug_ids = array(55); $linked_artifacts = array($task_54, $bug_55); $tasks_effort_field_id = 35; $tasks_effort_field = stub('Tracker_FormElement_Field_Float')->getId()->returns($tasks_effort_field_id); stub($this->form_element_factory)->getType($tasks_effort_field)->returns(self::EFFORT_FIELD_TYPE); stub($this->form_element_factory)->getUsedFieldByNameForUser($task_tracker_id, 'remaining_effort', $this->current_user)->returns($tasks_effort_field); $bugs_effort_field_id = 37; $bugs_effort_field = stub('Tracker_FormElement_Field_Float')->getId()->returns($bugs_effort_field_id); stub($this->form_element_factory)->getType($bugs_effort_field)->returns(self::EFFORT_FIELD_TYPE); stub($this->form_element_factory)->getUsedFieldByNameForUser($bug_tracker_id, 'remaining_effort', $this->current_user)->returns($bugs_effort_field); $this->dao->expectAt(0, 'searchRemainingEffort', array($tasks_effort_field_id, self::EFFORT_FIELD_TYPE, $task_ids)); $this->dao->expectAt(1, 'searchRemainingEffort', array($bugs_effort_field_id, self::EFFORT_FIELD_TYPE, $bug_ids)); $this->burndown_data->__construct($linked_artifacts, 'remaining_effort', $this->current_user); }
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()); }
public function itExportsTheArtifactToXML() { $user = aUser()->withId(101)->withLdapId('ldap_O1')->withUserName('user_01')->build(); stub($this->user_manager)->getUserById(101)->returns($user); stub($this->formelement_factory)->getUsedFileFields()->returns(array()); $changeset_01 = stub('Tracker_Artifact_Changeset')->getsubmittedBy()->returns(101); $changeset_02 = stub('Tracker_Artifact_Changeset')->getsubmittedBy()->returns(101); $project = stub('Project')->getID()->returns(101); $tracker = aTracker()->withId(101)->withProject($project)->build(); $artifact = anArtifact()->withTracker($tracker)->withId(101)->withChangesets(array($changeset_01, $changeset_02))->build(); $artifacts_node = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?> <artifacts/>'); $text_field_01 = stub('Tracker_FormElement_Field_Text')->getName()->returns('text_01'); stub($text_field_01)->getTracker()->returns($tracker); $value_01 = new Tracker_Artifact_ChangesetValue_Text(1, $text_field_01, true, 'value_01', 'text'); $value_02 = new Tracker_Artifact_ChangesetValue_Text(2, $text_field_01, true, 'value_02', 'text'); stub($changeset_01)->getArtifact()->returns($artifact); stub($changeset_01)->getValues()->returns(array($value_01)); stub($changeset_02)->getArtifact()->returns($artifact); stub($changeset_02)->getValues()->returns(array($value_02)); $archive = new ZipArchive(); $artifact->exportToXML($artifacts_node, $user, $archive); $this->assertEqual($artifacts_node->artifact['id'], 101); }
public function itLinksRawEmailToCreatedChangeset() { $artifact = anArtifact()->withChangesets(array($this->changeset))->withTracker($this->tracker)->build(); stub($this->incoming_message)->isAFollowUp()->returns(false); stub($this->artifact_factory)->createArtifact()->returns($artifact); stub($this->tracker)->userCanSubmitArtifact()->returns(true); expect($this->incoming_mail_dao)->save(666, $this->raw_email)->once(); $this->mailgateway->process($this->raw_email); }
public function setUp() { parent::setUp(); $id = $tracker_id = $parent_id = $description = $use_it = $scope = $required = $notifications = $rank = ''; $name = 'foo'; $label = 'Foo Bar'; $this->field = partial_mock('Tracker_FormElement_Field_Computed', array('getComputedValue', 'userCanRead'), array($id, $tracker_id, $parent_id, $name, $label, $description, $use_it, $scope, $required, $notifications, $rank)); $this->artifact = anArtifact()->build(); $this->user = aUser()->build(); $this->changeset = mock('Tracker_Artifact_Changeset'); stub($this->changeset)->getArtifact()->returns($this->artifact); }
public function itExportsArtifactsInXML() { $user_01 = aUser()->withId(101)->withLdapId('ldap_01')->withUserName('user_01')->build(); $user_02 = aUser()->withId(102)->withLdapId('ldap_02')->withUserName('user_02')->build(); stub($this->user_manager)->getUserById(101)->returns($user_01); stub($this->user_manager)->getUserById(102)->returns($user_02); stub($this->formelement_factory)->getUsedFileFields()->returns(array()); $project = stub('Project')->getID()->returns(101); $tracker = aTracker()->withId(101)->withProject($project)->build(); $timestamp_01 = '1433863107'; $timestamp_02 = '1433949507'; $timestamp_03 = '1434035907'; $timestamp_04 = '1434122307'; $text_field_01 = stub('Tracker_FormElement_Field_Text')->getName()->returns('text_01'); stub($text_field_01)->getTracker()->returns($tracker); $text_field_02 = stub('Tracker_FormElement_Field_Text')->getName()->returns('text_02'); stub($text_field_02)->getTracker()->returns($tracker); $value_01 = new Tracker_Artifact_ChangesetValue_Text(1, $text_field_01, true, 'value_01', 'text'); $value_02 = new Tracker_Artifact_ChangesetValue_Text(2, $text_field_01, true, 'value_02', 'text'); $value_03 = new Tracker_Artifact_ChangesetValue_Text(3, $text_field_01, true, 'value_03', 'text'); $value_04 = new Tracker_Artifact_ChangesetValue_Text(4, $text_field_01, true, 'value_04', 'text'); $value_05 = new Tracker_Artifact_ChangesetValue_Text(5, $text_field_02, true, 'value_05', 'text'); $value_06 = new Tracker_Artifact_ChangesetValue_Text(6, $text_field_02, true, 'value_06', 'text'); $value_07 = new Tracker_Artifact_ChangesetValue_Text(7, $text_field_02, true, 'value_07', 'text'); $changeset_01 = partial_mock('Tracker_Artifact_Changeset', array('getId', 'getSubmittedBy', 'getSubmittedOn', 'getValues', 'getArtifact', 'getComment')); $changeset_02 = partial_mock('Tracker_Artifact_Changeset', array('getId', 'getSubmittedBy', 'getSubmittedOn', 'getValues', 'getArtifact', 'getComment')); $changeset_03 = partial_mock('Tracker_Artifact_Changeset', array('getId', 'getSubmittedBy', 'getSubmittedOn', 'getValues', 'getArtifact', 'getComment')); $changeset_04 = partial_mock('Tracker_Artifact_Changeset', array('getId', 'getSubmittedBy', 'getSubmittedOn', 'getValues', 'getArtifact', 'getComment')); stub($changeset_01)->getSubmittedBy()->returns(101); stub($changeset_01)->getSubmittedOn()->returns($timestamp_01); stub($changeset_01)->getValues()->returns(array($value_01, $value_02)); stub($changeset_02)->getSubmittedBy()->returns(101); stub($changeset_02)->getSubmittedOn()->returns($timestamp_02); stub($changeset_02)->getValues()->returns(array($value_03, $value_04)); stub($changeset_03)->getSubmittedBy()->returns(101); stub($changeset_03)->getSubmittedOn()->returns($timestamp_03); stub($changeset_03)->getValues()->returns(array($value_05, $value_06)); stub($changeset_04)->getSubmittedBy()->returns(102); stub($changeset_04)->getSubmittedOn()->returns($timestamp_04); stub($changeset_04)->getValues()->returns(array($value_07)); $artifact_01 = anArtifact()->withTracker($tracker)->withId(101)->withChangesets(array($changeset_01, $changeset_02))->build(); $artifact_02 = anArtifact()->withTracker($tracker)->withId(102)->withChangesets(array($changeset_03, $changeset_04))->build(); stub($changeset_01)->getArtifact()->returns($artifact_01); stub($changeset_02)->getArtifact()->returns($artifact_01); stub($changeset_03)->getArtifact()->returns($artifact_02); stub($changeset_04)->getArtifact()->returns($artifact_02); $comment_01 = new Tracker_Artifact_Changeset_Comment(1, $changeset_01, 0, 0, 101, $timestamp_01, '<b> My comment 01</b>', 'html', 0); $comment_02 = new Tracker_Artifact_Changeset_Comment(2, $changeset_02, 0, 0, 101, $timestamp_02, '<b> My comment 02</b>', 'html', 0); $comment_03 = new Tracker_Artifact_Changeset_Comment(3, $changeset_03, 0, 0, 102, $timestamp_03, '<b> My comment 03</b>', 'html', 0); $comment_04 = new Tracker_Artifact_Changeset_Comment(4, $changeset_04, 0, 0, 102, $timestamp_04, '<b> My comment 04</b>', 'html', 0); stub($changeset_01)->getComment()->returns($comment_01); stub($changeset_02)->getComment()->returns($comment_02); stub($changeset_03)->getComment()->returns($comment_03); stub($changeset_04)->getComment()->returns($comment_04); $rng_validator = new XML_RNGValidator(); $artifact_factory = stub('Tracker_ArtifactFactory')->getArtifactsByTrackerId(101)->returns(array($artifact_01, $artifact_02)); $can_bypass_threshold = true; $exporter = new Tracker_Artifact_XMLExport($rng_validator, $artifact_factory, $can_bypass_threshold); $xml_element = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?> <project />'); $admin_user = stub('PFUser')->isSuperUser()->returns(true); $archive = new ZipArchive(); $exporter->export($tracker, $xml_element, $admin_user, $archive); $this->assertNotNull($xml_element->artifacts); $this->assertEqual((string) $xml_element->artifacts->artifact[0]['id'], '101'); $this->assertEqual((string) $xml_element->artifacts->artifact[1]['id'], '102'); $this->assertNotNull($xml_element->artifacts->artifact[0]->changeset); $this->assertCount($xml_element->artifacts->artifact[0]->changeset, 2); $this->assertNotNull($xml_element->artifacts->artifact[1]->changeset); $this->assertCount($xml_element->artifacts->artifact[1]->changeset, 2); }
public function itRaisesAnExeptionIfTheAttachementIsInvalid() { $artifact = anArtifact()->withId($this->artifact_id)->withTracker($this->tracker)->build(); stub($this->artifact_factory)->getArtifactById($this->artifact_id)->returns($artifact); $returns = $this->server->getArtifactAttachmentChunk($this->session_key, $this->artifact_id, 321654, $this->offset, $this->size); $this->assertIsA($returns, 'SoapFault'); }
public function setUp() { parent::setUp(); $this->tracker = aMockTracker()->build(); $artifact = anArtifact()->withTracker($this->tracker)->build(); $this->user = stub('PFUser')->isSuperUser()->returns(true); $this->changeset_id = 1234; $this->changeset = partial_mock('Tracker_Artifact_Changeset', array('getCommentDao', 'getChangesetDao', 'getFormElementFactory', 'getValueDao'), array($this->changeset_id, $artifact, null, null, null)); }