/**
  * @param Promotion $promotion
  * @param string $contentXML
  * @throws \Searchperience\Common\Exception\InvalidArgumentException;
  */
 public function fromXML(Promotion $promotion, $contentXML)
 {
     $contentDOM = new \DOMDocument('1.0', 'UTF-8');
     $result = @$contentDOM->loadXML($contentXML);
     if ($result === false) {
         throw new InvalidArgumentException("No xml content: " . $contentXML);
     }
     $xpath = new \DOMXPath($contentDOM);
     $promotion->__setProperty('promotionTitle', $this->getFirstNodeContent($xpath, '//title'));
     $promotion->__setProperty('promotionType', $this->getFirstNodeContent($xpath, '//type'));
     $promotion->__setProperty('imageUrl', $this->getFirstNodeContent($xpath, '//image'));
     $promotion->__setProperty('language', $this->getFirstNodeContent($xpath, '//language'));
     $promotion->__setProperty('limitedTimeFrom', $this->getFirstNodeContent($xpath, '//limitedTimeFrom'));
     $promotion->__setProperty('limitedTimeTo', $this->getFirstNodeContent($xpath, '//limitedTimeTo'));
     $searchTerms = $xpath->query("//searchterm");
     $keywords = array();
     foreach ($searchTerms as $searchTerm) {
         $keywords[] = $searchTerm->textContent;
     }
     $promotion->__setProperty('keywords', $keywords);
     $solrFieldValues = $xpath->query("//solrfieldvalue");
     $fieldValues = array();
     foreach ($solrFieldValues as $solrFieldValue) {
         /** @var $solrFieldValue \DOMElement */
         $fieldName = $solrFieldValue->getAttribute("fieldname");
         $fieldValues[$fieldName] = $solrFieldValue->textContent;
     }
     $promotion->__setProperty('fieldValues', $fieldValues);
     $promotion->__setProperty('promotionContent', $this->getFirstNodeContent($xpath, '//content'));
 }
 /**
  * @test
  */
 public function afterReconstitutionIsNotThrowingErrorWithEmptyContent()
 {
     $this->promotion->afterReconstitution();
 }