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

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

public it_returns_a_non_html_response_for_correctly_created_resources ( 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\FlashHelperInterface $flashHelper, Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface $eventDispatcher, Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent $event, Sylius\Bundle\ResourceBundle\Controller\StateMachineInterface $stateMachine, Form $form, Request $request, Response $response )
$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
$flashHelper Sylius\Bundle\ResourceBundle\Controller\FlashHelperInterface
$eventDispatcher Sylius\Bundle\ResourceBundle\Controller\EventDispatcherInterface
$event Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent
$stateMachine Sylius\Bundle\ResourceBundle\Controller\StateMachineInterface
$form Symfony\Component\Form\Form
$request Symfony\Component\HttpFoundation\Request
$response Symfony\Component\HttpFoundation\Response
    function it_returns_a_non_html_response_for_correctly_created_resources(MetadataInterface $metadata, RequestConfigurationFactoryInterface $requestConfigurationFactory, RequestConfiguration $configuration, AuthorizationCheckerInterface $authorizationChecker, ViewHandlerInterface $viewHandler, FactoryInterface $factory, NewResourceFactoryInterface $newResourceFactory, RepositoryInterface $repository, ResourceInterface $newResource, ResourceFormFactoryInterface $resourceFormFactory, FlashHelperInterface $flashHelper, EventDispatcherInterface $eventDispatcher, ResourceControllerEvent $event, StateMachineInterface $stateMachine, Form $form, Request $request, Response $response)
    {
        $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(false);
        $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(Argument::any())->shouldNotBeCalled();
        $expectedView = View::create($newResource, 201);
        $viewHandler->handle($configuration, Argument::that($this->getViewComparingCallback($expectedView)))->willReturn($response);
        $this->createAction($request)->shouldReturn($response);
    }
ResourceControllerSpec