From 13470c3596d0b1490bbf18b39128a05bbb3c7f3e Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 9 Sep 2016 18:02:29 +0200 Subject: Add test for RabbitMQ Also update Symfony deps --- .../ImportBundle/Import/ReadabilityImportTest.php | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php') diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php index 706d707b..69a66d6a 100644 --- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php @@ -120,6 +120,46 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase $this->assertEquals(['skipped' => 0, 'imported' => 2], $readabilityImport->getSummary()); } + public function testImportWithRabbit() + { + $readabilityImport = $this->getReadabilityImport(); + $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.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'); + + $readabilityImport->setRabbitmqProducer($producer); + + $res = $readabilityImport->setMarkAsRead(true)->import(); + + $this->assertTrue($res); + $this->assertEquals(['skipped' => 0, 'imported' => 2], $readabilityImport->getSummary()); + } + public function testImportBadFile() { $readabilityImport = $this->getReadabilityImport(); -- cgit v1.2.3