X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FImportBundle%2FImport%2FPocketImportTest.php;h=141ece36e26aea05847feac34877f957b8246086;hb=6fb06904ecde15b1b07d0a2af945338b416cf0e2;hp=48fbbfb615ea7fd97abf184bee3b601635a017f1;hpb=ebe0787e093f4f2934430033015d6ebad1c64dca;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index 48fbbfb6..141ece36 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php @@ -24,7 +24,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase protected $contentProxy; protected $logHandler; - private function getPocketImport($consumerKey = 'ConsumerKey') + private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0) { $this->user = new User(); @@ -41,10 +41,29 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $pocket = new PocketImport( - $this->em, - $this->contentProxy - ); + $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([]); + + $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') + ->disableOriginalConstructor() + ->getMock(); + + $dispatcher + ->expects($this->exactly($dispatched)) + ->method('dispatch'); + + $pocket = new PocketImport($this->em, $this->contentProxy, $dispatcher); $pocket->setUser($this->user); $this->logHandler = new TestHandler(); @@ -238,7 +257,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase $client->getEmitter()->attach($mock); - $pocketImport = $this->getPocketImport(); + $pocketImport = $this->getPocketImport('ConsumerKey', 1); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') ->disableOriginalConstructor() @@ -325,7 +344,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase $client->getEmitter()->attach($mock); - $pocketImport = $this->getPocketImport(); + $pocketImport = $this->getPocketImport('ConsumerKey', 2); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') ->disableOriginalConstructor() @@ -566,6 +585,8 @@ JSON; "status": 1, "list": { "229279689": { + "status": "1", + "favorite": "1", "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview" } } @@ -575,7 +596,7 @@ JSON; $client->getEmitter()->attach($mock); - $pocketImport = $this->getPocketImport(); + $pocketImport = $this->getPocketImport('ConsumerKey', 1); $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') ->disableOriginalConstructor() @@ -603,6 +624,6 @@ JSON; $res = $pocketImport->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 1, 'imported' => 0, 'queued' => 0], $pocketImport->getSummary()); + $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary()); } }