Fix some tests

This commit is contained in:
2023-12-14 21:18:00 +01:00
parent d5476df14c
commit 2dd1b7c943
11 changed files with 92 additions and 127 deletions

View File

@@ -18,7 +18,10 @@ use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\TerminateEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
* @internal
@@ -35,14 +38,17 @@ final class PersistNotificationOnTerminateEventSubscriberTest extends TestCase
$em = $this->prophesize(EntityManagerInterface::class);
$em->persist(Argument::type(Notification::class))->shouldBeCalledTimes(1);
$em->flush()->shouldBeCalledTimes(1);
$event = $this->prophesize(TerminateEvent::class);
$event->isMainRequest()->willReturn(true);
$event = new TerminateEvent(
$this->prophesize(HttpKernelInterface::class)->reveal(),
new Request(),
new Response()
);
$eventSubscriber = new PersistNotificationOnTerminateEventSubscriber($em->reveal(), $persister);
$notification = new Notification();
$persister->persist($notification);
$eventSubscriber->onKernelTerminate($event->reveal());
$eventSubscriber->onKernelTerminate($event);
}
}