mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
deferring the sending of notification to kernel.terminate: prepare
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Notification\EventListener;
|
||||
|
||||
use Chill\MainBundle\Entity\Notification;
|
||||
use Chill\MainBundle\Notification\EventListener\PersistNotificationOnTerminateEventSubscriber;
|
||||
use Chill\MainBundle\Notification\NotificationPersister;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\HttpKernel\Event\TerminateEvent;
|
||||
|
||||
class PersistNotificationOnTerminateEventSubscriberTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function testNotificationIsPersisted()
|
||||
{
|
||||
$persister = new NotificationPersister();
|
||||
$em = $this->prophesize(EntityManagerInterface::class);
|
||||
$em->persist(Argument::type(Notification::class))->shouldBeCalledTimes(1);
|
||||
$em->flush()->shouldBeCalledTimes(1);
|
||||
$event = $this->prophesize(TerminateEvent::class);
|
||||
$event->isMasterRequest()->willReturn(true);
|
||||
|
||||
$eventSubscriber = new PersistNotificationOnTerminateEventSubscriber($em->reveal(), $persister);
|
||||
|
||||
$notification = new Notification();
|
||||
$persister->persist($notification);
|
||||
|
||||
$eventSubscriber->onKernelTerminate($event->reveal());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user