diff --git a/src/Plugin/Guard/FinalizeGuard.php b/src/Plugin/Guard/FinalizeGuard.php index daf75e3..bb47f52 100644 --- a/src/Plugin/Guard/FinalizeGuard.php +++ b/src/Plugin/Guard/FinalizeGuard.php @@ -45,7 +45,7 @@ function (ActionEvent $actionEvent): void { $messageName = $actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE_NAME); if ($promise instanceof Promise) { - $newPromise = $promise->then(function ($result) use ($actionEvent, $messageName): void { + $newPromise = $promise->then(function ($result) use ($actionEvent, $messageName) { if (! $this->authorizationService->isGranted($messageName, $result)) { $actionEvent->stopPropagation(true); @@ -55,8 +55,9 @@ function (ActionEvent $actionEvent): void { throw new UnauthorizedException($messageName); } - }); + return $result; + }); $actionEvent->setParam(QueryBus::EVENT_PARAM_PROMISE, $newPromise); } elseif (! $this->authorizationService->isGranted($messageName)) { $actionEvent->stopPropagation(true); diff --git a/tests/Plugin/Guard/FinalizeGuardTest.php b/tests/Plugin/Guard/FinalizeGuardTest.php index 61eaeed..5a16f41 100644 --- a/tests/Plugin/Guard/FinalizeGuardTest.php +++ b/tests/Plugin/Guard/FinalizeGuardTest.php @@ -72,7 +72,10 @@ function (ActionEvent $actionEvent): void { ); $promise = $this->messageBus->dispatch('test_event'); - $promise->done(); + $promise->done(function ($result) { + $this->assertNotNull($result); + $this->assertEquals('result', $result); + }); } /**