public function setUp() { $this->query = $this->getMock('Sonata\\AdminBundle\\Datagrid\\ProxyQueryInterface'); $this->columns = new FieldDescriptionCollection(); $this->pager = $this->getMock('Sonata\\AdminBundle\\Datagrid\\PagerInterface'); $this->formTypes = array(); // php 5.3 BC $formTypes =& $this->formTypes; $this->formBuilder = $this->getMockBuilder('Symfony\\Component\\Form\\FormBuilder')->disableOriginalConstructor()->getMock(); $this->formBuilder->expects($this->any())->method('get')->will($this->returnCallback(function ($name) use(&$formTypes) { if (isset($formTypes[$name])) { return $formTypes[$name]; } return; })); // php 5.3 BC $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface'); $this->formBuilder->expects($this->any())->method('add')->will($this->returnCallback(function ($name, $type, $options) use(&$formTypes, $eventDispatcher, $formFactory) { $formTypes[$name] = new FormBuilder($name, 'Sonata\\AdminBundle\\Tests\\Fixtures\\Entity\\Form\\TestEntity', $eventDispatcher, $formFactory, $options); return; })); // php 5.3 BC $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock(); $this->formBuilder->expects($this->any())->method('getForm')->will($this->returnCallback(function () use($form) { return $form; })); $values = array(); $this->datagrid = new Datagrid($this->query, $this->columns, $this->pager, $this->formBuilder, $values); }
public function testBuildForm() { $fields = []; $this->builder->expects($this->exactly(4))->method('add')->will($this->returnCallback(function ($filedName, $fieldType) use(&$fields) { $fields[$filedName] = $fieldType; })); $this->type->buildForm($this->builder, []); $this->assertSame(['name' => 'text', 'entities' => 'orocrm_channel_entities', 'channelType' => 'genemu_jqueryselect2_choice', 'status' => 'choice'], $fields); }
public function testBuildForm() { $test = $this; $this->reg->expects($this->once())->method('getManager')->with(null)->will($this->returnValue($this->dm)); $this->builder->expects($this->once())->method('addModelTransformer')->will($this->returnCallback(function ($transformer) use($test) { $test->assertInstanceOf('Doctrine\\Bundle\\PHPCRBundle\\Form\\DataTransformer\\DocumentToPathTransformer', $transformer); return; })); $this->type->buildForm($this->builder, array('manager_name' => null)); }
public function testBuildForm() { $this->builder->expects($this->at(0))->method('addEventSubscriber')->with($this->isInstanceOf('Oro\\Bundle\\IntegrationBundle\\Form\\EventListener\\ChannelFormSubscriber')); $this->builder->expects($this->at(1))->method('addEventSubscriber')->with($this->isInstanceOf('Oro\\Bundle\\IntegrationBundle\\Form\\EventListener\\DefaultOwnerSubscriber')); $this->type->buildForm($this->builder, []); }