當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。