X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FImportBundle%2FImport%2FWallabagV1ImportTest.php;h=4dbced604bc5ae59061b2bb46aedaeb2d327622b;hb=68003139e133835805b143b62c4407f19b495dab;hp=5ab4ad008738d977b0dbe17c9d8db64325c0103a;hpb=c80cc01afa315dcfa38b2a01c5b05d4516659c24;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php index 5ab4ad00..4dbced60 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php @@ -18,7 +18,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase protected $logHandler; protected $contentProxy; - private function getWallabagV1Import($unsetUser = false) + private function getWallabagV1Import($unsetUser = false, $dispatched = 0) { $this->user = new User(); @@ -26,11 +26,33 @@ class WallabagV1ImportTest 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(); - $wallabag = new WallabagV1Import($this->em, $this->contentProxy); + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') + ->disableOriginalConstructor() + ->getMock(); + + $dispatcher + ->expects($this->exactly($dispatched)) + ->method('dispatch'); + + $wallabag = new WallabagV1Import($this->em, $this->contentProxy, $dispatcher); $this->logHandler = new TestHandler(); $logger = new Logger('test', [$this->logHandler]); @@ -54,7 +76,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase public function testImport() { - $wallabagV1Import = $this->getWallabagV1Import(); + $wallabagV1Import = $this->getWallabagV1Import(false, 3); $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') @@ -87,7 +109,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase public function testImportAndMarkAllAsRead() { - $wallabagV1Import = $this->getWallabagV1Import(); + $wallabagV1Import = $this->getWallabagV1Import(false, 3); $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1-read.json'); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')