public function setUp()
 {
     parent::setUp();
     $this->tracker_id = 666;
     $this->tracker = mock('Tracker');
     stub($this->tracker)->getId()->returns($this->tracker_id);
     $this->task_tracker = mock('Tracker');
     stub($this->task_tracker)->getId()->returns(42);
     $this->story_tracker = mock('Tracker');
     stub($this->story_tracker)->getId()->returns(69);
     $this->tracker_factory = mock('TrackerFactory');
     stub($this->tracker_factory)->getTrackerById(42)->returns($this->task_tracker);
     stub($this->tracker_factory)->getTrackerById(69)->returns($this->story_tracker);
     $this->status_field = aMockField()->withId(123)->withTracker($this->task_tracker)->build();
     $this->assignto_field = aMockField()->withId(321)->withTracker($this->story_tracker)->build();
     $this->stage_field = aMockField()->withId(322)->withTracker($this->story_tracker)->build();
     $this->element_factory = mock('Tracker_FormElementFactory');
     stub($this->element_factory)->getFieldById(123)->returns($this->status_field);
     stub($this->element_factory)->getFieldById(321)->returns($this->assignto_field);
     stub($this->element_factory)->getFieldById(322)->returns($this->stage_field);
     $existing_mappings = array(42 => new Cardwall_OnTop_Config_TrackerMappingStatus($this->task_tracker, array(), array(), $this->status_field), 69 => new Cardwall_OnTop_Config_TrackerMappingFreestyle($this->story_tracker, array(), array(), $this->stage_field));
     $this->dao = mock('Cardwall_OnTop_ColumnMappingFieldDao');
     $this->value_dao = mock('Cardwall_OnTop_ColumnMappingFieldValueDao');
     $this->command = new Cardwall_OnTop_Config_Command_UpdateMappingFields($this->tracker, $this->dao, $this->value_dao, $this->tracker_factory, $this->element_factory, $existing_mappings);
 }
Example #2
0
 public function setUp()
 {
     parent::setUp();
     $this->field = aMockField()->build();
     $this->from_value = mock('Tracker_FormElement_Field_List_Value');
     $this->to_value = mock('Tracker_FormElement_Field_List_Value');
     $this->xml_mapping = array('F1' => $this->field, 'F32-V1' => $this->from_value, 'F32-V0' => $this->to_value);
     $this->factory = TestHelper::getPartialMock('TransitionFactory', array());
 }
 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 itHasATriggerTrackerWithAField()
 {
     $field_id = 693;
     $field = aMockField()->withId($field_id)->build();
     expect($field)->fetchFormattedForJson()->once();
     stub($field)->fetchFormattedForJson()->returns('whatever');
     $tracker_id = 90;
     $triggering_field = new Tracker_Workflow_Trigger_RulesBuilderTriggeringFields(aTracker()->withId($tracker_id)->withName('Tasks')->build(), new ArrayIterator(array($field)));
     $rules_builder_data = new Tracker_Workflow_Trigger_RulesBuilderData(new ArrayIterator(), array($triggering_field));
     $result = $rules_builder_data->fetchFormattedForJson();
     $trigger = $result['triggers'][$tracker_id];
     $this->assertCount($trigger['fields'], 1);
     $this->assertEqual($trigger['fields'][$field_id], 'whatever');
 }
Example #5
0
 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);
 }
