public function setUp() { parent::setUp(); $this->artifact_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>' . '<artifact>' . ' <changeset>' . ' <submitted_on>2014</submitted_on>' . ' <submitted_by>123</submitted_by>' . ' <field_change field_name="summary">' . ' <value>Initial summary value</value>' . ' </field_change>' . ' <field_change field_name="effort">' . ' <value>125</value>' . ' </field_change>' . ' <field_change field_name="details">' . ' <value>Content of details</value>' . ' </field_change>' . ' </changeset>' . '</artifact>'); $this->visitor = mock('Tracker_XML_Updater_FieldChangeXMLUpdaterVisitor'); $this->formelement_factory = mock('Tracker_FormElementFactory'); $this->updater = new Tracker_XML_Updater_ChangesetXMLUpdater($this->visitor, $this->formelement_factory); $this->user = aUser()->withId($this->user_id)->build(); $this->tracker = aTracker()->withId($this->tracker_id)->build(); $this->submitted_values = array(1001 => 'Content of summary field', 1002 => '123'); $this->field_summary = aStringField()->withId(1001)->build(); $this->field_effort = aStringField()->withId(1002)->build(); $this->field_details = aStringField()->withId(1003)->build(); stub($this->formelement_factory)->getUsedFieldByNameForUser($this->tracker_id, 'summary', $this->user)->returns($this->field_summary); stub($this->formelement_factory)->getUsedFieldByNameForUser($this->tracker_id, 'effort', $this->user)->returns($this->field_effort); stub($this->formelement_factory)->getUsedFieldByNameForUser($this->tracker_id, 'details', $this->user)->returns($this->field_details); }
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 setUp() { parent::setUp(); $this->tracker = partial_mock('Tracker', array('getWorkflow', 'getId')); stub($this->tracker)->getId()->returns($this->tracker_id); stub($this->tracker)->getWorkflow()->returns(mock('Workflow')); $this->artifact_creator = mock('Tracker_ArtifactCreator'); $this->new_changeset_creator = mock('Tracker_Artifact_Changeset_NewChangesetAtGivenDateCreator'); $this->summary_field_id = 50; $this->formelement_factory = mock('Tracker_FormElementFactory'); stub($this->formelement_factory)->getUsedFieldByName($this->tracker_id, 'summary')->returns(aStringField()->withId(50)->build()); $this->john_doe = aUser()->withId(200)->withUserName('john_doe')->build(); $this->user_manager = mock('UserManager'); stub($this->user_manager)->getUserByIdentifier('john_doe')->returns($this->john_doe); stub($this->user_manager)->getUserAnonymous()->returns(new PFUser(array('user_id' => 0))); $this->xml_import_helper = new Tracker_XMLImport_XMLImportHelper($this->user_manager); $this->artifact = mock('Tracker_Artifact'); $this->extraction_path = dirname(__FILE__) . '/_fixtures'; $this->static_value_dao = mock('Tracker_FormElement_Field_List_Bind_Static_ValueDao'); $this->logger = mock('Logger'); $this->response = mock('Response'); $GLOBALS['Response'] = $this->response; $this->importer = new Tracker_Artifact_XMLImport(mock('XML_RNGValidator'), $this->artifact_creator, $this->new_changeset_creator, $this->formelement_factory, $this->xml_import_helper, $this->static_value_dao, $this->logger, false); }
public function setUp() { parent::setUp(); stub($this->tracker_config)->isInsecureEmailgatewayEnabled()->returns(true); stub($this->tracker_config)->isTokenBasedEmailgatewayEnabled()->returns(false); $title_field = aStringField()->build(); $description_field = aTextField()->build(); stub($this->tracker)->getTitleField()->returns($title_field); stub($this->tracker)->getDescriptionField()->returns($description_field); stub($this->tracker)->getFormElementFields()->returns(array($title_field, $description_field)); $this->changeset = stub('Tracker_Artifact_Changeset')->getId()->returns(666); }
public function setUp() { parent::setUp(); $title_field = aStringField()->build(); $description_field = aTextField()->build(); stub($this->tracker)->getTitleField()->returns($title_field); stub($this->tracker)->getDescriptionField()->returns($description_field); stub($this->tracker)->getFormElementFields()->returns(array($title_field, $description_field)); $this->changeset = stub('Tracker_Artifact_Changeset')->getId()->returns(666); $this->mailgateway = new Tracker_Artifact_MailGateway_InsecureMailGateway($this->parser, $this->incoming_message_factory, $this->citation_stripper, $this->notifier, $this->incoming_mail_dao, $this->artifact_factory, new Tracker_ArtifactByEmailStatus($this->tracker_config), $this->logger); }
/** * @see https://tuleap.net/plugins/tracker?aid=6449 */ function itIsNotEmptyWhenThereIsContent() { $artifact = new MockTracker_Artifact(); $field = aStringField()->build(); $this->assertFalse($field->isEmpty('sdf', $artifact)); }
public function itReturnsTheValueIndexedByFieldName() { $field = aStringField()->build(); $value = array("field_id" => 330, "value" => 'My awesome content'); $this->assertEqual('My awesome content', $field->getFieldDataFromRESTValueByField($value)); }
public function setUp() { parent::setUp(); $this->form_element = aStringField()->withId(300)->withLabel("My field")->withName('my_field')->build(); $this->user = aUser()->build(); $this->workflow_user = new Tracker_Workflow_WorkflowUser(); }