/** * Loads options from an XML file (see class description for XML format) * into an array. Called by {@link epConfig::load()} * @param string file name * @return false|array * @throws epExceptionConfig */ protected static function _loadXml($cfg_file) { // if cfg file does not exist if (!$cfg_file || !file_exists($cfg_file)) { // return an empty array return array(); } // unserialize xml config using SimpleXml if (false === ($options = epXml2Array($cfg_file))) { throw new epExceptionConfig('Parsing config file failed'); return self::$false; } // locate options if (isset($options['ezpdo'])) { $options = $options['ezpdo']; } else { if (isset($options['options'])) { $options = $options['options']; } } return $options; }
/** * Test function epFilesInDir() in epUtils.php */ function test_epXml2Array_epValue2Xml() { // make sure methods exist $this->assertTrue(function_exists('epValue2Xml')); $this->assertTrue(function_exists('epXml2Array')); // an associated array to be tested $array0 = array('a' => array('b' => array('c' => 'x'))); $array = $array0; $array['b'] = $array0; $array['c'] = $array0; $array['d'] = $array0; // unserialize array into xml $this->assertTrue($xml = epValue2Xml($array)); // serialize xml into array $this->assertTrue($array_2 = epXml2Array($xml)); // unserialize the new array into xml $this->assertTrue($xml_2 = epValue2Xml($array_2)); // make sure the two xml strings are the same $this->assertTrue($xml == $xml_2); }