Skip to content

Commit

Permalink
IBX-7055: Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
mikadamczyk committed Dec 5, 2023
1 parent d1da7ce commit 308d0bf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/lib/Event/TrashServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,41 @@ public function testTrashStopPropagationInBeforeEvents()
]);
}

public function testTrashStopPropagationInBeforeEventsSetNullResult(): void
{
$traceableEventDispatcher = $this->getEventDispatcher(
BeforeTrashEvent::class,
TrashEvent::class
);

$parameters = [
$this->createMock(Location::class),
];

$innerServiceMock = $this->createMock(TrashServiceInterface::class);
$innerServiceMock->expects(self::never())->method('trash');

$traceableEventDispatcher->addListener(BeforeTrashEvent::class, static function (BeforeTrashEvent $event) {
$event->setResult(null);
$event->stopPropagation();
}, 10);

$service = new TrashService($innerServiceMock, $traceableEventDispatcher);
$result = $service->trash(...$parameters);

$calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
$notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners());

$this->assertNull($result);
$this->assertSame($calledListeners, [
[BeforeTrashEvent::class, 10],
]);
$this->assertSame($notCalledListeners, [
[BeforeTrashEvent::class, 0],
[TrashEvent::class, 0],
]);
}

public function testRecoverEvents()
{
$traceableEventDispatcher = $this->getEventDispatcher(
Expand Down

0 comments on commit 308d0bf

Please sign in to comment.