/** * Load local package data array * * @param string $packageName without extension * @return array|boolean */ public function loadLocalPackage($packageName) { $xmlFile = sprintf('connect/%.xml', $packageName); $serFile = sprintf('connect/%.ser', $packageName); if ($this->readDirectory->isFile($xmlFile) && $this->readDirectory->isReadable($xmlFile)) { $xml = simplexml_load_string($this->readDirectory->readFile($xmlFile)); $data = $this->_xmlConverter->xmlToAssoc($xml); if (!empty($data)) { return $data; } } if ($this->readDirectory->isFile($serFile) && $this->readDirectory->isReadable($xmlFile)) { $data = unserialize($this->readDirectory->readFile($serFile)); if (!empty($data)) { return $data; } } return false; }
public function testXmlToAssoc() { $xmlstr = $this->getXml(); $result = $this->_model->xmlToAssoc(new \SimpleXMLElement($xmlstr)); $this->assertEquals(array('one' => '1', 'two' => array('three' => '3', 'four' => '4'), 'five' => array(0 => '5', 1 => '6')), $result); }