<?php
-namespace Tests\Wallabag\ImportBundle\Consumer\AMQP;
+namespace Tests\Wallabag\ImportBundle\Consumer;
-use Wallabag\ImportBundle\Consumer\AMQPEntryConsumer;
use PhpAmqpLib\Message\AMQPMessage;
-use Wallabag\UserBundle\Entity\User;
+use PHPUnit\Framework\TestCase;
use Wallabag\CoreBundle\Entity\Entry;
+use Wallabag\ImportBundle\Consumer\AMQPEntryConsumer;
+use Wallabag\UserBundle\Entity\User;
-class AMQPEntryConsumerTest extends \PHPUnit_Framework_TestCase
+class AMQPEntryConsumerTest extends TestCase
{
public function testMessageOk()
{
->with(json_decode($body, true))
->willReturn($entry);
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->once())
+ ->method('dispatch');
+
$consumer = new AMQPEntryConsumer(
$em,
$userRepository,
- $import
+ $import,
+ $dispatcher
);
$message = new AMQPMessage($body);
->disableOriginalConstructor()
->getMock();
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->never())
+ ->method('dispatch');
+
$consumer = new AMQPEntryConsumer(
$em,
$userRepository,
- $import
+ $import,
+ $dispatcher
);
$message = new AMQPMessage($body);
- $consumer->execute($message);
+ $res = $consumer->execute($message);
+
+ $this->assertTrue($res);
}
public function testMessageWithEntryProcessed()
->with(json_decode($body, true))
->willReturn(null);
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->never())
+ ->method('dispatch');
+
$consumer = new AMQPEntryConsumer(
$em,
$userRepository,
- $import
+ $import,
+ $dispatcher
);
$message = new AMQPMessage($body);