/**
  * @test
  */
 public function canInitializeProductFromProductXml()
 {
     $expectedXml = $this->getFixtureContent('Api/Client/Domain/Document/Fixture/testproduct.xml');
     $this->product->__setProperty('content', $expectedXml);
     $this->product->afterReconstitution();
     $this->assertSame(118948, $this->product->getProductId(), 'Could not get product with expected productId');
     $this->assertSame(1, $this->product->getStoreId(), 'Could not restore storeId');
     $this->assertSame("de_DE", $this->product->getLanguage(), 'Could not restore language');
     $this->assertSame("103115", $this->product->getSku(), 'Could not restore sku');
     $this->assertSame("Foo", $this->product->getTitle(), 'Could not restore title');
     $this->assertSame("long description", $this->product->getDescription(), 'Could not restore description');
     $this->assertSame("short description", $this->product->getShortDescription(), 'Could not restore short description');
     $this->assertSame(42.36, $this->product->getPrice(), 'Could not restore price');
     $this->assertSame(100.0, $this->product->getSpecialPrice(), 'Could not get special price');
     $this->assertSame(101.0, $this->product->getGroupPrice(), 'Could not get group price');
     $this->assertSame('http://www.searchperience.de/test.gif', $this->product->getImageLink(), 'Could not restore image link');
     $this->assertSame(2, count($this->product->getCategoryPaths()), 'Could not restore category pathes');
     $this->assertSame(2, count($this->product->getAttributes()), 'Could not restore attributes');
 }
 /**
  * @param \DOMXPath $xpath
  * @param Product $product
  */
 protected function restoreAttributesFromDOMContent($xpath, Product $product)
 {
     $attributeNodes = $xpath->query("//attribute");
     $attributes = array();
     foreach ($attributeNodes as $attributeNode) {
         /** @var $attributeNode \DOMElement */
         $name = $attributeNode->getAttribute("name");
         $type = $attributeNode->getAttribute("type");
         $forSearching = $attributeNode->getAttribute("forsearching") == "1";
         $forFaceting = $attributeNode->getAttribute("forfaceting") == "1";
         $forSorting = $attributeNode->getAttribute("forsorting") == "1";
         $attribute = new ProductAttribute();
         $attribute->setName($name);
         $attribute->setType($type);
         $attribute->setForSearching($forSearching);
         $attribute->setForFaceting($forFaceting);
         $attribute->setForSorting($forSorting);
         $values = $xpath->query("value", $attributeNode);
         foreach ($values as $value) {
             /** @var $value \DOMElement */
             $attribute->addValue($value->textContent);
         }
         $attributes[$attribute->getName()] = $attribute;
     }
     $product->__setProperty('attributes', $attributes);
 }