/**
  * @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);
 }
 /**
  * @test
  */
 public function canSetAttributes()
 {
     $productAttribute = new ProductAttribute();
     $productAttribute->setType(ProductAttribute::TYPE_DATE);
     $productAttribute->setName('birtyday');
     $productAttribute->addValue('foo');
     $productAttributes = array();
     $productAttributes[] = $productAttribute;
     $this->product->setAttributes($productAttributes);
     $this->assertEquals(1, count($this->product->getAttributes()));
 }