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

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

public it_redirects_to_newly_created_resource ( 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, Sylius\Component\Resource\Factory\FactoryInterface $factory, Sylius\Bundle\ResourceBundle\Controller\NewResourceFactoryInterface $newResourceFactory, Sylius\Component\Resource\Repository\RepositoryInterface $repository, Sylius\Component\Resource\Model\ResourceInterface $newResource, Sylius\Bundle\ResourceBundle\Controller\ResourceFormFactoryInterface $resourceFormFactory, Sylius\Bundle\ResourceBundle\Controller\StateMachineInterface $stateMachine, Form $form, Sylius\Bundle\ResourceBundle\Controller\RedirectHandlerInterface $redirectHandler, Sylius\Bundle\ResourceBundle\Controller\FlashHelperInterface $flashHelper, Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface $eventDispatcher, 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
$viewHandler Sylius\Bundle\ResourceBundle\Controller\ViewHandlerInterface
$factory Sylius\Component\Resource\Factory\FactoryInterface
$newResourceFactory Sylius\Bundle\ResourceBundle\Controller\NewResourceFactoryInterface
$repository Sylius\Component\Resource\Repository\RepositoryInterface
$newResource Sylius\Component\Resource\Model\ResourceInterface
$resourceFormFactory Sylius\Bundle\ResourceBundle\Controller\ResourceFormFactoryInterface
$stateMachine Sylius\Bundle\ResourceBundle\Controller\StateMachineInterface
$form Symfony\Component\Form\Form
$redirectHandler Sylius\Bundle\ResourceBundle\Controller\RedirectHandlerInterface
$flashHelper Sylius\Bundle\ResourceBundle\Controller\FlashHelperInterface
$eventDispatcher Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface
$event Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent
$request Symfony\Component\HttpFoundation\Request
$redirectResponse Symfony\Component\HttpFoundation\Response
    function it_redirects_to_newly_created_resource(MetadataInterface $metadata, RequestConfigurationFactoryInterface $requestConfigurationFactory, RequestConfiguration $configuration, AuthorizationCheckerInterface $authorizationChecker, ViewHandlerInterface $viewHandler, FactoryInterface $factory, NewResourceFactoryInterface $newResourceFactory, RepositoryInterface $repository, ResourceInterface $newResource, ResourceFormFactoryInterface $resourceFormFactory, StateMachineInterface $stateMachine, 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');
        $configuration->hasStateMachine()->willReturn(true);
        $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(false);
        $stateMachine->apply($configuration, $newResource)->shouldBeCalled();
        $repository->add($newResource)->shouldBeCalled();
        $eventDispatcher->dispatchPostEvent(ResourceActions::CREATE, $configuration, $newResource)->shouldBeCalled();
        $flashHelper->addSuccessFlash($configuration, ResourceActions::CREATE, $newResource)->shouldBeCalled();
        $redirectHandler->redirectToResource($configuration, $newResource)->willReturn($redirectResponse);
        $this->createAction($request)->shouldReturn($redirectResponse);
    }
ResourceControllerSpec