/**
  * Creates a Cardwall_Semantic_CardFields Object
  *
  * @param SimpleXMLElement $xml          containing the structure of the imported semantic initial effort
  * @param array            &$xml_mapping containig the newly created formElements idexed by their XML IDs
  * @param Tracker          $tracker      to which the semantic is attached
  *
  * @return Cardwall_Semantic_CardFields The semantic object
  */
 public function getInstanceFromXML($xml, &$xml_mapping, $tracker)
 {
     $fields = array();
     foreach ($xml->field as $field) {
         $att = $field->attributes();
         $fields[] = $xml_mapping[(string) $att['REF']];
     }
     $semantic = new Cardwall_Semantic_CardFields($tracker);
     $semantic->setFields($fields);
     return $semantic;
 }
Beispiel #2
0
 public function itExportsInXMLFormat()
 {
     $tracker = mock('Tracker');
     $field_1 = stub('Tracker_FormElement_Field_Text')->getId()->returns(102);
     $field_2 = stub('Tracker_FormElement_Field_Text')->getId()->returns(103);
     $semantic = new Cardwall_Semantic_CardFields($tracker);
     $semantic->setFields(array($field_1, $field_2));
     $root = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><tracker />');
     $array_mapping = array('F13' => '102', 'F14' => '103');
     $semantic->exportToXML($root, $array_mapping);
     $xml = simplexml_load_file(dirname(__FILE__) . '/_fixtures/ImportCardwallSemanticCardFields.xml');
     $this->assertEqual((string) $xml['type'], (string) $root->semantic['type']);
     $this->assertEqual((string) $xml->field[0]['REF'], (string) $root->semantic->field[0]['REF']);
     $this->assertEqual((string) $xml->field[1]['REF'], (string) $root->semantic->field[1]['REF']);
 }