Example #6
0
 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 itReturnsAnArrayEvenWhenFieldsAreNotReadable()
 {
     stub($this->semantic_manager)->exportToREST()->returns(array());
     stub($this->tracker)->getWorkflow()->returns(mock('Workflow'));
     $field1 = aMockField()->withId(1)->build();
     stub($field1)->userCanRead()->returns(true);
     stub($field1)->exportCurrentUserPermissionsToSOAP()->returns(array());
     stub($field1)->getSoapBindingProperties()->returns(aStringField()->build()->getSoapBindingProperties());
     $field2 = aMockField()->withId(2)->build();
     stub($field2)->userCanRead()->returns(false);
     stub($field2)->exportCurrentUserPermissionsToSOAP()->returns(array());
     stub($field2)->getSoapBindingProperties()->returns(aStringField()->build()->getSoapBindingProperties());
     $field3 = aMockField()->withId(3)->build();
     stub($field3)->userCanRead()->returns(true);
     stub($field3)->exportCurrentUserPermissionsToSOAP()->returns(array());
     stub($field3)->getSoapBindingProperties()->returns(aStringField()->build()->getSoapBindingProperties());
     stub($this->formelement_factory)->getUsedFields()->returns(array($field1, $field2, $field3));
     stub($this->formelement_factory)->getAllUsedFormElementOfAnyTypesForTracker()->returns(array($field1, $field2, $field3));
     stub($this->formelement_factory)->getType()->returns('string');
     $tracker_representation = $this->builder->getTrackerRepresentation($this->user, $this->tracker);
     $this->assertEqual(array_keys($tracker_representation->fields), array(0, 1));
 }
 public function itDoesNotDisplayAFeedbackErrorIfAssignedToSemanticIsDefined()
 {
     stub($this->tracker)->getContributorField()->returns(aMockField()->build());
     $request = new Tracker_Permission_PermissionRequest(array(ProjectUGroup::ANONYMOUS => Tracker_Permission_Command::PERMISSION_NONE, ProjectUGroup::REGISTERED => Tracker_Permission_Command::PERMISSION_NONE, ProjectUGroup::PROJECT_MEMBERS => Tracker_Permission_Command::PERMISSION_ASSIGNEE));
     expect($this->permissions_manager)->addPermission()->once();
     expect($GLOBALS['Response'])->addFeedback(Feedback::INFO, '*')->once();
     $this->permission_manager->save($request, $this->permission_setter);
 }
Example #9
0
 public function setUp()
 {
     parent::setUp();
     $this->rule_id = 6347;
     $this->tracker_id = 4656;
     $this->tracker = aTracker()->withId($this->tracker_id)->build();
     $this->target_field_id = 12;
     $this->target_field_value = aBindStaticValue()->withId($this->target_value_id)->build();
     $this->target_field = aMockField()->withTracker($this->tracker)->build();
     stub($this->target_field)->getAllValues()->returns(array(aBindStaticValue()->withId(9998)->build(), $this->target_field_value, aBindStaticValue()->withId(9999)->build()));
     stub($this->formelement_factory)->getUsedFormElementFieldById($this->target_field_id)->returns($this->target_field);
     $this->trigger_field_id_1 = 369;
     $this->trigger_value_id_1 = 852;
     $this->trigger_field_value_1 = aBindStaticValue()->withId($this->trigger_value_id_1)->build();
     $this->trigger_field_1 = aMockField()->withId($this->trigger_field_id_1)->build();
     stub($this->trigger_field_1)->getAllValues()->returns(array($this->trigger_field_value_1));
     stub($this->formelement_factory)->getUsedFormElementFieldById($this->trigger_field_id_1)->returns($this->trigger_field_1);
 }
 public function itCreatesContentWithOneElementInDone()
 {
     stub($this->dao)->getPlannedItemIds()->returns(array());
     stub($this->form_element_factory)->getUsedFieldByNameForUser()->returns(aMockField()->build());
     $content = $this->factory->getDoneCollection($this->user, $this->milestone, $this->backlog_strategy, $this->redirect_to_self);
     $row = $content->current();
     $this->assertEqual($row->id(), $this->closed_story_id);
 }
 public function itReturnsValuesOnlyForFieldsWithValues()
 {
     $field1 = aMockField()->withId(1)->build();
     $field2 = aMockField()->withId(2)->build();
     $field3 = aMockField()->withId(3)->build();
     stub($field2)->userCanRead($this->user)->returns(true);
     stub($field2)->getRESTValue()->returns('whatever');
     stub($this->formelement_factory)->getUsedFieldsForREST($this->tracker)->returns(array($field1, $field2, $field3));
     $representation = $this->builder->getArtifactRepresentationWithFieldValues($this->user, $this->artifact);
     $this->assertEqual($representation->values, array('whatever'));
     $this->assertEqual($representation->values_by_field, null);
 }
 public function setUp()
 {
     parent::setUp();
     $this->factory = new Transition_PostActionFactoryTestVersion();
     $this->date_dao = mock('Transition_PostAction_Field_DateDao');
     $this->int_dao = mock('Transition_PostAction_Field_IntDao');
     $this->float_dao = mock('Transition_PostAction_Field_FloatDao');
     stub($this->factory)->getDao('field_date')->returns($this->date_dao);
     stub($this->factory)->getDao('field_int')->returns($this->int_dao);
     stub($this->factory)->getDao('field_float')->returns($this->float_dao);
     $this->field_id = 45617;
     $this->field = aMockField()->withId($this->field_id)->build();
 }
