/** * Processes entry node. * * @param array $xmlArray An array of simple xml elements. * * @return array */ protected function processEntryNode($xmlArray) { $entry = array(); $entryItem = $xmlArray[Resources::ENTRY]; if (is_array($entryItem)) { foreach ($xmlArray[Resources::ENTRY] as $entryXmlInstance) { $entryInstance = new Entry(); $entryInstance->fromXml($entryXmlInstance); $entry[] = $entryInstance; } } else { $entryInstance = new Entry(); $entryInstance->fromXml($entryItem); $entry[] = $entryInstance; } return $entry; }
/** * Get array of properties of atom entites passed via feed or single entry * * @param string $xmlString Atom xml * * @return array of properties arrays */ protected function getEntryList($xmlString) { $xml = simplexml_load_string($xmlString); if ($xml->getName() == Resources::ENTRY) { $entry = new Entry(); $entry->fromXml($xml); $entries = array($entry); } else { $feed = new Feed(); $feed->parseXml($xmlString); $entries = $feed->getEntry(); } $result = array(); if (is_array($entries)) { foreach ($entries as $entry) { $properties = $this->getPropertiesFromAtomEntry($entry); if (!empty($properties)) { $result[] = $properties; } } } return $result; }
/** * @covers WindowsAzure\Common\Internal\Atom\Entry::fromXml */ public function testFromXml() { // Setup $xmlString = '<entry> <content> </content> </entry>'; $entry = new Entry(); $xml = simplexml_load_string($xmlString); // Test $entry->fromXml($xml); // Assert $this->assertNotNull($entry->getContent()); }