/**
  * Test method for articles.
  */
 public function testTransformArticleToDocument()
 {
     $attributes = new ArrayCollection();
     $expected = [];
     /** @var Article|MockObject $mockArticle */
     $mockArticle = $this->getMockForAbstractClass('\\ONGR\\OXIDConnectorBundle\\Entity\\Article');
     for ($i = 1; $i <= 10; $i++) {
         $artToAttr = new ArticleToAttribute();
         $artToAttr->setId($i);
         $artToAttr->setPos($i);
         $artToAttr->setArticle($mockArticle);
         $attr = new Attribute();
         $attr->setPos($i + 2);
         $attr->setTitle('Some other title ' . $i);
         $artToAttr->setAttribute($attr);
         $attributes->add($artToAttr);
         $expected[] = $artToAttr;
     }
     $result = $this->service->transform($attributes);
     foreach ($result as $idx => $actual) {
         $this->assertInstanceOf('\\ONGR\\OXIDConnectorBundle\\Document\\AttributeObject', $actual);
         $this->assertEquals('Some other title ' . ($idx + 1), $actual->getTitle());
         $this->assertEquals($idx + 3, $actual->getPos());
     }
 }
 /**
  * Test for modify().
  */
 public function testModify()
 {
     /** @var Category $root */
     $root = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\Category');
     $root->setId('testIdRoot');
     /** @var Category $category */
     $category = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\Category');
     // Attribute to be added to Category.
     $attribute = new Attribute();
     $attribute->setId(123);
     $attribute->setPos(1);
     $attribute->setTitle('testAttributeTitle');
     $catToAttr = new CategoryToAttribute();
     $catToAttr->setId(321);
     $catToAttr->setSort(1);
     $catToAttr->setCategory($category);
     $catToAttr->setAttribute($attribute);
     $category->setId('testId')->setActive(true)->setHidden(false)->setTitle('testTitle')->setDesc('testDescription')->setLongDesc('testLongDescription')->setSort(3)->setRoot($root)->setRight(501)->setLeft(102)->addAttribute($catToAttr);
     /** @var CategoryDocument $expectedDocument */
     $expectedDocument = new CategoryDocument();
     $expectedDocument->setId('testId');
     $expectedDocument->setActive(true);
     $expectedDocument->setHidden(false);
     $expectedDocument->setTitle('testTitle');
     $expectedDocument->setDescription('testDescription');
     $expectedDocument->setLongDescription('testLongDescription');
     $expectedDocument->setSort(3);
     $expectedDocument->setRootId('testIdRoot');
     $expectedDocument->setParentId('oxrootid');
     $expectedDocument->setLeft(102);
     $expectedDocument->setRight(501);
     $url = new UrlNested();
     $url->setUrl('test');
     $expectedDocument->setUrls(new \ArrayIterator([$url]));
     $expectedDocument->setExpiredUrls([]);
     $attrObj = new AttributeObject();
     $attrObj->setPos(1);
     $attrObj->setTitle('testAttributeTitle');
     $expectedDocument->setAttributes([$attrObj]);
     $document = new CategoryDocument();
     /** @var ItemPipelineEvent|\PHPUnit_Framework_MockObject_MockObject $event */
     $event = $this->getMock('ONGR\\ConnectionsBundle\\Pipeline\\Event\\ItemPipelineEvent', [], [], '', false);
     $this->modifier->modify(new ImportItem($category, $document), $event);
     $this->assertEquals($expectedDocument, $document);
 }
 /**
  * @param Article $parent
  *
  * @return Article[] ;
  */
 private function getVariants($parent)
 {
     /** @var ArticleExtension $extension */
     $extension = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\ArticleExtension');
     $extension->setLongDesc('Long description');
     /** @var Article $entity1 */
     $entity1 = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\Article');
     $attribute = new Attribute();
     $attribute->setId(125);
     $attribute->setPos(1);
     $attribute->setTitle('testAttributeTitle');
     $artToAttr = new ArticleToAttribute();
     $artToAttr->setId(3213);
     $artToAttr->setPos(1);
     $artToAttr->setArticle($entity1);
     $artToAttr->setAttribute($attribute);
     $entity1->setId('id1235')->setActive(true)->setArtNum('abc123')->setTitle('Any title')->setShortDesc('Short description')->setPrice(13.34)->setTPrice(44.21)->setExtension($extension)->setStock(5)->setStockFlag(1)->addAttribute($artToAttr)->setParent($parent);
     /** @var ArticleExtension $extension */
     $extension = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\ArticleExtension');
     $extension->setLongDesc('Long description2');
     /** @var Article $entity2 */
     $entity2 = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\Article');
     $attribute = new Attribute();
     $attribute->setId(126);
     $attribute->setPos(1);
     $attribute->setTitle('testAttributeTitle2');
     $artToAttr = new ArticleToAttribute();
     $artToAttr->setId(3211);
     $artToAttr->setPos(1);
     $artToAttr->setArticle($entity2);
     $artToAttr->setAttribute($attribute);
     $entity2->setId('id1234')->setActive(false)->setArtNum('abc1234')->setTitle('Any title2')->setShortDesc('Short description2')->setPrice(13.34)->setTPrice(44.21)->setExtension($extension)->setStock(6)->setStockFlag(1)->addAttribute($artToAttr)->setParent($parent);
     return [$entity1, $entity2];
 }