當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormInterface::expects方法代碼示例

本文整理匯總了PHP中Symfony\Component\Form\FormInterface::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormInterface::expects方法的具體用法?PHP FormInterface::expects怎麽用?PHP FormInterface::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Form\FormInterface的用法示例。


在下文中一共展示了FormInterface::expects方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testProcessInvalid

 public function testProcessInvalid()
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(false));
     $this->assertFalse($this->handler->process($this->entity));
 }
開發者ID:hafeez3000,項目名稱:orocommerce,代碼行數:7,代碼來源:CustomerGroupHandlerTest.php

示例2: testEventDispatching

 /**
  * @dataProvider eventDataProvider
  *
  * @param Integration      $entity
  * @param null|User        $newOwner
  * @param Integration|null $oldIntegration
  * @param bool             $expectOwnerSetEvent
  * @param bool             $expectIntegrationUpdateEvent
  */
 public function testEventDispatching($entity, $newOwner, $oldIntegration, $expectOwnerSetEvent, $expectIntegrationUpdateEvent)
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($entity)->will($this->returnCallback(function ($entity) use($newOwner) {
         $entity->setDefaultUserOwner($newOwner);
     }));
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->em->expects($this->once())->method('persist')->with($entity);
     $this->em->expects($this->once())->method('flush');
     if ($entity->getId()) {
         $this->em->expects($this->once())->method('find')->with('OroIntegrationBundle:Channel', $entity->getId())->will($this->returnValue($oldIntegration));
     }
     $dispatchCallIndex = 0;
     if ($expectOwnerSetEvent) {
         $this->eventDispatcher->expects($this->at($dispatchCallIndex++))->method('dispatch')->with($this->equalTo(DefaultOwnerSetEvent::NAME), $this->isInstanceOf('Oro\\Bundle\\IntegrationBundle\\Event\\DefaultOwnerSetEvent'));
     }
     if ($expectIntegrationUpdateEvent) {
         $this->eventDispatcher->expects($this->at($dispatchCallIndex++))->method('dispatch')->with($this->equalTo(IntegrationUpdateEvent::NAME), $this->callback(function ($event) use($entity, $oldIntegration) {
             $this->assertInstanceOf('Oro\\Bundle\\IntegrationBundle\\Event\\IntegrationUpdateEvent', $event);
             $this->assertSame($entity, $event->getIntegration());
             $this->assertEquals($oldIntegration, $event->getOldState());
             return true;
         }));
     } elseif (!$expectOwnerSetEvent) {
         $this->eventDispatcher->expects($this->never())->method('dispatch');
     }
     $this->assertTrue($this->handler->process($entity));
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:38,代碼來源:IntegrationHandlerTest.php

示例3: testCreateUserFormDataValidWillReturn201Response

 public function testCreateUserFormDataValidWillReturn201Response()
 {
     $this->formMock->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->useCaseMock->expects($this->once())->method('editPhoneNumber')->with($this->number, false);
     $view = $this->controller->editPhoneNumberAction($this->number, $this->createExampleRequest());
     $this->assertEquals(new View($this->number, 200), $view);
 }
開發者ID:Nakard,項目名稱:hexagonal_phonebook,代碼行數:7,代碼來源:EditPhoneNumberControllerTest.php

示例4: testProcessSupportedRequest

 /**
  * @dataProvider supportedMethods
  *
  * @param string $method
  */
 public function testProcessSupportedRequest($method)
 {
     $this->request->setMethod($method);
     $this->form->expects($this->any())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->assertTrue($this->handler->process($this->entity));
 }
開發者ID:antrampa,項目名稱:crm,代碼行數:13,代碼來源:B2bCustomerHandlerTest.php

示例5: testCreateUserFormDataValidWillReturn200Response

 public function testCreateUserFormDataValidWillReturn200Response()
 {
     $request = $this->createExampleRequest();
     $user = $this->createExampleUser();
     $this->formMock->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $view = $this->controller->editUserAction($user, $request);
     $this->assertInstanceOf(User::class, $view->getData());
     $this->assertSame(200, $view->getStatusCode());
 }
