public function let(ActionFactory $actionFactory, ActionEventManager $eventManager, ManagerRegistry $managerRegistry, ManagerInterface $manager, RouterInterface $router, TranslatorInterface $translator, MassActionDispatcher $massActionDispatcher, JobInstanceRepository $jobInstanceRepository, JobLauncherInterface $jobLauncher, TokenStorageInterface $tokenStorage, Request $request, ParameterBag $attributes, ConfigurationInterface $configuration, Session $session, FlashBag $flashBag) { $this->beConstructedWith($actionFactory, $eventManager, $managerRegistry, $router, $translator, $massActionDispatcher, $jobInstanceRepository, $jobLauncher, $tokenStorage); // initialize configuration $configuration->getEntityClass()->willReturn('entity_class'); $configuration->getName()->willReturn('entity'); // initialize manager $managerRegistry->getFromConfiguration($configuration)->willReturn($manager); // initialize router $router->generate(Argument::type('string'), Argument::type('array'), Argument::any())->will(function ($arguments) { $path = $arguments[0] . '?'; foreach ($arguments[1] as $key => $value) { $path .= '&' . $key . '=' . $value; } return $path; }); // initialize request $request->attributes = $attributes; $attributes->get('id')->willReturn('id'); // initialize flashbag $request->getSession()->willReturn($session); $session->getFlashBag()->willReturn($flashBag); // initialize translator $translator->trans(Argument::type('string'), Argument::any())->will(function ($arguments) { if (!isset($arguments[1])) { $arguments[1] = array(); } $translated = sprintf('<%s>', $arguments[0]); foreach ($arguments[1] as $key => $value) { $translated .= sprintf('%s=%s;', $key, $value); } return $translated; }); }
public function let(ActionFactory $actionFactory, ActionEventManager $eventManager, ManagerRegistry $managerRegistry, ManagerInterface $manager, RouterInterface $router, TranslatorInterface $translator, ConfigurationInterface $configuration, Request $request, ParameterBag $attributes, EngineInterface $templating, FormFactoryInterface $formFactory, FormInterface $form, FormView $formView, Entity $object, ActionInterface $indexAction) { $this->beConstructedWith($actionFactory, $eventManager, $managerRegistry, $router, $translator, $templating, $formFactory); // initialize configuration $configuration->getEntityClass()->willReturn('entity_class'); $configuration->getName()->willReturn('entity'); // initialize manager $managerRegistry->getFromConfiguration($configuration)->willReturn($manager); // initialize router $router->generate(Argument::type('string'), Argument::type('array'), Argument::any())->will(function ($arguments) { $path = $arguments[0] . '?'; foreach ($arguments[1] as $key => $value) { $path .= '&' . $key . '=' . $value; } return $path; }); // initialize form $formFactory->create('form_type', $object, ['data_class' => 'entity_class'])->willReturn($form); $form->createView()->willReturn($formView); $form->getData()->willReturn($object); // initialize request $request->attributes = $attributes; $attributes->get('id')->willReturn('id'); // initialize configuration for form $actionFactory->getAction('entity', 'index')->willReturn($indexAction); $configuration->hasAction('index')->willReturn(true); $indexAction->getRoute()->willReturn('index'); $indexAction->getRouteParameters(null)->willReturn(['ir_param1' => 'value1']); }
/** * Returns the entity of the request * * @param Request $request * * @throws NotFoundHttpException * @return object */ protected function findEntity(Request $request) { $entity = $this->getManager()->find($this->configuration->getEntityClass(), $request->attributes->get('id'), $this->options['find_options']); if (!$entity) { throw new NotFoundHttpException(); } return $entity; }
public function let(ActionFactory $actionFactory, ActionEventManager $eventManager, ManagerRegistry $managerRegistry, ManagerInterface $manager, RouterInterface $router, TranslatorInterface $translator, ConfigurationInterface $configuration, EngineInterface $templating) { $this->beConstructedWith($actionFactory, $eventManager, $managerRegistry, $router, $translator, $templating); // initialize configuration $configuration->getEntityClass()->willReturn('entity_class'); $configuration->getName()->willReturn('entity'); $configuration->hasAction('index')->willReturn(true); // initialize manager $managerRegistry->getFromConfiguration($configuration)->willReturn($manager); // initialize router $router->generate(Argument::type('string'), Argument::type('array'), Argument::any())->will(function ($arguments) { $path = $arguments[0] . '?'; foreach ($arguments[1] as $key => $value) { $path .= '&' . $key . '=' . $value; } return $path; }); }
public function initializeConfiguration(ConfigurationInterface $configuration) { $configuration->getEntityClass()->willReturn('entity_class'); $configuration->getName()->willReturn('entity'); }