ProophTest\ServiceBus\Plugin\Guard\FinalizeGuardTest::it_stops_propagation_and_throws_unauthorizedexception_when_authorization_service_denies_access_with_deferred_and_exposes_message_name PHP Method

it_stops_propagation_and_throws_unauthorizedexception_when_authorization_service_denies_access_with_deferred_and_exposes_message_name() public method

    public function it_stops_propagation_and_throws_unauthorizedexception_when_authorization_service_denies_access_with_deferred_and_exposes_message_name()
    {
        $authorizationService = $this->prophesize(AuthorizationService::class);
        $authorizationService->isGranted('test_event', 'result')->willReturn(false);
        $deferred = new Deferred();
        $deferred->resolve('result');
        $actionEvent = new DefaultActionEvent(QueryBus::EVENT_FINALIZE);
        $actionEvent->setParam(QueryBus::EVENT_PARAM_PROMISE, $deferred->promise());
        $actionEvent->setParam(QueryBus::EVENT_PARAM_MESSAGE_NAME, 'test_event');
        $routeGuard = new FinalizeGuard($authorizationService->reveal(), true);
        $routeGuard->onFinalize($actionEvent);
        $this->assertTrue($actionEvent->propagationIsStopped());
        $actionEvent->getParam(QueryBus::EVENT_PARAM_PROMISE)->done();
    }