+ $this->assertSame(['skipped' => 0, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary());
+ }
+
+ public function testImportWithRabbit()
+ {
+ $wallabagV1Import = $this->getWallabagV1Import();
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
+
+ $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $entryRepo->expects($this->never())
+ ->method('findByUrlAndUserId');
+
+ $this->em
+ ->expects($this->never())
+ ->method('getRepository');
+
+ $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->contentProxy
+ ->expects($this->never())
+ ->method('updateEntry');
+
+ $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $producer
+ ->expects($this->exactly(2))
+ ->method('publish');
+
+ $wallabagV1Import->setProducer($producer);
+
+ $res = $wallabagV1Import->setMarkAsRead(true)->import();
+
+ $this->assertTrue($res);
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
+ }
+
+ public function testImportWithRedis()
+ {
+ $wallabagV1Import = $this->getWallabagV1Import();
+ $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
+
+ $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $entryRepo->expects($this->never())
+ ->method('findByUrlAndUserId');
+
+ $this->em
+ ->expects($this->never())
+ ->method('getRepository');
+
+ $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->contentProxy
+ ->expects($this->never())
+ ->method('updateEntry');
+
+ $factory = new RedisMockFactory();
+ $redisMock = $factory->getAdapter('Predis\Client', true);
+
+ $queue = new RedisQueue($redisMock, 'wallabag_v1');
+ $producer = new Producer($queue);
+
+ $wallabagV1Import->setProducer($producer);
+
+ $res = $wallabagV1Import->setMarkAsRead(true)->import();
+
+ $this->assertTrue($res);
+ $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
+
+ $this->assertNotEmpty($redisMock->lpop('wallabag_v1'));