/**
  * Test for modify().
  */
 public function testModify()
 {
     $modifier = new ContentModifier();
     /** @var Content $content */
     $content = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\Content');
     $content->setId('testId')->setActive(true)->setPosition(4)->setContent('testContent')->setTitle('testTitle')->setFolder('testFolder')->setLoadId('testSlug')->setSnippet(false)->setType(5)->setFolder('testFolder');
     /** @var Seo|\PHPUnit_Framework_MockObject_MockObject $seo */
     $seo = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\Seo');
     $seo->setSeoUrl('test');
     /** @var SeoFinder|\PHPUnit_Framework_MockObject_MockObject $seoFinder */
     $seoFinder = $this->getMockBuilder('ONGR\\OXIDConnectorBundle\\Service\\SeoFinder')->disableOriginalConstructor()->getMock();
     $seoFinder->expects($this->once())->method('getEntitySeo')->willReturn(new \ArrayIterator([$seo]));
     $modifier->setSeoFinderService($seoFinder);
     $expectedDocument = new ContentDocument();
     $expectedDocument->setId('testId');
     $expectedDocument->setActive(true);
     $expectedDocument->setPosition(4);
     $expectedDocument->setContent('testContent');
     $expectedDocument->setTitle('testTitle');
     $expectedDocument->setFolder('testFolder');
     $expectedDocument->setSlug('testSlug');
     $expectedDocument->setSnippet(false);
     $expectedDocument->setType(5);
     $expectedDocument->setFolder('testFolder');
     $url = new UrlNested();
     $url->setUrl('test');
     $expectedDocument->setUrls(new \ArrayIterator([$url]));
     $expectedDocument->setExpiredUrls([]);
     $document = new ContentDocument();
     /** @var ItemPipelineEvent|\PHPUnit_Framework_MockObject_MockObject $event */
     $event = $this->getMock('ONGR\\ConnectionsBundle\\Pipeline\\Event\\ItemPipelineEvent', [], [], '', false);
     $modifier->modify(new ImportItem($content, $document), $event);
     $this->assertEquals($expectedDocument, $document);
 }
 /**
  * Test for modify().
  */
 public function testModify()
 {
     $modifier = new ContentModifier();
     /** @var Content $content */
     $content = $this->getMockForAbstractClass('ONGR\\OXIDConnectorBundle\\Entity\\Content');
     $content->setId('testId')->setActive(true)->setPosition(4)->setContent('testContent')->setTitle('testTitle')->setFolder('testFolder')->setLoadId('testSlug')->setSnippet(false)->setType(5)->setFolder('testFolder');
     $expectedDocument = new ContentDocument();
     $expectedDocument->setId('testId');
     $expectedDocument->setActive(true);
     $expectedDocument->setPosition(4);
     $expectedDocument->setContent('testContent');
     $expectedDocument->setTitle('testTitle');
     $expectedDocument->setFolder('testFolder');
     $expectedDocument->setSlug('testSlug');
     $expectedDocument->setSnippet(false);
     $expectedDocument->setType(5);
     $expectedDocument->setFolder('testFolder');
     $expectedDocument->setUrls(new \ArrayIterator());
     $expectedDocument->setExpiredUrls([]);
     $document = new ContentDocument();
     /** @var ItemPipelineEvent|\PHPUnit_Framework_MockObject_MockObject $event */
     $event = $this->getMock('ONGR\\ConnectionsBundle\\Pipeline\\Event\\ItemPipelineEvent', [], [], '', false);
     $modifier->modify(new ImportItem($content, $document), $event);
     $this->assertEquals($expectedDocument, $document);
 }
 /**
  * Test modification.
  */
 public function testModify()
 {
     $expectedContent1 = new ContentDocument();
     $expectedContent1->setId('8709e45f31a86909e9f999222e80b1d0');
     $expectedContent1->setContent('CONTENT ONE');
     $expectedContent1->setTitle('TITLE OF CONTENT ONE');
     $expectedContent1->setFolder('CMSFOLDER_STANDARD');
     $expectedContent1->setSlug('oxstdfooter');
     $expectedContent1->setSnippet(true);
     $expectedContent1->setType(2);
     $expectedContent1->setActive(false);
     $expectedContent1->setPosition('position1');
     $url = new UrlNested();
     $url->setUrl('Test/Content/1');
     $expectedContent1->setUrls(new \ArrayIterator([$url]));
     $expectedContent1->setExpiredUrls([]);
     $expectedContent2 = new ContentDocument();
     $expectedContent2->setId('ad542e49bff479009.64538090');
     $expectedContent2->setContent('<div>Content two</div>');
     $expectedContent2->setTitle('Title of content two');
     $expectedContent2->setFolder('CMSFOLDER_EMAILS');
     $expectedContent2->setSlug('oxadminorderemail');
     $expectedContent2->setSnippet(false);
     $expectedContent2->setType(1);
     $expectedContent2->setActive(true);
     $expectedContent2->setPosition('position2');
     $url = new UrlNested();
     $url->setUrl('Test/Content/2');
     $expectedContent2->setUrls(new \ArrayIterator([$url]));
     $expectedContent2->setExpiredUrls([]);
     $expectedEntities = [$expectedContent1, $expectedContent2];
     $contentItems = $this->getTestElements(['8709e45f31a86909e9f999222e80b1d0', 'ad542e49bff479009.64538090'], 'ONGROXIDConnectorBundleTest:Content');
     $this->assertCount(2, $contentItems);
     $seoFinder = new SeoFinder();
     $seoFinder->setEntityManager($this->getEntityManager());
     $seoFinder->setShopId(0);
     $seoFinder->setRepository('ONGROXIDConnectorBundleTest:Seo');
     $modifier = new ContentModifier();
     $modifier->setSeoFinderService($seoFinder);
     /** @var ItemPipelineEvent|\PHPUnit_Framework_MockObject_MockObject $event */
     $event = $this->getMock('ONGR\\ConnectionsBundle\\Pipeline\\Event\\ItemPipelineEvent', [], [], '', false);
     foreach ($expectedEntities as $key => $expectedContent) {
         $actualContent = new ContentDocument();
         $modifier->modify(new ImportItem($contentItems[$key], $actualContent), $event);
         $this->assertEquals($expectedContent, $actualContent);
     }
 }
 /**
  * Test content modifier listener.
  */
 public function testContentModifierListener()
 {
     $this->mockExpectsMethods($this->contEntity, [['getId', 1, 123], ['getTitle', 1, 'testTitle'], ['getContent', 1, 'testContent'], ['getFolder', 1, 'testFolder'], ['getLoadId', 1, 'testLoadId'], ['isSnippet', 1, false], ['getType', 1, 'testType'], ['isActive', 1, true], ['getPosition', 1, 9]]);
     $this->mockExpectsMethods($this->contDocument, [['setId', 1, null, 123], ['setTitle', 1, null, 'testTitle'], ['setContent', 1, null, 'testContent'], ['setFolder', 1, null, 'testFolder'], ['setSlug', 1, null, 'testLoadId'], ['setSnippet', 1, null, false], ['setType', 1, null, 'testType'], ['setActive', 1, null, true], ['setPosition', 1, null, 9]]);
     /** @var ImportItem|MockObject $importItem */
     $importItem = $this->getMockBuilder('ONGR\\ConnectionsBundle\\Pipeline\\Item\\ImportItem')->disableOriginalConstructor()->getMock();
     $importItem->expects($this->once())->method('getEntity')->will($this->returnValue($this->contEntity));
     $importItem->expects($this->once())->method('getDocument')->will($this->returnValue($this->contDocument));
     /** @var ItemPipelineEvent|MockObject $itemPipelineEvent */
     $itemPipelineEvent = $this->getMockBuilder('\\ONGR\\ConnectionsBundle\\Pipeline\\Event\\ItemPipelineEvent')->disableOriginalConstructor()->getMock();
     $itemPipelineEvent->expects($this->once())->method('getItem')->will($this->returnValue($importItem));
     $this->contModifierListener->onModify($itemPipelineEvent);
 }