本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::expects方法的具体用法?PHP FormBuilder::expects怎么用?PHP FormBuilder::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::expects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
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);
}
示例2: testBuildForm
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);
}
示例3: testBuildForm
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));
}
示例4: testBuildForm
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, []);
}