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

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

public it_does_not_update_the_resource_throws_a_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\Bundle\ResourceBundle\Controller\ViewHandlerInterface $viewHandler, Doctrine\Common\Persistence\ObjectManager $manager, Sylius\Component\Resource\Repository\RepositoryInterface $repository, Sylius\Bundle\ResourceBundle\Controller\SingleResourceProviderInterface $singleResourceProvider, Sylius\Component\Resource\Model\ResourceInterface $resource, Sylius\Bundle\ResourceBundle\Controller\ResourceFormFactoryInterface $resourceFormFactory, Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface $eventDispatcher, Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent $event, Form $form, 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
$viewHandler Sylius\Bundle\ResourceBundle\Controller\ViewHandlerInterface
$manager Doctrine\Common\Persistence\ObjectManager
$repository Sylius\Component\Resource\Repository\RepositoryInterface
$singleResourceProvider Sylius\Bundle\ResourceBundle\Controller\SingleResourceProviderInterface
$resource Sylius\Component\Resource\Model\ResourceInterface
$resourceFormFactory Sylius\Bundle\ResourceBundle\Controller\ResourceFormFactoryInterface
$eventDispatcher Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface
$event Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent
$form Symfony\Component\Form\Form
$request Symfony\Component\HttpFoundation\Request
    function it_does_not_update_the_resource_throws_a_http_exception_for_non_html_requests_stopped_via_event(MetadataInterface $metadata, RequestConfigurationFactoryInterface $requestConfigurationFactory, RequestConfiguration $configuration, AuthorizationCheckerInterface $authorizationChecker, ViewHandlerInterface $viewHandler, ObjectManager $manager, RepositoryInterface $repository, SingleResourceProviderInterface $singleResourceProvider, ResourceInterface $resource, ResourceFormFactoryInterface $resourceFormFactory, EventDispatcherInterface $eventDispatcher, ResourceControllerEvent $event, Form $form, 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');
        $configuration->isHtmlRequest()->willReturn(false);
        $authorizationChecker->isGranted($configuration, 'sylius.product.update')->willReturn(true);
        $singleResourceProvider->get($configuration, $repository)->willReturn($resource);
        $resourceFormFactory->create($configuration, $resource)->willReturn($form);
        $request->isMethod('PATCH')->willReturn(false);
        $request->getMethod()->willReturn('PUT');
        $form->handleRequest($request)->willReturn($form);
        $form->isValid()->willReturn(true);
        $form->getData()->willReturn($resource);
        $eventDispatcher->dispatchPreEvent(ResourceActions::UPDATE, $configuration, $resource)->willReturn($event);
        $event->isStopped()->willReturn(true);
        $event->getMessage()->willReturn('Cannot update this channel.');
        $event->getErrorCode()->willReturn(500);
        $manager->flush()->shouldNotBeCalled();
        $eventDispatcher->dispatchPostEvent(Argument::any())->shouldNotBeCalled();
        $this->shouldThrow(new HttpException(500, 'Cannot update this channel.'))->during('updateAction', [$request]);
    }
ResourceControllerSpec