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]);
}