function it_does_not_create_the_resource_and_redirects_to_index_for_html_requests_stopped_via_events(MetadataInterface $metadata, RequestConfigurationFactoryInterface $requestConfigurationFactory, RequestConfiguration $configuration, AuthorizationCheckerInterface $authorizationChecker, ViewHandlerInterface $viewHandler, FactoryInterface $factory, NewResourceFactoryInterface $newResourceFactory, RepositoryInterface $repository, ResourceInterface $newResource, ResourceFormFactoryInterface $resourceFormFactory, Form $form, RedirectHandlerInterface $redirectHandler, FlashHelperInterface $flashHelper, EventDispatcherInterface $eventDispatcher, ResourceControllerEvent $event, Request $request, Response $redirectResponse)
{
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');
$requestConfigurationFactory->create($metadata, $request)->willReturn($configuration);
$configuration->hasPermission()->willReturn(true);
$configuration->getPermission(ResourceActions::CREATE)->willReturn('sylius.product.create');
$authorizationChecker->isGranted($configuration, 'sylius.product.create')->willReturn(true);
$configuration->isHtmlRequest()->willReturn(true);
$configuration->getTemplate(ResourceActions::CREATE . '.html')->willReturn('SyliusShopBundle:Product:create.html.twig');
$newResourceFactory->create($configuration, $factory)->willReturn($newResource);
$resourceFormFactory->create($configuration, $newResource)->willReturn($form);
$request->isMethod('POST')->willReturn(true);
$form->handleRequest($request)->willReturn($form);
$form->isValid()->willReturn(true);
$form->getData()->willReturn($newResource);
$eventDispatcher->dispatchPreEvent(ResourceActions::CREATE, $configuration, $newResource)->willReturn($event);
$event->isStopped()->willReturn(true);
$flashHelper->addFlashFromEvent($configuration, $event)->shouldBeCalled();
$repository->add($newResource)->shouldNotBeCalled();
$eventDispatcher->dispatchPostEvent(ResourceActions::CREATE, $configuration, $newResource)->shouldNotBeCalled();
$flashHelper->addSuccessFlash(Argument::any())->shouldNotBeCalled();
$redirectHandler->redirectToIndex($configuration, $newResource)->willReturn($redirectResponse);
$this->createAction($request)->shouldReturn($redirectResponse);
}