public function testAddNewInstanceInflector()
 {
     $admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin->expects($this->once())->method('getNewInstance')->will($this->returnValue(new \stdClass()));
     $fieldDescription = $this->getMock('Sonata\\AdminBundle\\Admin\\FieldDescriptionInterface');
     $fieldDescription->expects($this->once())->method('getAssociationAdmin')->will($this->returnValue($admin));
     $fieldDescription->expects($this->once())->method('getAssociationMapping')->will($this->returnValue(array('fieldName' => 'entries')));
     $object = $this->getMock('sdtClass', array('addEntry'));
     $object->expects($this->once())->method('addEntry');
     $this->helper->addNewInstance($object, $fieldDescription);
 }
Exemplo n.º 2
0
 public function testaddNewInstance()
 {
     $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');
     $admin->expects($this->once())->method('getNewInstance')->will($this->returnValue(new \stdClass()));
     $fieldDescription = $this->getMock('Sonata\\AdminBundle\\Admin\\FieldDescriptionInterface');
     $fieldDescription->expects($this->once())->method('getAssociationAdmin')->will($this->returnValue($admin));
     $fieldDescription->expects($this->once())->method('getAssociationMapping')->will($this->returnValue(array('fieldName' => 'fooBar')));
     $object = $this->getMock('sdtClass', array('addFooBar'));
     $object->expects($this->once())->method('addFooBar');
     $helper->addNewInstance($object, $fieldDescription);
 }
Exemplo n.º 3
0
 public function testAddNewInstance()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $pool = new Pool($container, 'title', 'logo.png');
     $helper = new AdminHelper($pool);
     $mockFormView = $this->getMockBuilder('Symfony\\Component\\Form\\FormView')->disableOriginalConstructor()->getMock();
     $mockForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $mockForm->expects($this->any())->method('createView')->will($this->returnValue($mockFormView));
     $mockFormBuilder = $this->getMockBuilder('Symfony\\Component\\Form\\FormBuilder')->disableOriginalConstructor()->getMock();
     $mockFormBuilder->expects($this->any())->method('getForm')->will($this->returnValue($mockForm));
     $collection = $this->getMock('Doctrine\\ORM\\ArrayCollection');
     $collection->expects($this->any())->method('add');
     $entity = new \stdClass();
     $entity->foo = $collection;
     $admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin->expects($this->any())->method('getNewInstance')->will($this->returnValue(new \stdClass()));
     $admin->expects($this->any())->method('getFormBuilder')->will($this->returnValue($mockFormBuilder));
     $admin->expects($this->any())->method('getSubject')->will($this->returnValue($entity));
     $elementId = 'foo';
     $helper->addNewInstance($admin, $elementId);
 }