function it_increase_position_when_increase_position_action_called(CRUDElement $element, DoctrineDataIndexer $indexer, PositionableInterface $positionableEntity, ObjectManager $om, RouterInterface $router)
 {
     $indexer->getData(1)->willReturn($positionableEntity);
     $positionableEntity->increasePosition()->shouldBeCalled();
     $om->persist($positionableEntity)->shouldBeCalled();
     $om->flush()->shouldBeCalled();
     $router->generate('fsi_admin_crud_list', array('element' => 'slides'))->willReturn('sample-path');
     $response = $this->increasePositionAction($element, 1);
     $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\RedirectResponse');
     $response->getTargetUrl()->shouldReturn('sample-path');
 }
 function it_redirects_to_redirect_uri_parameter_after_operation(CRUDElement $element, DoctrineDataIndexer $indexer, \StdClass $category, Request $request, ParameterBag $query)
 {
     $query->get('redirect_uri')->willReturn('some_redirect_uri');
     $indexer->getData(1)->willReturn($category);
     $response = $this->moveUpAction($element, 1, $request);
     $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\RedirectResponse');
     $response->getTargetUrl()->shouldReturn('some_redirect_uri');
     $response = $this->moveDownAction($element, 1, $request);
     $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\RedirectResponse');
     $response->getTargetUrl()->shouldReturn('some_redirect_uri');
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function getValue($object)
 {
     if (!is_object($object)) {
         throw new \InvalidArgumentException('Column "gedmo_tree" must read value from object.');
     }
     $value = parent::getValue($object);
     $objectManager = $this->registry->getManager($this->getOption('em'));
     // Check if tree listener is registred.
     $treeListener = $this->getTreeListener($objectManager);
     // Get Tree strategy.
     $strategy = $this->getClassStrategy($objectManager, $treeListener, get_class($object));
     $this->validateStrategy($object, $strategy);
     $config = $treeListener->getConfiguration($objectManager, get_class($object));
     $doctrineDataIndexer = new DoctrineDataIndexer($this->registry, get_class($object));
     $propertyAccessor = PropertyAccess::createPropertyAccessor();
     $this->viewAttributes = array('id' => $doctrineDataIndexer->getIndex($object), 'root' => isset($config['root']) ? $propertyAccessor->getValue($object, $config['root']) : null, 'left' => isset($config['left']) ? $propertyAccessor->getValue($object, $config['left']) : null, 'right' => isset($config['right']) ? $propertyAccessor->getValue($object, $config['right']) : null, 'level' => isset($config['level']) ? $propertyAccessor->getValue($object, $config['level']) : null, 'children' => $this->getTreeRepository(get_class($object), $objectManager)->childCount($object));
     $parent = isset($config['parent']) ? $propertyAccessor->getValue($object, $config['parent']) : null;
     if (isset($parent)) {
         $this->viewAttributes['parent'] = $doctrineDataIndexer->getIndex($parent);
     }
     return $value;
 }
 public function testThirdLevelOfInheritanceFromMappedSuperClass()
 {
     $class = self::FIXTURES . 'Oak';
     $dataIndexer = new DoctrineDataIndexer($this->getManagerRegistry(), $class);
     $this->assertSame(self::FIXTURES . 'Tree', $dataIndexer->getClass());
 }