namespace Tests\Wallabag\ImportBundle\Consumer\AMQP;
+use PHPUnit\Framework\TestCase;
+use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\ImportBundle\Consumer\RedisEntryConsumer;
use Wallabag\UserBundle\Entity\User;
-use Wallabag\CoreBundle\Entity\Entry;
-class RedisEntryConsumerTest extends \PHPUnit_Framework_TestCase
+class RedisEntryConsumerTest 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 RedisEntryConsumer(
$em,
$userRepository,
- $import
+ $import,
+ $dispatcher
);
$res = $consumer->manage($body);
->disableOriginalConstructor()
->getMock();
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $dispatcher
+ ->expects($this->never())
+ ->method('dispatch');
+
$consumer = new RedisEntryConsumer(
$em,
$userRepository,
- $import
+ $import,
+ $dispatcher
);
$res = $consumer->manage($body);
- $this->assertFalse($res);
+ $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 RedisEntryConsumer(
$em,
$userRepository,
- $import
+ $import,
+ $dispatcher
);
$res = $consumer->manage($body);