Example #13
0
 private function setUpTwoTriggers()
 {
     // field 1
     $this->child_tracker_1 = aTracker()->withParent($this->tracker)->build();
     $this->trigger_field_id_1 = 369;
     $this->trigger_value_id_1 = 852;
     $this->trigger_field_value_1 = aBindStaticValue()->withId($this->trigger_value_id_1)->build();
     $this->trigger_field_1 = aMockField()->withId($this->trigger_field_id_1)->withTracker($this->child_tracker_1)->build();
     stub($this->trigger_field_1)->getAllValues()->returns(array($this->trigger_field_value_1));
     // field 2
     $this->child_tracker_2 = aTracker()->withParent($this->tracker)->build();
     $this->trigger_field_id_2 = 874;
     $this->trigger_value_id_2 = 147;
     $this->trigger_field_value_2 = aBindStaticValue()->withId($this->trigger_value_id_2)->build();
     $this->trigger_field_2 = aMockField()->withId($this->trigger_field_id_2)->withTracker($this->child_tracker_2)->build();
     stub($this->trigger_field_2)->getAllValues()->returns(array($this->trigger_field_value_2));
     // Returns the 2 fields
     stub($this->formelement_factory)->getUsedFormElementFieldById("{$this->trigger_field_id_1}")->returns($this->trigger_field_1);
     stub($this->formelement_factory)->getUsedFormElementFieldById("{$this->trigger_field_id_2}")->returns($this->trigger_field_2);
     // Update input
     $json_triggering_field2 = new stdClass();
     $json_triggering_field2->field_id = "{$this->trigger_field_id_2}";
     $json_triggering_field2->field_value_id = "{$this->trigger_value_id_2}";
     $this->json_input->triggering_fields[] = $json_triggering_field2;
 }
 public function setUp()
 {
     parent::setUp();
     $this->field_id = 45617;
     $this->field = aMockField()->withId($this->field_id)->build();
 }
 function testUserCanViewTrackerAccessFull()
 {
     $ugroup_ass = 101;
     $ugroup_sub = 102;
     $ugroup_ful = 103;
     // $assignee is in (UgroupAss - ugroup_id=101)
     // $submitter is in (UgroupSub - ugroup_id=102)
     // $u is in (UgroupFul - ugroup_id=103);
     // $other do not belong to any ugroup
     //
     $u = mock('PFUser');
     $u->setReturnValue('getId', 120);
     $u->setReturnValue('isMemberOfUgroup', true, array(103, 222));
     $u->setReturnValue('isMemberOfUgroup', false, array(101, 222));
     $u->setReturnValue('isMemberOfUgroup', false, array(102, 222));
     $u->setReturnValue('isSuperUser', false);
     //
     $assignee = mock('PFUser');
     $assignee->setReturnValue('getId', 121);
     $assignee->setReturnValue('isMemberOfUgroup', true, array(101, 222));
     $assignee->setReturnValue('isMemberOfUgroup', false, array(102, 222));
     $assignee->setReturnValue('isMemberOfUgroup', false, array(103, 222));
     $assignee->setReturnValue('isSuperUser', false);
     //
     $submitter = mock('PFUser');
     $submitter->setReturnValue('getId', 122);
     $submitter->setReturnValue('isMemberOfUgroup', false, array(101, 222));
     $submitter->setReturnValue('isMemberOfUgroup', true, array(102, 222));
     $submitter->setReturnValue('isMemberOfUgroup', false, array(103, 222));
     $submitter->setReturnValue('isSuperUser', false);
     //
     $other = mock('PFUser');
     $other->setReturnValue('getId', 123);
     $other->setReturnValue('isMemberOfUgroup', false);
     $other->setReturnValue('isSuperUser', false);
     $user_manager = mock('UserManager');
     $user_manager->setReturnReference('getUserById', $u, array(120));
     $user_manager->setReturnReference('getUserById', $assignee, array(121));
     $user_manager->setReturnReference('getUserById', $submitter, array(122));
     $user_manager->setReturnReference('getUserById', $other, array(123));
     $project_manager = mock('ProjectManager');
     // $artifact_subass has been submitted by $submitter and assigned to $assignee
     // $u should have the right to see it.
     // $other, $submitter and assigned should not have the right to see it
     $permissions = array("PLUGIN_TRACKER_ACCESS_FULL" => array(0 => $ugroup_ful));
     $this->tracker->setReturnReference('getAuthorizedUgroupsByPermissionType', $permissions);
     $contributor_field = aMockField()->build();
     $this->tracker->setReturnReference('getContributorField', $contributor_field);
     $artifact_subass = mock('Tracker_Artifact');
     $artifact_subass->setReturnReference('getTracker', $this->tracker);
     $artifact_subass->setReturnValue('useArtifactPermissions', false);
     $artifact_subass->setReturnValue('getSubmittedBy', 123);
     $user_changeset_value = new MockTracker_Artifact_ChangesetValue();
     $contributors = array(121);
     $user_changeset_value->setReturnReference('getValue', $contributors);
     $artifact_subass->setReturnReference('getValue', $user_changeset_value, array($contributor_field));
     $permission_checker = new Tracker_Permission_PermissionChecker($user_manager, $project_manager);
     $this->assertFalse($permission_checker->userCanView($submitter, $artifact_subass));
     $this->assertFalse($permission_checker->userCanView($assignee, $artifact_subass));
     $this->assertFalse($permission_checker->userCanView($other, $artifact_subass));
     $this->assertTrue($permission_checker->userCanView($u, $artifact_subass));
 }
 public function setUp()
 {
     parent::setUp();
     $artifact_factory = aMockArtifactFactory()->build();
     $tracker_factory = mock('TrackerFactory');
     $group_id = 456;
     $this->user = mock('User');
     $this->project = stub('Project')->getId()->returns($group_id);
     $trackers = array(101 => stub('Tracker')->getId()->returns(101), 102 => stub('Tracker')->getId()->returns(102), 103 => stub('Tracker')->getId()->returns(103));
     stub($tracker_factory)->getTrackersByGroupId($group_id)->returns($trackers);
     $this->field_title_102 = aMockField()->build();
     $this->field_title_103 = aMockField()->build();
     $this->field_status_102 = aMockField()->build();
     $this->field_status_103 = aMockField()->build();
     $this->semantic_title_factory = aMockSemanticTitleFactory()->withNoFieldForTracker($trackers[101])->withFieldForTracker($this->field_title_102, $trackers[102])->withFieldForTracker($this->field_title_103, $trackers[103])->build();
     $this->semantic_status_factory = aMockSemanticStatusFactory()->withNoFieldForTracker($trackers[101])->withFieldForTracker($this->field_status_102, $trackers[102])->withFieldForTracker($this->field_status_103, $trackers[103])->build();
     $this->semantic_value_factory = new Tracker_CrossSearch_SemanticValueFactory($artifact_factory, $this->semantic_title_factory, $this->semantic_status_factory, $tracker_factory);
 }
