private function createForm($name) { $builder = new FormBuilder($name, null, $this->dispatcher, $this->factory); $builder->setCompound(true); $builder->setDataMapper($this->dataMapper); return $builder->getForm(); }
/** * tests only so far that actual value/object is retrieved. * * @expectedException Exception * @expectedExceptionCode 0 * @expectedExceptionMessage unknown collection class */ public function testAppendFormFieldElementNested() { $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $pool = new Pool($container, 'title', 'logo.png'); $helper = new AdminHelper($pool); $admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface'); $object = $this->getMock('stdClass', array('getSubObject')); $simpleObject = $this->getMock('stdClass', array('getSubObject')); $subObject = $this->getMock('stdClass', array('getAnd')); $sub2Object = $this->getMock('stdClass', array('getMore')); $sub3Object = $this->getMock('stdClass', array('getFinalData')); $dataMapper = $this->getMock('Symfony\\Component\\Form\\DataMapperInterface'); $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface'); $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $formBuilder = new FormBuilder('test', get_class($simpleObject), $eventDispatcher, $formFactory); $childFormBuilder = new FormBuilder('subObject', get_class($subObject), $eventDispatcher, $formFactory); $object->expects($this->atLeastOnce())->method('getSubObject')->will($this->returnValue(array($subObject))); $subObject->expects($this->atLeastOnce())->method('getAnd')->will($this->returnValue($sub2Object)); $sub2Object->expects($this->atLeastOnce())->method('getMore')->will($this->returnValue(array($sub3Object))); $sub3Object->expects($this->atLeastOnce())->method('getFinalData')->will($this->returnValue('value')); $formBuilder->setCompound(true); $formBuilder->setDataMapper($dataMapper); $formBuilder->add($childFormBuilder); $admin->expects($this->once())->method('getFormBuilder')->will($this->returnValue($formBuilder)); $admin->expects($this->once())->method('getSubject')->will($this->returnValue($object)); $helper->appendFormFieldElement($admin, $simpleObject, 'uniquePartOfId_sub_object_0_and_more_0_final_data'); }