ProophTest\ServiceBus\Plugin\Guard\FinalizeGuardTest::it_allows_when_authorization_service_grants_access_with_deferred PHP Метод

it_allows_when_authorization_service_grants_access_with_deferred() публичный Метод

    public function it_allows_when_authorization_service_grants_access_with_deferred()
    {
        $authorizationService = $this->prophesize(AuthorizationService::class);
        $authorizationService->isGranted('test_event', 'result')->willReturn(true);
        $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());
        $routeGuard->onFinalize($actionEvent);
        $actionEvent->getParam(QueryBus::EVENT_PARAM_PROMISE)->done();
    }