Example #17
0
 public function setUp()
 {
     parent::setUp();
     $this->user = mock('PFUser');
     $this->field_id = 123242;
     $this->field = aMockField()->build();
     $this->changeset_value = mock('Tracker_Artifact_ChangesetValue');
     $this->last_changeset = stub('Tracker_Artifact_Changeset')->getValues()->returns(array($this->field_id => $this->changeset_value));
     $this->formelement_factory = mock('Tracker_FormElementFactory');
     stub($this->formelement_factory)->getFormElementById()->returns($this->field);
     $this->tracker = aTracker()->build();
     $this->artifact = partial_mock('Tracker_Artifact', array('userCanView', 'getCrossReferencesSOAPValues'), array('whatever', 'whatever', 'whatever', 'whatever', 'whatever'));
     stub($this->artifact)->userCanView()->returns(true);
     $this->artifact->setChangesets(array($this->last_changeset));
     $this->artifact->setFormElementFactory($this->formelement_factory);
     $this->artifact->setTracker($this->tracker);
 }
 public function setUp()
 {
     parent::setUp();
     $this->field = aMockField()->build();
     $this->from_value = mock('Tracker_FormElement_Field_List_Value');
     $this->to_value = mock('Tracker_FormElement_Field_List_Value');
     $this->xml_mapping = array('F1' => $this->field, 'F32-V1' => $this->from_value, 'F32-V0' => $this->to_value);
     stub($this->condition_factory)->getAllInstancesFromXML()->returns(new Workflow_Transition_ConditionsCollection());
 }