public function setUp() { $this->field_122 = aSelectBoxField()->withId(122)->build(); $this->field_123 = aSelectBoxField()->withId(123)->build(); $this->field_124 = aSelectBoxField()->withId(124)->build(); $this->status_field = aSelectBoxField()->withId(125)->build(); $group_id = 234; $this->tracker = aMockTracker()->withId(3)->withProjectId($group_id)->build(); $this->tracker_10 = aMockTracker()->withId(10)->withStatusField($this->status_field)->build(); $this->tracker_20 = aMockTracker()->withId(20)->build(); $project_trackers = array(3 => $this->tracker, 10 => $this->tracker_10, 20 => $this->tracker_20); $tracker_factory = stub('TrackerFactory')->getTrackersByGroupId($group_id)->returns($project_trackers); foreach ($project_trackers as $t) { stub($tracker_factory)->getTrackerById($t->getId())->returns($t); } $element_factory = mock('Tracker_FormElementFactory'); stub($element_factory)->getFieldById(123)->returns($this->field_123); stub($element_factory)->getFieldById(124)->returns($this->field_124); stub($element_factory)->getUsedSbFields($this->tracker_10)->returns(array($this->field_122, $this->field_123)); stub($element_factory)->getUsedSbFields()->returns(array()); $this->dao = mock('Cardwall_OnTop_ColumnMappingFieldDao'); $this->value_mapping_factory = mock('Cardwall_OnTop_Config_ValueMappingFactory'); stub($this->value_mapping_factory)->getMappings()->returns(array()); stub($this->value_mapping_factory)->getStatusMappings()->returns(array()); $this->columns = new Cardwall_OnTop_Config_ColumnFreestyleCollection(array(new Cardwall_Column(1, 'Todo', 'white', 'black'), new Cardwall_Column(2, 'On Going', 'white', 'black'), new Cardwall_Column(3, 'Done', 'white', 'black'))); $this->factory = new Cardwall_OnTop_Config_TrackerMappingFactory($tracker_factory, $element_factory, $this->dao, $this->value_mapping_factory); }
public function itsFieldIsNull() { $tracker = aMockTracker()->build(); $available_fields = array(); $mapping = new Cardwall_OnTop_Config_TrackerMappingNoField($tracker, $available_fields); $this->assertNull($mapping->getField()); }
public function setUp() { parent::setUp(); $changeset_factory = mock('Tracker_Artifact_ChangesetFactory'); $this->tracker = aMockTracker()->withId(1)->build(); $this->new_artifact = partial_mock('Tracker_Artifact', array('createNewChangeset')); $this->new_artifact->setId($this->new_artifact_id); $this->layout = mock('Tracker_IDisplayTrackerLayout'); $this->user = mock('PFUser'); $this->xml_exporter = mock('Tracker_XML_Exporter_ArtifactXMLExporter'); $this->xml_importer = mock('Tracker_Artifact_XMLImport'); $this->xml_updater = mock('Tracker_XML_Updater_ChangesetXMLUpdater'); $this->file_updater = mock('Tracker_XML_Updater_TemporaryFileXMLUpdater'); $this->from_changeset = stub('Tracker_Artifact_Changeset')->getId()->returns($this->changeset_id); $this->from_artifact = partial_mock('Tracker_Artifact', array('getChangesetFactory')); $this->from_artifact->setId($this->artifact_id); $this->from_artifact->setTracker($this->tracker); $this->from_artifact->setChangesets(array($this->changeset_id => $this->from_changeset)); stub($this->from_artifact)->getChangesetFactory()->returns($changeset_factory); stub($this->from_changeset)->getArtifact()->returns($this->from_artifact); $this->children_xml_exporter = mock('Tracker_XML_Exporter_ChildrenXMLExporter'); $this->children_xml_importer = mock('Tracker_XML_Importer_ChildrenXMLImporter'); $this->artifacts_imported_mapping = mock('Tracker_XML_Importer_ArtifactImportedMapping'); $backend_logger = mock("BackendLogger"); $this->logger = new Tracker_XML_Importer_CopyArtifactInformationsAggregator($backend_logger); $this->submitted_values = array(); $this->artifact_factory = mock('Tracker_ArtifactFactory'); stub($this->artifact_factory)->getArtifactByIdUserCanView($this->user, $this->artifact_id)->returns($this->from_artifact); $this->request = aRequest()->with('from_artifact_id', $this->artifact_id)->with('from_changeset_id', $this->changeset_id)->with('artifact', $this->submitted_values)->build(); $this->action = new Tracker_Action_CopyArtifact($this->tracker, $this->artifact_factory, $this->xml_exporter, $this->xml_importer, $this->xml_updater, $this->file_updater, $this->children_xml_exporter, $this->children_xml_importer, $this->artifacts_imported_mapping, $this->logger); $this->a_mocked_artifact = mock("Tracker_Artifact"); }
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() { $element_factory = mock('Tracker_FormElementFactory'); $this->dao = mock('Cardwall_OnTop_ColumnMappingFieldValueDao'); $this->factory = new Cardwall_OnTop_Config_ValueMappingFactory($element_factory, $this->dao); $this->field_124 = aMockField()->withId(124)->build(); stub($element_factory)->getFieldById(124)->returns($this->field_124); $group_id = 234; $this->tracker = aMockTracker()->withId(3)->withProjectId($group_id)->build(); $this->tracker_20 = aMockTracker()->withId(20)->build(); stub($this->dao)->searchMappingFieldValues($this->tracker->getId())->returnsDar(array('tracker_id' => 10, 'field_id' => 125, 'value_id' => 1000, 'column_id' => 1), array('tracker_id' => 20, 'field_id' => 124, 'value_id' => 1001, 'column_id' => 1)); }
public function setUp() { parent::setUp(); $tracker = aMockTracker()->withId(33)->build(); $swimline_tracker = aMockTracker()->build(); $this->artifact = stub('Tracker_Artifact')->getTracker()->returns($tracker); $this->field = mock('Tracker_FormElement_Field_MultiSelectbox'); $this->field_provider = stub('Cardwall_FieldProviders_IProvideFieldGivenAnArtifact')->getField($this->artifact)->returns($this->field); $dao = mock('Cardwall_OnTop_Dao'); $column_factory = mock('Cardwall_OnTop_Config_ColumnFactory'); $tracker_mapping_factory = mock('Cardwall_OnTop_Config_TrackerMappingFactory'); $this->config = new Cardwall_OnTop_Config($tracker, $swimline_tracker, $dao, $column_factory, $tracker_mapping_factory); }
public function setUp() { parent::setUp(); $planning_tracker_id = 456; $other_tracker_id = 789; $this->planning_tracker = aMockTracker()->withId($planning_tracker_id)->build(); $this->other_tracker = aMockTracker()->withId($other_tracker_id)->build(); $planning = stub('Planning')->getBacklogTrackerId()->returns($planning_tracker_id); $this->artifact = mock('Tracker_Artifact'); $this->node = new TreeNode(); $this->node->setObject($this->artifact); $this->card_mapper = new TreeNodeMapper(new Planning_ItemCardPresenterCallback($planning, mock('Tracker_CardFields'), mock('User'), 'whatever')); }
public function setUp() { $values = array(); foreach (array('new', 'verified', 'fixed') as $i => $value) { ${$value} = mock('Tracker_FormElement_Field_List_Bind_StaticValue'); stub(${$value})->getId()->returns(10 + $i); stub(${$value})->getLabel()->returns(ucfirst($value)); $values[] = ${$value}; } $this->status_field = aMockField()->build(); stub($this->status_field)->getVisibleValuesPlusNoneIfAny()->returns($values); $this->tracker = aMockTracker()->withId(42)->build(); $this->dao = mock('Cardwall_OnTop_ColumnDao'); $this->on_top_dao = mock('Cardwall_OnTop_Dao'); $this->factory = new Cardwall_OnTop_Config_ColumnFactory($this->dao, $this->on_top_dao); }
public function setUp() { $element_factory = mock('Tracker_FormElementFactory'); $this->dao = mock('Cardwall_OnTop_ColumnMappingFieldValueDao'); $column_factory = mock('Cardwall_OnTop_Config_ColumnFactory'); $this->factory = new Cardwall_OnTop_Config_ValueMappingFactory($element_factory, $this->dao); $this->field_123 = aMockField()->withId(123)->build(); $this->field_124 = aMockField()->withId(124)->build(); $this->status_field = aMockField()->withId(125)->build(); stub($this->field_124)->getListValueById(1001)->returns(stub('Tracker_FormElement_Field_List_Value')->getId()->returns(1001)); stub($this->field_124)->getListValueById(1002)->returns(stub('Tracker_FormElement_Field_List_Value')->getId()->returns(1002)); stub($this->status_field)->getListValueById(1000)->returns(stub('Tracker_FormElement_Field_List_Value')->getId()->returns(1000)); stub($element_factory)->getFieldById(123)->returns($this->field_123); stub($element_factory)->getFieldById(124)->returns($this->field_124); stub($element_factory)->getFieldById(125)->returns($this->status_field); $group_id = 234; $this->tracker = aMockTracker()->withId(3)->withProjectId($group_id)->build(); $this->tracker_10 = aMockTracker()->withId(10)->withStatusField($this->status_field)->build(); $this->tracker_20 = aMockTracker()->withId(20)->build(); stub($this->dao)->searchMappingFieldValues($this->tracker->getId())->returns(TestHelper::arrayToDar(array('tracker_id' => 10, 'field_id' => 125, 'value_id' => 1000, 'column_id' => 1), array('tracker_id' => 20, 'field_id' => 124, 'value_id' => 1001, 'column_id' => 1), array('tracker_id' => 20, 'field_id' => 124, 'value_id' => 1002, 'column_id' => 2))); stub($this->status_field)->getVisibleValuesPlusNoneIfAny()->returns(array(new Tracker_FormElement_Field_List_Bind_StaticValue(1001, 'Todo', '', 0, 0), new Tracker_FormElement_Field_List_Bind_StaticValue(1002, 'On Going', '', 0, 0), new Tracker_FormElement_Field_List_Bind_StaticValue(1003, 'Done', '', 0, 0))); }
public function itRendersAWarningForAnyTrackerChildThatHasNoEffortField() { $warning_message = 'Foo'; $this->setText($warning_message, array('plugin_tracker', 'burndown_missing_remaining_effort_warning')); $stories = aMockTracker()->withName('Stories')->havingFormElementWithNameAndType('remaining_effort', array('int', 'float'))->build(); $bugs = aMockTracker()->withName('Bugs')->havingNoFormElement('remaining_effort')->build(); $chores = aMockTracker()->withName('Chores')->havingFormElementWithNameAndType('remaining_effort', array('int', 'date'))->build(); $children = array($stories, $bugs, $chores); $tracker_id = 123; $tracker = aMockTracker()->withId($tracker_id)->build(); $hierarchy_factory = aMockHierarchyFactory()->withChildrenForTrackerId($tracker_id, $children)->build(); $field = aBurndownField()->withTracker($tracker)->withHierarchyFactory($hierarchy_factory)->build(); $html = $field->fetchAdminFormElement(); $this->assertPattern('/' . $warning_message . '/', $html); $this->assertNoPattern('/Stories/', $html); $this->assertPattern('/Bugs/', $html); $this->assertPattern('/Chores/', $html); }
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)); }
private function setUpTrackers(TrackerFactory $tracker_factory, Project $project, Project $private_project) { $this->tracker = aMockTracker()->withId($this->tracker_id)->withProject($project)->withProjectId($project->getGroupId())->build(); $this->unreadable_tracker = aMockTracker()->withId($this->unreadable_tracker_id)->withProject($project)->withProjectId($project->getGroupId())->build(); $this->private_unreadable_tracker = aMockTracker()->withId($this->private_unreadable_tracker_id)->withProject($private_project)->withProjectId($private_project->getGroupId())->build(); stub($this->tracker)->userCanView()->returns(true); stub($this->tracker)->userIsAdmin()->returns(true); stub($this->unreadable_tracker)->userCanView()->returns(false); stub($this->private_unreadable_tracker)->userCanView()->returns(true); stub($this->private_unreadable_tracker)->userIsAdmin()->returns(true); stub($tracker_factory)->getTrackerById($this->tracker_id)->returns($this->tracker); stub($tracker_factory)->getTrackerById($this->unreadable_tracker_id)->returns($this->unreadable_tracker); stub($tracker_factory)->getTrackerById($this->private_unreadable_tracker_id)->returns($this->private_unreadable_tracker); }
private function setUpTrackers(TrackerFactory $tracker_factory, Tracker_Hierarchy_Dao $hierarchy_dao) { $this->epic_tracker = aMockTracker()->withId(104)->build(); $this->story_tracker = aMockTracker()->withId(103)->build(); $this->release_tracker = aMockTracker()->withId(107)->build(); $this->sprint_tracker = aMockTracker()->withId(108)->build(); $tracker_factory->setCachedInstances(array(104 => $this->epic_tracker, 103 => $this->story_tracker, 107 => $this->release_tracker, 108 => $this->sprint_tracker)); stub($hierarchy_dao)->searchTrackerHierarchy(array(103, 104))->returnsDar(array('parent_id' => '104', 'child_id' => '103')); stub($hierarchy_dao)->searchTrackerHierarchy(array(108, 107))->returnsDar(array('parent_id' => '107', 'child_id' => '108')); stub($hierarchy_dao)->searchTrackerHierarchy()->returnsEmptyDar(); }
public function itAddsThePlanningAndTheBacklogTrackers() { $tracker = aMockTracker()->withId(99)->build(); $dar = TestHelper::arrayToDar(array('id' => 1, 'name' => 'Release Planning', 'group_id' => 102, 'planning_tracker_id' => 103, 'backlog_title' => 'Release Backlog', 'plan_title' => 'Sprint Plan', 'backlog_tracker_id' => 104)); $backlog_tracker_row = array('tracker_id' => 104); $dao = mock('PlanningDao'); stub($dao)->searchByPlanningTrackerId(99)->returns($dar); stub($dao)->searchBacklogTrackerById(1)->returns($backlog_tracker_row); $planning_tracker = aTracker()->withName('planning tracker')->withId(103)->build(); $backlog_tracker = aTracker()->withName('backlog tracker')->withId(104)->build(); $tracker_factory = mock('TrackerFactory'); stub($tracker_factory)->getTrackerById(103)->returns($planning_tracker); stub($tracker_factory)->getTrackerById(104)->returns($backlog_tracker); $factory = aPlanningFactory()->withDao($dao)->withTrackerFactory($tracker_factory)->build(); $actual_planning = $factory->getPlanningByPlanningTracker($tracker); $this->assertEqual($planning_tracker, $actual_planning->getPlanningTracker()); $this->assertEqual($backlog_tracker, $actual_planning->getBacklogTracker()); }
public function setUp() { parent::setUp(); $this->user = aUser()->withId(111)->build(); $this->artifact = anArtifact()->withTracker(aMockTracker()->build())->build(); $this->builder = new Tracker_REST_Artifact_ArtifactRepresentationBuilder(mock('Tracker_FormElementFactory')); }
public function itDoesNotSendParentWhenParentHasNoRemainingEffortField() { $tracker_user_story_id = 110; $tracker_user_story = aMockTracker()->withId($tracker_user_story_id)->build(); $user_story_id = 111; $user_story = mock('Tracker_Artifact'); stub($user_story)->getTracker()->returns($tracker_user_story); stub($user_story)->getId()->returns($user_story_id); stub($this->hierarchy_factory)->getParentArtifact($this->user, $this->task)->returns($user_story); $expected = array($this->artifact_id => array('remaining_effort' => 42)); expect($GLOBALS['Response'])->sendJSON($expected)->once(); $this->action->process($this->layout, $this->request, $this->user); }
public function setUp() { parent::setUp(); $this->workflow_factory = partial_mock('WorkflowFactory', array('getDao'), array(mock('TransitionFactory'), stub('TrackerFactory')->getTrackerById()->returns(aMockTracker()->build()), mock('Tracker_FormElementFactory'), mock('Tracker_Workflow_Trigger_RulesManager'), mock('WorkflowBackendLogger'))); $this->dao = mock('Workflow_Dao'); stub($this->workflow_factory)->getDao()->returns($this->dao); }
public function itReturnsDeniedTrackersIfTheSelectedTrackerIsOfAKanbanHierarchyOrConcernedByKanban() { $hierarchy42_78_68 = stub('Tracker_Hierarchy')->flatten()->returns(array(42, 78, 68)); $tracker42 = aMockTracker()->withId(42)->build(); stub($tracker42)->getHierarchy()->returns($hierarchy42_78_68); $tracker78 = aMockTracker()->withId(78)->build(); stub($tracker78)->getHierarchy()->returns($hierarchy42_78_68); $tracker68 = aMockTracker()->withId(68)->build(); stub($tracker68)->getHierarchy()->returns($hierarchy42_78_68); $tracker34 = aMockTracker()->withId(34)->build(); stub($tracker34)->getHierarchy()->returns($this->hierarchy); $tracker55 = aMockTracker()->withId(55)->build(); stub($tracker55)->getHierarchy()->returns($this->hierarchy); stub($this->tracker)->getHierarchy()->returns($this->hierarchy); stub($this->tracker_factory)->getTrackersByGroupIdUserCanView()->returns(array(12 => $this->tracker, 42 => $tracker42, 78 => $tracker78, 68 => $tracker68, 34 => $tracker34, 55 => $tracker55)); stub($this->kanban_factory)->getKanbanTrackerIds()->returns(array(12, 34, 55)); stub($this->planning_factory)->getPlanningTrackerIdsByGroupId()->returns(array()); stub($this->planning_factory)->getBacklogTrackerIdsByGroupId()->returns(array(42)); stub($this->hierarchy)->flatten()->returns(array(12, 34, 55)); $this->assertEqual(array_keys($this->hierarchy_checker->getDeniedTrackersForATrackerHierarchy($this->tracker, $this->user)), array(42, 78, 68)); }
public function setUp() { $tracker_id = 123; $this->workflow = aWorkflow()->withTrackerId($tracker_id)->build(); $tracker = aMockTracker()->withId($tracker_id)->build(); stub($tracker)->getWorkflow()->returns($this->workflow); $this->artifact = anArtifact()->build(); $this->artifact->setTracker($tracker); }
protected function renderAdmin() { $this->planning_factory->expectOnce('getPlannings', array($this->current_user, $this->group_id)); $this->planning_factory->setReturnValue('getPlannings', $this->plannings); stub($this->planning_factory)->getRootPlanning()->returns(aPlanning()->withPlanningTracker(aMockTracker()->build())->build()); $this->output = $this->controller->admin(); }
public function setUp() { parent::setUp(); $this->xml_input = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?> <project> <empty_section /> <trackers> <tracker id="T101" parent_id="0" instantiate_for_new_projects="1"> <name>t10</name> <item_name>t11</item_name> <description>t12</description> <formElements> <formElement type="sb" ID="F1685" rank="4" required="1"> <name>status</name> <label><![CDATA[Status]]></label> <bind type="static" is_rank_alpha="0"> <items> <item ID="V2059" label="To be done" is_hidden="0"/> <item ID="V2060" label="On going" is_hidden="0"/> <item ID="V2061" label="Done" is_hidden="0"/> <item ID="V2062" label="Canceled" is_hidden="0"/> <item ID="V2063" label="Functional review" is_hidden="0"/> <item ID="V2064" label="Code review" is_hidden="0"/> </items> <default_values> <value REF="V2059"/> </default_values> </bind> </formElement> </formElements> </tracker> <tracker id="T102" parent_id="T101" instantiate_for_new_projects="1"> <name>t20</name> <item_name>t21</item_name> <description>t22</description> <formElements> <formElement type="sb" ID="F1741" rank="0" required="1"> <name>status</name> <label><![CDATA[Status]]></label> <bind type="static" is_rank_alpha="0"> <items> <item ID="V2116" label="To be done" is_hidden="0"/> <item ID="V2117" label="On going" is_hidden="0"/> <item ID="V2118" label="Done" is_hidden="0"/> <item ID="V2119" label="Canceled" is_hidden="0"/> </items> <decorators> <decorator REF="V2117" r="102" g="102" b="0"/> </decorators> <default_values> <value REF="V2116"/> </default_values> </bind> </formElement> </formElements> </tracker> <triggers> <trigger_rule> <triggers> <trigger> <field_id REF="F1685"/> <field_value_id REF="V2060"/> </trigger> </triggers> <condition>at_least_one</condition> <target> <field_id REF="F1741"/> <field_value_id REF="V2117"/> </target> </trigger_rule> <trigger_rule> <triggers> <trigger> <field_id REF="F1685"/> <field_value_id REF="V2061"/> </trigger> </triggers> <condition>all_of</condition> <target> <field_id REF="F1741"/> <field_value_id REF="V2118"/> </target> </trigger_rule> </triggers> </trackers> <cardwall/> <agiledashboard/> </project>'); $this->triggers = new SimpleXMLElement('<triggers> <trigger_rule> <triggers> <trigger> <field_id REF="F1685"/> <field_value_id REF="V2060"/> </trigger> </triggers> <condition>at_least_one</condition> <target> <field_id REF="F1741"/> <field_value_id REF="V2117"/> </target> </trigger_rule> <trigger_rule> <triggers> <trigger> <field_id REF="F1685"/> <field_value_id REF="V2061"/> </trigger> </triggers> <condition>all_of</condition> <target> <field_id REF="F1741"/> <field_value_id REF="V2118"/> </target> </trigger_rule> </triggers>'); $this->tracker1 = aMockTracker()->withId(444)->build(); stub($this->tracker1)->testImport()->returns(true); $this->tracker2 = aMockTracker()->withId(555)->build(); stub($this->tracker2)->testImport()->returns(true); $this->tracker_factory = mock('TrackerFactory'); stub($this->tracker_factory)->validMandatoryInfoOnCreate()->returns(true); stub($this->tracker_factory)->getInstanceFromRow()->returnsAt(0, $this->tracker1); stub($this->tracker_factory)->getInstanceFromRow()->returnsAt(1, $this->tracker2); stub($this->tracker_factory)->saveObject()->returnsAt(0, 444); stub($this->tracker_factory)->saveObject()->returnsAt(1, 555); $this->event_manager = mock('EventManager'); $this->hierarchy_dao = stub('Tracker_Hierarchy_Dao')->updateChildren()->returns(true); $this->xmlFieldMapping = array('F1685' => '', 'F1741' => '', 'V2060' => '', 'V2061' => '', 'V2117' => '', 'V2118' => ''); $this->trigger_rulesmanager = mock('Tracker_Workflow_Trigger_RulesManager'); $this->tracker_xml_importer = new TrackerXmlImport($this->tracker_factory, $this->event_manager, $this->hierarchy_dao, mock('Tracker_CannedResponseFactory'), new Tracker_FormElementFactoryForXMLTests($this->xmlFieldMapping), mock('Tracker_SemanticFactory'), mock('Tracker_RuleFactory'), mock('Tracker_ReportFactory'), mock('WorkflowFactory'), mock('XML_RNGValidator'), $this->trigger_rulesmanager, mock('Tracker_Artifact_XMLImport')); }