/**
  * @param \DOMDocument $dom
  * @param \DOMElement $productNode
  * @param Product $product
  */
 protected function addAttributeNodesToContentDom($dom, \DOMElement $productNode, Product $product)
 {
     foreach ($product->getAttributes() as $productAttribute) {
         /** @var $productAttribute ProductAttribute */
         $attributeNode = $dom->createElement('attribute');
         $attributeNode->setAttribute("name", $productAttribute->getName());
         $attributeNode->setAttribute("type", $productAttribute->getType());
         if ($productAttribute->getForSearching()) {
             $attributeNode->setAttribute("forsearching", 1);
         }
         if ($productAttribute->getForSorting()) {
             $attributeNode->setAttribute("forsorting", 1);
         }
         if ($productAttribute->getForFaceting()) {
             $attributeNode->setAttribute("forfaceting", 1);
         }
         $values = $productAttribute->getValues();
         foreach ($values as $value) {
             $valueNode = $dom->createElement('value');
             $valueTextNode = $dom->createTextNode($value);
             if ($valueTextNode instanceof \DOMNode) {
                 $valueNode->appendChild($valueTextNode);
             }
             $attributeNode->appendChild($valueNode);
         }
         $productNode->appendChild($attributeNode);
     }
 }
 /**
  * @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()));
 }