public function exportChildren(SimpleXMLElement $xml) { while ($artifact_id = $this->children_collector->pop()) { $artifact = $this->artifact_factory->getArtifactById($artifact_id); if (!$artifact) { continue; } $last_changeset = $artifact->getLastChangeset(); $this->artifact_xml_updater->exportSnapshotWithoutComments($xml, $last_changeset); $index_last_artifact = count($xml->artifact) - 1; $this->file_xml_updater->update($xml->artifact[$index_last_artifact]); } }
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); }
private function processCopy(Tracker_Artifact_Changeset $from_changeset, PFUser $current_user, array $submitted_values) { $xml_artifacts = $this->getXMLRootNode(); $this->xml_exporter->exportSnapshotWithoutComments($xml_artifacts, $from_changeset); $this->file_updater->update($xml_artifacts->artifact); $this->xml_updater->update($this->tracker, $xml_artifacts->artifact, $submitted_values, $current_user, $_SERVER['REQUEST_TIME']); $this->children_xml_exporter->exportChildren($xml_artifacts); $extraction_path = ''; $artifact = $this->xml_importer->importOneArtifactFromXML($this->tracker, $xml_artifacts->artifact[0], $extraction_path); if ($artifact) { $this->artifacts_imported_mapping->add($from_changeset->getArtifact()->getId(), $artifact->getId()); $this->children_xml_importer->importChildren($this->artifacts_imported_mapping, $xml_artifacts, $extraction_path, $artifact, $current_user); $this->addSummaryCommentChangeset($artifact, $current_user, $from_changeset); $this->redirectToArtifact($artifact); } else { $this->logsErrorAndRedirectToTracker('plugin_tracker', 'error_create_copy', $from_changeset->getArtifact()->getId()); } }