Eko\FeedBundle\Service\FeedDumpService::setEntity PHP Method

setEntity() public method

Sets the value of entity.
public setEntity ( mixed $entity )
$entity mixed the entity
    public function setEntity($entity)
    {
        $this->entity = $entity;
        return $this;
    }

Usage Example

Example #1
0
 /**
  * Tests the dump() method with an entity.
  */
 public function testDumpWithAnEntity()
 {
     if (!method_exists($this->filesystem, 'dumpFile')) {
         $this->markTestSkipped('Test skipped as Filesystem::dumpFile() is not available in this version.');
     }
     // Given
     $this->service->setRootDir('/unit/test/');
     $this->service->setFilename('feed.rss');
     $this->service->setEntity('Eko\\FeedBundle\\Tests\\Entity\\Writer\\FakeItemInterfaceEntity');
     $this->service->setDirection('ASC');
     $entity = $this->getMock('Eko\\FeedBundle\\Tests\\Entity\\Writer\\FakeItemInterfaceEntity');
     $repository = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('findBy')->will($this->returnValue([$entity, $entity]));
     $this->entityManager->expects($this->once())->method('getRepository')->will($this->returnValue($repository));
     $feed = $this->getMockBuilder('Eko\\FeedBundle\\Feed\\Feed')->disableOriginalConstructor()->getMock();
     $feed->expects($this->once())->method('addFromArray');
     $feed->expects($this->once())->method('render')->will($this->returnValue('XML content'));
     $this->feedManager->expects($this->once())->method('get')->will($this->returnValue($feed));
     $this->filesystem->expects($this->once())->method('dumpFile')->with('/unit/test/feed.rss', 'XML content');
     // When - Expects actions
     $this->service->dump();
 }