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


PHP Request::setMethod方法代码示例

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


在下文中一共展示了Request::setMethod方法的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: testProcessSupportedRequest

 /**
  * @dataProvider supportedMethods
  *
  * @param string $method
  */
 public function testProcessSupportedRequest($method)
 {
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->request->setMethod($method);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->assertFalse($this->handler->process($this->entity));
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:SegmentHandlerTest.php

示例3: 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

示例4: 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

示例5: 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

示例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: testAddingErrorToNonEditableSystemEntity

 public function testAddingErrorToNonEditableSystemEntity()
 {
     $this->entity->setIsSystem(true);
     $this->entity->setIsEditable(false);
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('addError');
     $this->request->setMethod('POST');
     $this->translator->expects($this->once())->method('trans');
     $this->assertFalse($this->handler->process($this->entity));
 }
开发者ID:ramunasd,项目名称:platform,代码行数:10,代码来源:EmailTemplateHandlerTest.php

示例8: testProcessValidData

 /**
  * @dataProvider supportedMethods
  */
 public function testProcessValidData($method)
 {
     $this->request->setMethod($method);
     $this->form->expects($this->once())->method('setData')->with($this->identicalTo($this->entity));
     $this->form->expects($this->once())->method('submit')->with($this->identicalTo($this->request));
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->om->expects($this->once())->method('persist');
     $this->om->expects($this->once())->method('flush');
     $this->assertTrue($this->handler->process($this->entity));
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:SystemCalendarHandlerTest.php

示例9: testProcessValidData

 public function testProcessValidData()
 {
     $this->form->expects($this->once())->method('setData')->with($this->attribute);
     $this->request->request->set(UpdateAttributeType::NAME, []);
     $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->attribute);
     $this->manager->expects($this->once())->method('flush');
     $this->assertTrue($this->handler->process($this->attribute));
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:11,代码来源:UpdateAttributeHandlerTest.php

示例10: testGetFormSubmittedData

 /**
  * @dataProvider submittedDataProvider
  *
  * @param string $requestType
  * @param array  $requestData
  * @param array  $expectedResult
  * @param null   $expectedException
  */
 public function testGetFormSubmittedData($requestType, $requestData, $expectedResult, $expectedException = null)
 {
     $this->request->setMethod($requestType);
     foreach ($requestData as $key => $value) {
         $this->request->request->set($key, $value);
     }
     if (null !== $expectedException) {
         $this->setExpectedException($expectedException);
     }
     $this->form->expects($this->any())->method('getName')->will($this->returnValue(self::TEST_NAME));
     $this->assertSame($expectedResult, $this->handler->getFormSubmittedData());
 }
开发者ID:dairdr,项目名称:crm,代码行数:20,代码来源:ChannelIntegrationHandlerTest.php

示例11: 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->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em));
     $this->em->expects($this->once())->method('persist')->with($this->entity);
     $this->em->expects($this->once())->method('flush');
     $this->dispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(ChannelSaveEvent::EVENT_NAME), $this->isInstanceOf('OroCRM\\Bundle\\ChannelBundle\\Event\\ChannelSaveEvent'));
     $this->assertTrue($this->handler->process($this->entity));
 }
开发者ID:dairdr,项目名称:crm,代码行数:12,代码来源:ChannelHandlerTest.php

示例12: testProcess

 /**
  * @param string $method
  * @param bool   $formValid
  * @param bool   $isFlushCalled
  *
  * @dataProvider processProvider
  */
 public function testProcess($method, $isFormValid, $isFlushCalled)
 {
     $entity = new TrackingWebsite();
     $this->request->setMethod($method);
     $this->form->expects($this->any())->method('submit')->with($this->request);
     $this->form->expects($this->any())->method('isValid')->will($this->returnValue($isFormValid));
     if ($isFlushCalled) {
         $this->manager->expects($this->once())->method('persist')->with($this->equalTo($entity))->will($this->returnValue(true));
         $this->manager->expects($this->once())->method('flush');
     }
     $handler = new TrackingWebsiteHandler($this->form, $this->request, $this->manager);
     $handler->process($entity);
 }
开发者ID:Maksold,项目名称:platform,代码行数:20,代码来源:TrackingWebsiteHandlerTest.php

示例13: testProcess

 public function testProcess()
 {
     $data = $this->getMockBuilder('OroCRM\\Bundle\\CampaignBundle\\Entity\\EmailCampaign')->disableOriginalConstructor()->getMock();
     $this->form->expects($this->once())->method('setData')->with($data);
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $manager = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\ObjectManager')->disableOriginalConstructor()->getMock();
     $manager->expects($this->once())->method('persist')->with($data);
     $manager->expects($this->once())->method('flush');
     $this->registry->expects($this->once())->method('getManagerForClass')->with('OroCRMCampaignBundle:EmailCampaign')->will($this->returnValue($manager));
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->assertTrue($this->handler->process($data));
 }
开发者ID:antrampa,项目名称:crm,代码行数:13,代码来源:EmailCampaignHandlerTest.php

示例14: 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

示例15: testProcessException

 /**
  * @param string $method
  *
  * @dataProvider methodsData
  */
 public function testProcessException($method)
 {
     $this->request->setMethod($method);
     $this->model->setFrom('from@example.com')->setTo(['to@example.com'])->setSubject('testSubject')->setBody('testBody');
     $this->form->expects($this->once())->method('setData')->with($this->model);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $exception = new \Exception('TEST');
     $this->emailProcessor->expects($this->once())->method('process')->with($this->model)->will($this->returnCallback(function () use($exception) {
         throw $exception;
     }));
     $this->logger->expects($this->once())->method('error')->with('Email sending failed.', ['exception' => $exception]);
     $this->form->expects($this->once())->method('addError')->with($this->isInstanceOf('Symfony\\Component\\Form\\FormError'));
     $this->assertFalse($this->handler->process($this->model));
 }
开发者ID:Maksold,项目名称:platform,代码行数:20,代码来源:EmailHandlerTest.php


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