public function testToArray2() { $FGC = new DOMDocument('1.0', 'UTF-8'); $FGC->load(FGC, LIBXML_NOBLANKS); $FGCXPath = new DOMXPath($FGC); $FGCXPath->registerNamespace('fg', 'http://keg.vse.cz/ns/fieldgroupconfig0_1'); $FGCNode = $FGCXPath->evaluate('//FieldGroupConfig[2]')->item(0); $FG = new FieldGroup($FGCNode, $FGCXPath, 'en', false, $this->attributes, $this->coefficients); $FG->parse(); $array = array(0 => array('id' => 2, 'name' => 'Personal characteristics', 'localizedName' => 'Personal characteristics', 'explanation' => 'Personal characteristics of a client.', 'fieldConfig' => array('Salary' => array('coefficient' => array('type' => 'Subset', 'minimalLength' => 1, 'maximalLength' => 1)), 'Sex' => array('coefficient' => array('type' => 'One category', 'category' => 'M')), 'Age' => array('coefficient' => array('type' => 'Subset', 'minimalLength' => 1, 'maximalLength' => 1))), 'childGroups' => array(), 'connective' => 'Conjunction')); $data = $FG->toArray(); $this->assertEquals($array, $data); }
protected function parseFieldGroupConfig($id, $config) { $FGCNode = $this->XPath->evaluate('//FieldGroupConfig[@id="' . $id . '"]')->item(0); if ($FGCNode === null) { throw new InvalidFieldGroupConfigException('Invalid field group config structure.'); } $FG = new FieldGroup($FGCNode, $this->XPath, $this->lang, $this->rootConfigID === $id, $this->attributes, $this->coefficients); $FG->parse(); $config = array_merge_recursive($config, $FG->toArray()); if ($FG->hasChildGroups() === true) { foreach ($FG->getChildGroups() as $chg) { $config = $this->parseFieldGroupConfig($chg, $config); } } return $config; }