開發者ID:Nakard,項目名稱:hexagonal_phonebook,代碼行數:9,代碼來源:EditUserControllerTest.php

示例6: testProcessWithoutContactViewPermission

 public function testProcessWithoutContactViewPermission()
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->form->expects($this->never())->method('get');
     $this->assertTrue($this->handler->process($this->entity));
 }
開發者ID:mehulsbhatt,項目名稱:crm,代碼行數:9,代碼來源:AccountHandlerTest.php

示例7: testCreateUserFormDataValidWillReturn201Response

 public function testCreateUserFormDataValidWillReturn201Response()
 {
     $request = $this->createExampleRequest();
     $this->formMock->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->routerMock->expects($this->once())->method('generate')->will($this->returnValue('http://example.com'));
     $view = $this->controller->createUserAction($request);
     $this->assertInstanceOf(User::class, $view->getData());
     $this->assertSame(201, $view->getStatusCode());
     $this->assertSame(['http://example.com'], $view->getHeaders()['location']);
 }
開發者ID:Nakard,項目名稱:hexagonal_phonebook,代碼行數:10,代碼來源:CreateUserControllerTest.php

示例8: testProcessValidData

 public function testProcessValidData()
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->manager->expects($this->once())->method('persist')->with($this->entity);
     $this->manager->expects($this->once())->method('flush');
     $this->assertTrue($this->handler->process($this->entity));
 }
開發者ID:dairdr,項目名稱:crm,代碼行數:10,代碼來源:CallHandlerTest.php

