X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FImportBundle%2FImport%2FInstapaperImportTest.php;h=9158c8a23277f411f3a41f28176aca93ed3b01e7;hb=873f6b8e03079d11fab541aa5b0bc6f8fe2d645e;hp=6777a02e880a7c3e0fb14f4356eedeb067ad0f3b;hpb=7aa5607f297d5ef188d06cc3f808f9ff5bda83b2;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php index 6777a02e..9158c8a2 100644 --- a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php @@ -18,6 +18,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase protected $logHandler; protected $contentProxy; protected $tagsAssigner; + protected $uow; private function getInstapaperImport($unsetUser = false, $dispatched = 0) { @@ -27,6 +28,20 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase ->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(); @@ -67,14 +82,14 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase public function testImport() { - $instapaperImport = $this->getInstapaperImport(false, 3); + $instapaperImport = $this->getInstapaperImport(false, 4); $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(3)) + $entryRepo->expects($this->exactly(4)) ->method('findByUrlAndUserId') ->willReturn(false); @@ -88,14 +103,14 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->contentProxy - ->expects($this->exactly(3)) + ->expects($this->exactly(4)) ->method('updateEntry') ->willReturn($entry); $res = $instapaperImport->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $instapaperImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $instapaperImport->getSummary()); } public function testImportAndMarkAllAsRead() @@ -107,9 +122,9 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(3)) + $entryRepo->expects($this->exactly(4)) ->method('findByUrlAndUserId') - ->will($this->onConsecutiveCalls(false, true, true)); + ->will($this->onConsecutiveCalls(false, true, true, true)); $this->em ->expects($this->any()) @@ -133,7 +148,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase $this->assertTrue($res); - $this->assertEquals(['skipped' => 2, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary()); + $this->assertEquals(['skipped' => 3, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary()); } public function testImportWithRabbit() @@ -165,7 +180,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase ->getMock(); $producer - ->expects($this->exactly(3)) + ->expects($this->exactly(4)) ->method('publish'); $instapaperImport->setProducer($producer); @@ -173,7 +188,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase $res = $instapaperImport->setMarkAsRead(true)->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $instapaperImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary()); } public function testImportWithRedis() @@ -211,7 +226,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase $res = $instapaperImport->setMarkAsRead(true)->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $instapaperImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary()); $this->assertNotEmpty($redisMock->lpop('instapaper')); }