protected $logHandler;
protected $contentProxy;
- private function getWallabagV2Import($unsetUser = false)
+ private function getWallabagV2Import($unsetUser = false, $dispatched = 0)
{
$this->user = new User();
->disableOriginalConstructor()
->getMock();
+ $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->em
+ ->expects($this->any())
+ ->method('getUnitOfWork')
+ ->willReturn($this->uow);
+
+ $this->uow
+ ->expects($this->any())
+ ->method('getScheduledEntityInsertions')
+ ->willReturn([]);
+
$this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
->disableOriginalConstructor()
->getMock();
- $wallabag = new WallabagV2Import($this->em, $this->contentProxy);
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->exactly($dispatched))
+ ->method('dispatch');
+
+ $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $dispatcher);
$this->logHandler = new TestHandler();
$logger = new Logger('test', [$this->logHandler]);
public function testImport()
{
- $wallabagV2Import = $this->getWallabagV2Import();
+ $wallabagV2Import = $this->getWallabagV2Import(false, 2);
$wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
public function testImportAndMarkAllAsRead()
{
- $wallabagV2Import = $this->getWallabagV2Import();
+ $wallabagV2Import = $this->getWallabagV2Import(false, 2);
$wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-read.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
public function testImportWithExceptionFromGraby()
{
- $wallabagV2Import = $this->getWallabagV2Import();
+ $wallabagV2Import = $this->getWallabagV2Import(false, 2);
$wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
$entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')