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

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

public it_does_not_delete_a_resource_and_redirects_to_index_for_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, Sylius\Bundle\ResourceBundle\Controller\SingleResourceProviderInterface $singleResourceProvider, Sylius\Component\Resource\Model\ResourceInterface $resource, Sylius\Bundle\ResourceBundle\Controller\RedirectHandlerInterface $redirectHandler, Sylius\Bundle\ResourceBundle\Controller\FlashHelperInterface $flashHelper, Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface $eventDispatcher, Symfony\Component\Security\Csrf\CsrfTokenManagerInterface $csrfTokenManager, Symfony\Component\DependencyInjection\ContainerInterface $container, Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent $event, Request $request, Response $redirectResponse )
$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
$singleResourceProvider Sylius\Bundle\ResourceBundle\Controller\SingleResourceProviderInterface
$resource Sylius\Component\Resource\Model\ResourceInterface
$redirectHandler Sylius\Bundle\ResourceBundle\Controller\RedirectHandlerInterface
$flashHelper Sylius\Bundle\ResourceBundle\Controller\FlashHelperInterface
$eventDispatcher Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface
$csrfTokenManager Symfony\Component\Security\Csrf\CsrfTokenManagerInterface
$container Symfony\Component\DependencyInjection\ContainerInterface
$event Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent
$request Symfony\Component\HttpFoundation\Request
$redirectResponse Symfony\Component\HttpFoundation\Response
    function it_does_not_delete_a_resource_and_redirects_to_index_for_html_requests_stopped_via_event(MetadataInterface $metadata, RequestConfigurationFactoryInterface $requestConfigurationFactory, RequestConfiguration $configuration, AuthorizationCheckerInterface $authorizationChecker, RepositoryInterface $repository, SingleResourceProviderInterface $singleResourceProvider, ResourceInterface $resource, RedirectHandlerInterface $redirectHandler, FlashHelperInterface $flashHelper, EventDispatcherInterface $eventDispatcher, CsrfTokenManagerInterface $csrfTokenManager, ContainerInterface $container, 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::DELETE)->willReturn('sylius.product.delete');
        $request->get('_csrf_token')->willReturn('xyz');
        $container->has('security.csrf.token_manager')->willReturn(true);
        $container->get('security.csrf.token_manager')->willReturn($csrfTokenManager);
        $csrfTokenManager->isTokenValid(new CsrfToken(1, 'xyz'))->willReturn(true);
        $authorizationChecker->isGranted($configuration, 'sylius.product.delete')->willReturn(true);
        $singleResourceProvider->get($configuration, $repository)->willReturn($resource);
        $resource->getId()->willReturn(1);
        $configuration->isHtmlRequest()->willReturn(true);
        $configuration->isCsrfProtectionEnabled()->willReturn(true);
        $eventDispatcher->dispatchPreEvent(ResourceActions::DELETE, $configuration, $resource)->willReturn($event);
        $event->isStopped()->willReturn(true);
        $repository->remove($resource)->shouldNotBeCalled();
        $eventDispatcher->dispatchPostEvent(ResourceActions::DELETE, $configuration, $resource)->shouldNotBeCalled();
        $flashHelper->addSuccessFlash($configuration, ResourceActions::DELETE, $resource)->shouldNotBeCalled();
        $flashHelper->addFlashFromEvent($configuration, $event)->shouldBeCalled();
        $redirectHandler->redirectToIndex($configuration, $resource)->willReturn($redirectResponse);
        $this->deleteAction($request)->shouldReturn($redirectResponse);
    }
ResourceControllerSpec