示例9: testProcessValidPost

 public function testProcessValidPost()
 {
     $offerData = ['offer', 'data'];
     $quote = new Quote();
     $order = new Order();
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->willReturn(true);
     $this->form->expects($this->once())->method('getData')->willReturn($offerData);
     $this->converter->expects($this->once())->method('convert')->with($quote, $this->accountUser, $offerData)->willReturn($order);
     $this->manager->expects($this->once())->method('persist')->with($order);
     $this->manager->expects($this->once())->method('flush');
     $this->assertEquals($order, $this->handler->process($quote));
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:14,代碼來源:QuoteToOrderHandlerTest.php

示例10: testProcessValidData

 public function testProcessValidData()
 {
     $subtotal = new Subtotal();
     $amount = 42;
     $subtotal->setType(Subtotal::TYPE_SUBTOTAL);
     $subtotal->setAmount($amount);
     $subtotals = new ArrayCollection([$subtotal]);
     $this->subtotalsProvider->expects($this->any())->method('getSubtotals')->willReturn($subtotals);
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->manager->expects($this->once())->method('persist')->with($this->entity);
     $this->manager->expects($this->once())->method('flush');
     $this->assertTrue($this->handler->process($this->entity));
     $propertyAccessor = PropertyAccess::createPropertyAccessor();
     foreach ($subtotals as $subtotal) {
         $this->assertEquals($amount, $propertyAccessor->getValue($this->entity, $subtotal->getType()));
     }
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:19,代碼來源:OrderHandlerTest.php

示例11: testHandleRequestChannelType

 /**
  * @param Channel $entity
  * @param mixed $requestValue
  * @param string $expectedType
  *
  * @dataProvider handleRequestDataProvider
  */
 public function testHandleRequestChannelType(Channel $entity, $requestValue, $expectedType)
 {
     $this->request->setMethod('GET');
     $expectedEntity = clone $entity;
     $expectedEntity->setChannelType($expectedType);
     $this->form->expects($this->once())->method('setData')->with($expectedEntity);
     $this->form->expects($this->never())->method('submit');
     $this->dispatcher->expects($this->never())->method('dispatch');
     $this->request->request->set('orocrm_channel_form', ['channelType' => $requestValue]);
     $this->handler->process($entity);
 }
開發者ID:antrampa,項目名稱:crm,代碼行數:18,代碼來源:ChannelHandlerTest.php

示例12: testProcessValidData

 /**
  * {@inheritdoc}
  */
 public function testProcessValidData()
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->at(2))->method('get')->with('passwordGenerate')->will($this->returnValue($this->passwordGenerateForm));
     $this->form->expects($this->at(3))->method('get')->with('sendEmail')->will($this->returnValue($this->sendEmailForm));
     $this->passwordGenerateForm->expects($this->once())->method('getData')->will($this->returnValue(true));
     $this->sendEmailForm->expects($this->once())->method('getData')->will($this->returnValue(true));
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->assertTrue($this->handler->process($this->entity));
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:14,代碼來源:AccountUserHandlerTest.php

示例13: testProcessValidData

 /**
  * @dataProvider processValidDataProvider
  *
  * @param bool $isDataChanged
  */
 public function testProcessValidData($isDataChanged)
 {
     $appendedAccount = new Account();
     $appendedAccount->setId(1);
     $removedAccount = new Account();
     $removedAccount->setId(2);
     $this->entity->addAccount($removedAccount);
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $appendForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $appendForm->expects($this->once())->method('getData')->will($this->returnValue(array($appendedAccount)));
     $this->form->expects($this->at(3))->method('get')->with('appendAccounts')->will($this->returnValue($appendForm));
     $removeForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $removeForm->expects($this->once())->method('getData')->will($this->returnValue(array($removedAccount)));
     $this->form->expects($this->at(4))->method('get')->with('removeAccounts')->will($this->returnValue($removeForm));
     if ($isDataChanged) {
         $this->manager->expects($this->once())->method('persist')->with($this->entity);
     } else {
         $this->manager->expects($this->exactly(2))->method('persist')->with($this->entity);
     }
     $this->manager->expects($this->once())->method('flush');
     $this->configureUnitOfWork($isDataChanged);
     $this->assertTrue($this->handler->process($this->entity));
     $actualAccounts = $this->entity->getAccounts()->toArray();
     $this->assertCount(1, $actualAccounts);
     $this->assertEquals($appendedAccount, current($actualAccounts));
 }
開發者ID:antrampa,項目名稱:crm,代碼行數:34,代碼來源:ContactHandlerTest.php

示例14: testProcessValidData

 public function testProcessValidData()
 {
     $appendedUser = new User();
     $appendedUser->setId(1);
     $removedUser = new User();
     $removedUser->setId(2);
     $removedUser->addBusinessUnit($this->entity);
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $appendForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $appendForm->expects($this->once())->method('getData')->will($this->returnValue(array($appendedUser)));
     $this->form->expects($this->at(3))->method('get')->with('appendUsers')->will($this->returnValue($appendForm));
     $removeForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $removeForm->expects($this->once())->method('getData')->will($this->returnValue(array($removedUser)));
     $this->form->expects($this->at(4))->method('get')->with('removeUsers')->will($this->returnValue($removeForm));
     $this->manager->expects($this->at(0))->method('persist')->with($appendedUser);
     $this->manager->expects($this->at(1))->method('persist')->with($removedUser);
     $this->manager->expects($this->at(2))->method('persist')->with($this->entity);
     $this->manager->expects($this->once())->method('flush');
     $this->assertTrue($this->handler->process($this->entity));
     $businessUnits = $appendedUser->getBusinessUnits()->toArray();
     $this->assertCount(1, $businessUnits);
     $this->assertEquals($this->entity, current($businessUnits));
     $this->assertCount(0, $removedUser->getBusinessUnits()->toArray());
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:27,代碼來源:BusinessUnitHandlerTest.php

示例15: testProcessWithoutContactViewPermission

 public function testProcessWithoutContactViewPermission()
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->form->expects($this->once())->method('has')->with('contacts')->will($this->returnValue(false));
     $this->form->expects($this->never())->method('get');
     $this->assertTrue($this->handler->process($this->entity));
     $actualContacts = $this->entity->getContacts()->toArray();
     $this->assertCount(0, $actualContacts);
     $this->assertEquals(array(), $actualContacts);
 }
開發者ID:dairdr,項目名稱:crm,代碼行數:13,代碼來源:AccountHandlerTest.php


注:本文中的Symfony\Component\Form\FormInterface::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。