public function setUp()
 {
     parent::setUp();
     $this->field = aFileField()->withName('textarea')->build();
     $this->exporter = new Tracker_XML_Exporter_ChangesetValue_ChangesetValueTextXMLExporter();
     $this->artifact_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><artifact />');
     $this->changeset_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><changeset />');
     $this->changeset_value = mock('Tracker_Artifact_ChangesetValue_Text');
     stub($this->changeset_value)->getField()->returns($this->field);
 }
 public function setUp()
 {
     parent::setUp();
     $this->field = aFileField()->withName('story_points')->build();
     $this->exporter = new Tracker_XML_Exporter_ChangesetValue_ChangesetValuePermissionsOnArtifactXMLExporter();
     $this->artifact_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><artifact />');
     $this->changeset_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><changeset />');
     $this->changeset_value = mock('Tracker_Artifact_ChangesetValue_PermissionsOnArtifact');
     stub($this->changeset_value)->getPerms()->returns(array(1001, 1002));
     stub($this->changeset_value)->getUsed()->returns(true);
     stub($this->changeset_value)->getField()->returns($this->field);
 }
 public function setUp()
 {
     parent::setUp();
     $this->field = aFileField()->withName('attachment')->build();
     $this->path_exporter = mock('Tracker_XML_Exporter_FilePathXMLExporter');
     $this->exporter = new Tracker_XML_Exporter_ChangesetValue_ChangesetValueFileXMLExporter($this->path_exporter);
     $this->artifact_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><artifact />');
     $this->changeset_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><changeset />');
     $this->id_prefix = Tracker_XML_Exporter_ChangesetValue_ChangesetValueFileXMLExporter::ID_PREFIX;
     $file1 = new Tracker_FileInfo(123, '*', '*', 'Description 123', 'file123.txt', 123, 'text/xml');
     $file2 = new Tracker_FileInfo(456, '*', '*', 'Description 456', 'file456.txt', 456, 'text/html');
     $this->changeset_value = mock('Tracker_Artifact_ChangesetValue_File');
     stub($this->changeset_value)->getFiles()->returns(array($file1, $file2));
     stub($this->changeset_value)->getField()->returns($this->field);
 }
 public function setUp()
 {
     parent::setUp();
     $tracker_factory = mock('TrackerFactory');
     TrackerFactory::setInstance($tracker_factory);
     $this->user = aUser()->build();
     $story_tracker = aTracker()->withId(100)->build();
     $task_tracker = aTracker()->withId(101)->build();
     $bug_tracker = aTracker()->withId(102)->build();
     $dayoff_tracker = aTracker()->withId(103)->build();
     $story_tracker->setChildren(array($task_tracker, $bug_tracker));
     stub($tracker_factory)->getTrackerById(100)->returns($story_tracker);
     stub($tracker_factory)->getTrackerById(101)->returns($task_tracker);
     stub($tracker_factory)->getTrackerById(102)->returns($bug_tracker);
     stub($tracker_factory)->getTrackerById(103)->returns($dayoff_tracker);
     $this->collector = new Tracker_XML_ChildrenCollector();
     $this->field = aFileField()->withTracker($story_tracker)->withName('artifact links')->build();
     $this->exporter = new Tracker_XML_Exporter_ChangesetValue_ChangesetValueArtifactLinkXMLExporter($this->collector, $this->user);
     $this->artifact_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><artifact />');
     $this->changeset_xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><changeset />');
     $this->changeset_value = mock('Tracker_Artifact_ChangesetValue_ArtifactLink');
     stub($this->changeset_value)->getField()->returns($this->field);
 }
 public function itOnlyExportsTheLastChangeset()
 {
     $older_changeset_value = mock('Tracker_Artifact_ChangesetValue_File');
     stub($older_changeset_value)->getId()->returns(9722);
     stub($older_changeset_value)->getField()->returns(aFileField()->build());
     stub($this->artifact)->getLastChangeset()->returns($older_changeset_value);
     $this->exporter->export($this->artifact_xml, $this->changeset_xml, $this->artifact, $older_changeset_value);
     $this->assertEqual(count($this->artifact_xml->file), 0);
 }
 public function itConvertsOneFile()
 {
     $description = "Purchase Order";
     $filename = 'my_file.ods';
     $filesize = 1234;
     $filetype = 'application/vnd.oasis.opendocument.spreadsheet';
     $file_id = 'coucou123';
     $field_value = $this->createFakeSoapFieldValue($this->createFakeSoapFileRequest($file_id, $description, $filename, $filesize, $filetype));
     $temp_file = new Tracker_SOAP_TemporaryFile($this->current_user, $file_id);
     $temp_file_path = $temp_file->getPath();
     touch($temp_file_path);
     $field = aFileField()->build();
     $this->assertEqual($field->getFieldData($field_value), array(array('id' => $file_id, 'description' => $description, 'name' => $filename, 'type' => $filetype, 'tmp_name' => $temp_file_path, 'error' => UPLOAD_ERR_OK, 'size' => $filesize)));
 }
Example #7
0
 public function itCreatesChangesetsThatOnlyReferenceConcernedFiles()
 {
     $artifact = mock('Tracker_Artifact');
     stub($this->artifact_creator)->create()->returns($artifact);
     stub($this->new_changeset_creator)->create()->returns(mock('Tracker_Artifact_Changeset'));
     stub($this->formelement_factory)->getUsedFieldByName($this->tracker_id, 'attachment')->returns(aFileField()->withId($this->file_field_id)->build());
     $initial_changeset_data = array($this->file_field_id => array(array('is_migrated' => true, 'name' => 'A.png', 'type' => 'image/png', 'description' => 'None', 'size' => 87947, 'tmp_name' => $this->extraction_path . '/34_File33.png', 'error' => UPLOAD_ERR_OK)), $this->summary_field_id => 'Newly submitted');
     $second_changeset_data = array($this->file_field_id => array(array('is_migrated' => true, 'name' => 'B.pdf', 'type' => 'application/x-download', 'description' => 'A Zuper File', 'size' => 84895, 'tmp_name' => $this->extraction_path . '/34_File34.pdf', 'error' => UPLOAD_ERR_OK)));
     expect($this->artifact_creator)->create('*', $initial_changeset_data, '*', '*', '*')->once();
     expect($this->new_changeset_creator)->create($artifact, $second_changeset_data, '*', '*', '*', '*', '*')->once();
     $this->importer->importFromXML($this->tracker, $this->xml_element, $this->extraction_path, $this->xml_mapping);
 }