/** * @covers Picture::createFromXML */ function test_createFromXML() { $xml_source = ' <picture id="84444" creation-time="2013-05-20T00:00:00+0200" resource="a8642693-2e65-43c5-a1bf-c377f1f283ac"> <name locale="cs_CZ" text="F11"/> <name locale="en_US" text="F11"/> <name locale="ru_RU" text="F11"/> </picture> '; $element = new \SimpleXMLElement($xml_source); $picture = Picture::createFromXML($element); $this->assertInstanceOf('RealPadConnector\\CMS\\Project\\Picture', $picture); $this->assertEquals(84444, $picture->getID()); $this->assertEquals(new \DateTime('2013-05-20T00:00:00+0200'), $picture->getCreationTime()); $this->assertEquals('a8642693-2e65-43c5-a1bf-c377f1f283ac', $picture->getResourceID()); $this->assertEquals(array('cs_CZ' => 'F11', 'en_US' => 'F11', 'ru_RU' => 'F11'), $picture->getNames()); }
/** * @param \SimpleXMLElement $element * @return Gallery */ public static function createFromXML(\SimpleXMLElement $element) { /** @var Gallery $gallery */ $gallery = parent::createFromXML($element); if (isset($element->picture)) { foreach ($element->picture as $picture_element) { $picture = Picture::createFromXML($picture_element); $gallery->addPicture($picture); } } $gallery->names = Utils::fetchChildAttributePairs($element, 'name', 'locale', 'text'); return $gallery; }
/** * @param \SimpleXMLElement $element * @return Flat */ public static function createFromXML(\SimpleXMLElement $element) { /** @var Flat $flat */ $flat = parent::createFromXML($element); if (isset($element->picture)) { foreach ($element->picture as $picture_element) { $picture = Picture::createFromXML($picture_element); $flat->addPicture($picture); } } $attributes = Utils::fetchChildAttributePairs($element, 'flat-attribute', 'key', 'value'); foreach ($attributes as $attribute => $value) { $flat->setParameter($attribute, $value); } return $flat; }