public function testObjectRemoval(ManagerInterface $manager, ActionEventManager $eventManager, ConfigurationInterface $configuration, Request $request, $options, $findOptions)
 {
     $object = new \stdClass();
     $configuration->getActionOptions('delete')->willReturn($options);
     $this->setConfiguration($configuration);
     $manager->find('entity_class', 'id', $findOptions)->willReturn($object);
     $manager->remove($object)->shouldBeCalled();
     $this->initializeEventManager($eventManager);
     $response = $this->execute($request, $configuration);
     $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\Response');
     $response->getStatusCode()->shouldReturn(204);
 }
 public function it_displays_forms(ManagerInterface $manager, ActionEventManager $eventManager, ConfigurationInterface $configuration, Request $request, Entity $object, EngineInterface $templating, FormView $formView, Response $response)
 {
     $request->isMethod('post')->willReturn(false);
     $manager->find('entity_class', 'id', [])->willReturn($object);
     $object->getId()->willReturn('id');
     $configuration->getActionOptions('edit')->willReturn(['form_type' => 'form_type']);
     $configuration->hasAction('delete')->willReturn(false);
     $templating->renderResponse('PimCustomEntityBundle:CustomEntity:form.html.twig', ['form' => $formView, 'formAction' => 'pim_customentity_edit?&customEntityName=entity&id=id', 'customEntityName' => 'entity', 'baseTemplate' => 'PimCustomEntityBundle::layout.html.twig', 'indexUrl' => 'index?&ir_param1=value1', 'pre_render' => true])->willReturn($response);
     $this->initializeEventManager($eventManager);
     $this->setConfiguration($configuration);
     $this->execute($request)->shouldReturn($response);
 }
 public function it_accepts_redirection_options(ManagerInterface $manager, ActionEventManager $eventManager, ConfigurationInterface $configuration, Request $request, Entity $object, FormFactoryInterface $formFactory, FormInterface $form, FlashBagInterface $flashBag)
 {
     $request->isMethod('post')->willReturn(true);
     $form->submit($request)->shouldBeCalled();
     $form->isValid()->willReturn(true);
     $manager->create('entity_class', [], [])->willReturn($object);
     $manager->save($object, [])->shouldBeCalled();
     $object->getId()->willReturn(null);
     $formFactory->create('form_type', $object, ['f_param1' => 'value1', 'data_class' => 'entity_class'])->shouldBeCalled()->willReturn($form);
     $configuration->getActionOptions('create')->willReturn(['form_type' => 'form_type', 'form_options' => ['f_param1' => 'value1'], 'redirect_route' => 'redirect_route', 'redirect_route_parameters' => ['c_r_param1' => 'value1'], 'success_message' => 'success_message']);
     $configuration->hasAction('delete')->willReturn(false);
     $flashBag->add('success', '<success_message>')->shouldBeCalled();
     $this->initializeEventManager($eventManager);
     $this->setConfiguration($configuration);
     $response = $this->execute($request);
     $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\RedirectResponse');
     $response->getTargetUrl()->shouldReturn('redirect_route?&c_r_param1=value1');
 }