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());
     }
 }
 public function itStoresTheChildrenOfTheFirstArtifact()
 {
     $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?>
         <artifacts>
             <artifact id="100" tracker_id="22">
                 <changeset>
                     <field_change field_name="content" type="art_link">
                         <value>123</value>
                     </field_change>
                 </changeset>
             </artifact>
             <artifact id="123" tracker_id="23">
                 <changeset>
                     <field_change field_name="content" type="art_link">
                         <value>124</value>
                     </field_change>
                 </changeset>
             </artifact>
             <artifact id="124" tracker_id="24">
                 <changeset>
                     <field_change field_name="content" type="art_link">
                         <value/>
                     </field_change>
                 </changeset>
             </artifact>
         </artifacts>');
     stub($this->xml_importer)->importOneArtifactFromXML('*', $xml->artifact[1], '*')->returns($this->created_artifact);
     stub($this->xml_importer)->importOneArtifactFromXML('*', $xml->artifact[2], '*')->returns($this->another_child_artifact);
     stub($this->artifacts_imported_mapping)->get(100)->returns($this->root_artifact->getId());
     stub($this->artifacts_imported_mapping)->get(123)->returns($this->created_artifact->getId());
     stub($this->artifacts_imported_mapping)->get(124)->returns($this->another_child_artifact->getId());
     stub($this->artifacts_imported_mapping)->getOriginal($this->root_artifact->getId())->returns(100);
     stub($this->artifacts_imported_mapping)->getOriginal($this->created_artifact->getId())->returns(123);
     stub($this->artifacts_imported_mapping)->getOriginal($this->another_child_artifact->getId())->returns(124);
     $this->importer->importChildren($this->artifacts_imported_mapping, $xml, 'whatever', $this->root_artifact, $this->user);
     $expected_parents = array(100, 123);
     $this->assertEqual($expected_parents, $this->children_collector->getAllParents());
 }