spec\Sylius\Bundle\ResourceBundle\Controller\ResourceControllerSpec::it_does_not_apply_state_machine_transition_resource_and_throws_http_exception_for_non_html_requests_stopped_via_event PHP Метод

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

public it_does_not_apply_state_machine_transition_resource_and_throws_http_exception_for_non_html_requests_stopped_via_event ( Sylius\Component\Resource\Metadata\MetadataInterface $metadata, Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactoryInterface $requestConfigurationFactory, RequestConfiguration $configuration, Sylius\Bundle\ResourceBundle\Controller\AuthorizationCheckerInterface $authorizationChecker, Sylius\Component\Resource\Repository\RepositoryInterface $repository, Doctrine\Common\Persistence\ObjectManager $objectManager, Sylius\Bundle\ResourceBundle\Controller\StateMachineInterface $stateMachine, Sylius\Bundle\ResourceBundle\Controller\SingleResourceProviderInterface $singleResourceProvider, Sylius\Component\Resource\Model\ResourceInterface $resource, Sylius\Bundle\ResourceBundle\Controller\FlashHelperInterface $flashHelper, Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface $eventDispatcher, Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent $event, Request $request )
$metadata Sylius\Component\Resource\Metadata\MetadataInterface
$requestConfigurationFactory Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactoryInterface
$configuration Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration
$authorizationChecker Sylius\Bundle\ResourceBundle\Controller\AuthorizationCheckerInterface
$repository Sylius\Component\Resource\Repository\RepositoryInterface
$objectManager Doctrine\Common\Persistence\ObjectManager
$stateMachine Sylius\Bundle\ResourceBundle\Controller\StateMachineInterface
$singleResourceProvider Sylius\Bundle\ResourceBundle\Controller\SingleResourceProviderInterface
$resource Sylius\Component\Resource\Model\ResourceInterface
$flashHelper Sylius\Bundle\ResourceBundle\Controller\FlashHelperInterface
$eventDispatcher Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface
$event Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent
$request Symfony\Component\HttpFoundation\Request
    function it_does_not_apply_state_machine_transition_resource_and_throws_http_exception_for_non_html_requests_stopped_via_event(MetadataInterface $metadata, RequestConfigurationFactoryInterface $requestConfigurationFactory, RequestConfiguration $configuration, AuthorizationCheckerInterface $authorizationChecker, RepositoryInterface $repository, ObjectManager $objectManager, StateMachineInterface $stateMachine, SingleResourceProviderInterface $singleResourceProvider, ResourceInterface $resource, FlashHelperInterface $flashHelper, EventDispatcherInterface $eventDispatcher, ResourceControllerEvent $event, Request $request)
    {
        $metadata->getApplicationName()->willReturn('sylius');
        $metadata->getName()->willReturn('product');
        $requestConfigurationFactory->create($metadata, $request)->willReturn($configuration);
        $configuration->hasPermission()->willReturn(true);
        $configuration->getPermission(ResourceActions::UPDATE)->willReturn('sylius.product.update');
        $authorizationChecker->isGranted($configuration, 'sylius.product.update')->willReturn(true);
        $singleResourceProvider->get($configuration, $repository)->willReturn($resource);
        $configuration->isHtmlRequest()->willReturn(false);
        $eventDispatcher->dispatchPreEvent(ResourceActions::UPDATE, $configuration, $resource)->willReturn($event);
        $event->isStopped()->willReturn(true);
        $event->getMessage()->willReturn('Cannot approve this product.');
        $event->getErrorCode()->willReturn(500);
        $stateMachine->apply($configuration, $resource)->shouldNotBeCalled();
        $objectManager->flush()->shouldNotBeCalled();
        $eventDispatcher->dispatchPostEvent(Argument::any())->shouldNotBeCalled();
        $flashHelper->addSuccessFlash(Argument::any())->shouldNotBeCalled();
        $flashHelper->addFlashFromEvent(Argument::any())->shouldNotBeCalled();
        $this->shouldThrow(new HttpException(500, 'Cannot approve this product.'))->during('applyStateMachineTransitionAction', [$request]);
    }
ResourceControllerSpec