当前位置: 首页>>代码示例>>PHP>>正文


PHP FormFactoryInterface::expects方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\FormFactoryInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP FormFactoryInterface::expects方法的具体用法?PHP FormFactoryInterface::expects怎么用?PHP FormFactoryInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\FormFactoryInterface的用法示例。


在下文中一共展示了FormFactoryInterface::expects方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->factory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
     $this->builder = new TestFormBuilder('name', null, $this->dispatcher, $this->factory);
     $this->factory->expects($this->any())->method('createNamedBuilder')->willReturn($this->builder);
 }
开发者ID:drmjo,项目名称:SonataAdminBundle,代码行数:7,代码来源:FormBuilderIteratorTest.php

示例2: initializeMocks

 /**
  * @param bool  $expectedSubmit
  * @param mixed $expectedException
  */
 private function initializeMocks($expectedSubmit, $expectedException)
 {
     if ($expectedSubmit) {
         $formMock = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface');
         $data = null;
         $this->formFactory->expects($this->once())->method('create')->with($this->equalTo('oro_integration_channel_form'), $this->isInstanceOf('Oro\\Bundle\\IntegrationBundle\\Entity\\Channel'), $this->equalTo(['csrf_protection' => false, 'disable_customer_datasource_types' => false]))->will($this->returnCallback(function ($type, $formData) use(&$data, $formMock) {
             // capture form data
             $data = $formData;
             return $formMock;
         }));
         $formMock->expects($this->once())->method('submit')->will($this->returnCallback(function ($submitted) use(&$data) {
             // emulate submit
             $accessor = PropertyAccess::createPropertyAccessor();
             foreach ($submitted as $key => $value) {
                 $accessor->setValue($data, $key, $value);
             }
         }));
         $invalid = null != $expectedException;
         $formMock->expects($this->once())->method('isValid')->will($this->returnValue(!$invalid));
         if ($invalid) {
             $formMock->expects($this->once())->method('getErrors')->will($this->returnValue([new FormError('message')]));
         }
     } else {
         $this->formFactory->expects($this->never())->method('create');
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:30,代码来源:DatasourceDataTransformerTest.php

示例3: setUp

 public function setUp()
 {
     $this->form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface');
     $this->formBuilder = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
     $this->formBuilder->expects($this->any())->method('createNamed')->will($this->returnValue($this->form));
     $this->request = Request::create('');
     $this->entity = new Integration();
     $this->handler = new ChannelIntegrationHandler($this->request, $this->formBuilder);
 }
开发者ID:dairdr,项目名称:crm,代码行数:9,代码来源:ChannelIntegrationHandlerTest.php

示例4: setUp

 public function setUp()
 {
     $this->form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface');
     $this->formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
     $this->formFactory->expects($this->any())->method('create')->will($this->returnValue($this->form));
     $this->filterUtility = $this->getMockBuilder('Oro\\Bundle\\FilterBundle\\Filter\\FilterUtility')->disableOriginalConstructor()->getMock();
     $this->filterUtility->expects($this->any())->method('getExcludeParams')->willReturn([]);
     $this->formatter = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Formatter\\ProductUnitLabelFormatter')->disableOriginalConstructor()->getMock();
     $this->productPriceFilter = new ProductPriceFilter($this->formFactory, $this->filterUtility, $this->formatter);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:10,代码来源:ProductPriceFilterTest.php

示例5: testRender

 public function testRender()
 {
     $this->urlGenerator->expects($this->once())->method('generate')->with($this->identicalTo($route = 'route_value'), $this->identicalTo([$routeParameter = 'route_parameter' => $routeParameterValue = 'route_parameter_value']), $this->identicalTo($routeReferenceType = UrlGeneratorInterface::ABSOLUTE_PATH))->will($this->returnValue($url = 'url_value'));
     $this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($routeParameter))->will($this->returnValue($routeParameterValue));
     $action = $this->createActionMock();
     $action->expects($this->once())->method('getLabel')->will($this->returnValue($actionLabel = 'action_label'));
     $action->expects($this->once())->method('getOption')->with($this->identicalTo('trans_domain'))->will($this->returnValue($actionTransDomain = 'action_trans_domain'));
     $this->formFactory->expects($this->once())->method('create')->with($this->identicalTo(CsrfProtectionType::class), $this->isNull(), $this->identicalTo(['method' => $method = Request::METHOD_DELETE, 'action' => $url, 'label' => $actionLabel, 'translation_domain' => $actionTransDomain]))->will($this->returnValue($form = $this->createFormMock()));
     $form->expects($this->once())->method('createView')->will($this->returnValue($view = $this->createFormViewMock()));
     $this->assertSame($view, $this->type->render($data, ['action' => $action, 'method' => strtolower($method), 'route' => $route, 'route_parameters' => [$routeParameter], 'route_reference_type' => $routeReferenceType]));
 }
开发者ID:php-lug,项目名称:lug,代码行数:11,代码来源:LinkSecureTypeTest.php

示例6: configureFormMock

 /**
  * @param bool $isFieldForm
  */
 protected function configureFormMock($isFieldForm)
 {
     $this->containerMock->expects($this->at(1))->method('get')->with('form.factory')->willReturn($this->formFactoryMock);
     $formMock = $this->getMock('Symfony\\Component\\Form\\FormInterface');
     $invocationMocker = $this->formFactoryMock->expects($this->once())->method('createNamed')->willReturn($formMock);
     if ($isFieldForm) {
         $invocationMocker->with('', 'guess_field_type', null, ['data_class' => 'Test\\Entity', 'field_name' => 'someField', 'dynamic_fields_disabled' => true, 'ownership_disabled' => true]);
     } else {
         $invocationMocker->with('mass_edit_field', 'update_field_choice', null, ['entity' => 'Test\\Entity', 'with_relations' => true]);
     }
     $formMock->expects($this->once())->method('createView')->willReturn($this->getMock('Symfony\\Component\\Form\\FormView'));
 }
开发者ID:trustify,项目名称:oroplatform-mass-update-bundle,代码行数:15,代码来源:MassUpdateControllerTest.php

示例7: testProcessValidDataWithResponse

 public function testProcessValidDataWithResponse()
 {
     $request = Request::create('/post/valid-with-response', 'POST');
     $request->request->set(QuickAddType::NAME, [QuickAddType::COMPONENT_FIELD_NAME => self::COMPONENT_NAME]);
     $response = new RedirectResponse('/processor-redirect');
     $products = [['sku' => '111', 'qty' => 123], ['sku' => '222', 'qty' => 234]];
     $productsForm = $this->getMock('Symfony\\Component\\Form\\FormInterface');
     $productsForm->expects($this->once())->method('getData')->willReturn($products);
     $form = $this->getMock('Symfony\\Component\\Form\\FormInterface');
     $form->expects($this->once())->method('submit')->with($request);
     $form->expects($this->once())->method('isValid')->willReturn(true);
     $form->expects($this->once())->method('get')->with(QuickAddType::PRODUCTS_FIELD_NAME)->willReturn($productsForm);
     $this->formFactory->expects($this->once())->method('create')->with(QuickAddType::NAME, null, ['validation_required' => true])->willReturn($form);
     $processor = $this->getProcessor();
     $processor->expects($this->once())->method('process')->with([ProductDataStorage::ENTITY_ITEMS_DATA_KEY => $products], $request)->willReturn($response);
     $this->assertEquals(['form' => $form, 'response' => $response], $this->handler->process($request));
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:17,代码来源:QuickAddHandlerTest.php

示例8: testPreSubmitData

 public function testPreSubmitData()
 {
     $eventMock = $this->getMockBuilder('Symfony\\Component\\Form\\FormEvent')->disableOriginalConstructor()->getMock();
     $countryMock = $this->getMockBuilder('Oro\\Bundle\\AddressBundle\\Entity\\Country')->disableOriginalConstructor()->getMock();
     $countryMock->expects($this->once())->method('hasRegions')->will($this->returnValue(true));
     $repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $repository->expects($this->any())->method('find')->with(self::TEST_COUNTRY_NAME)->will($this->returnValue($countryMock));
     $this->om->expects($this->once())->method('getRepository')->with($this->equalTo('OroAddressBundle:Country'))->will($this->returnValue($repository));
     $configMock = $this->getMock('Symfony\\Component\\Form\\FormConfigInterface');
     $configMock->expects($this->once())->method('getOptions')->will($this->returnValue(array()));
     $fieldMock = $this->getMockBuilder('Symfony\\Component\\Form\\Test\\FormInterface')->disableOriginalConstructor()->getMock();
     $fieldMock->expects($this->once())->method('getConfig')->will($this->returnValue($configMock));
     $formMock = $this->getMockBuilder('Symfony\\Component\\Form\\Test\\FormInterface')->disableOriginalConstructor()->getMock();
     $formMock->expects($this->once())->method('get')->with($this->equalTo('region'))->will($this->returnValue($fieldMock));
     $formMock->expects($this->once())->method('add');
     $newFieldMock = $this->getMockBuilder('Symfony\\Component\\Form\\Test\\FormInterface')->disableOriginalConstructor()->getMock();
     $this->formBuilder->expects($this->once())->method('createNamed')->will($this->returnValue($newFieldMock));
     $startData = array('region_text' => 'regionText', 'country' => self::TEST_COUNTRY_NAME);
     $eventMock->expects($this->once())->method('getData')->will($this->returnValue($startData));
     $eventMock->expects($this->once())->method('getForm')->will($this->returnValue($formMock));
     $eventMock->expects($this->once())->method('setData')->with(array_intersect_key($startData, array('country' => self::TEST_COUNTRY_NAME)));
     $this->subscriber->preSubmit($eventMock);
 }
开发者ID:Maksold,项目名称:platform,代码行数:23,代码来源:AddressCountryAndRegionSubscriberTest.php

示例9: testCreateWithApi

 public function testCreateWithApi()
 {
     $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(true));
     $this->symfonyFormFactory->expects($this->once())->method('create')->with($this->identicalTo($type = 'type'), $this->identicalTo($data = 'data'), $this->identicalTo(array_merge($options = ['option'], ['csrf_protection' => false])))->will($this->returnValue($form = 'form'));
     $this->assertSame($form, $this->formFactory->create($type, $data, $options));
 }
开发者ID:php-lug,项目名称:lug,代码行数:6,代码来源:FormFactoryTest.php


注:本文中的Symfony\Component\Form\FormFactoryInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。