/** * unserialize() * * Create a structure in the object $profile from the structure specficied * in the xml string provided * * @param string xml data * @param \Zend\Tool\Project\Profile The profile to use as the top node * @return \Zend\Tool\Project\Profile */ public function unserialize($data, Profile $profile) { if ($data == null) { throw new Exception\InvalidArgumentException('contents not available to unserialize.'); } $this->_profile = $profile; $xmlDataIterator = new \SimpleXMLIterator($data); if ($xmlDataIterator->getName() != 'projectProfile') { throw new Exception\RuntimeException('Profiles must start with a projectProfile node'); } if (isset($xmlDataIterator['type'])) { $this->_profile->setAttribute('type', (string) $xmlDataIterator['type']); } if (isset($xmlDataIterator['version'])) { $this->_profile->setAttribute('version', (string) $xmlDataIterator['version']); } // start un-serialization of the xml doc $this->_unserializeRecurser($xmlDataIterator); // contexts should be initialized after the unwinding of the profile structure $this->_lazyLoadContexts(); return $this->_profile; }
public function testProfileThrowsExceptionOnLoadFromFileWithBadPathForProfileFile() { $this->setExpectedException('Zend\\Tool\\Project\\Exception'); $profile = new Profile(); $profile->setAttribute('projectProfileFile', '/path/should/not/exist'); // missing file path or project path $profile->loadFromFile(); }