本文整理汇总了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));
}
示例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));
}
示例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);
}
示例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));
}
示例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());
}
示例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));
}
示例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']);
}
示例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));
}
示例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));
}
示例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()));
}
}
示例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);
}
示例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));
}
示例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));
}
示例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());
}
示例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);
}