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


PHP Request::expects方法代码示例

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


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

示例1: testGetPathWithBasePathThatDoesNotMatch

 public function testGetPathWithBasePathThatDoesNotMatch()
 {
     $this->request->expects($this->once())->method('getRequestUri')->will($this->returnValue('/bar'));
     $extractorFactory = new ExtractorFactory('/foo');
     $extractor = $extractorFactory->createPathExtractor();
     $this->assertSame('', $extractor($this->request));
 }
开发者ID:cosmorogers,项目名称:http-mock,代码行数:7,代码来源:ExtractorFactoryTest.php

示例2: testInvalidLocaleFound

 /**
  * @covers Kunstmaan\LanguageChooserBundle\LocaleGuesser\UrlLocaleGuesser::guessLocale
  */
 public function testInvalidLocaleFound()
 {
     $this->metaValidator->expects($this->once())->method('isAllowed')->will($this->returnValue(false));
     $this->request->expects($this->once())->method('getPathInfo')->will($this->returnValue('/en/another-path'));
     $this->assertFalse($this->object->guessLocale($this->request));
     $this->assertEquals(null, $this->object->getIdentifiedLocale());
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:10,代码来源:UrlLocaleGuesserTest.php

示例3: testGetIncludeSubcategoriesChoice

 /**
  * @dataProvider getIncludeSubcategoriesChoiceDataProvider
  *
  * @param $value
  * @param $expected
  */
 public function testGetIncludeSubcategoriesChoice($value, $expected)
 {
     $this->requestProductHandler->setRequest($this->request);
     $this->request->expects($this->once())->method('get')->with(RequestProductHandler::INCLUDE_SUBCATEGORIES_KEY)->willReturn($value);
     $actual = $this->requestProductHandler->getIncludeSubcategoriesChoice();
     $this->assertEquals($expected, $actual);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:13,代码来源:RequestProductHandlerTest.php

示例4: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->placesAutocompleteHelperMock = $this->getMockBuilder('Ivory\\GoogleMap\\Helper\\Places\\AutocompleteHelper')->disableOriginalConstructor()->getMock();
     $this->requestMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $this->requestMock->expects($this->any())->method('getLocale')->will($this->returnValue('en'));
     $this->placesAutocompleteType = new PlacesAutocompleteType($this->placesAutocompleteHelperMock, $this->requestMock);
     $this->factory = Forms::createFormFactoryBuilder()->addType($this->placesAutocompleteType)->getFormFactory();
 }
开发者ID:acrobat,项目名称:IvoryGoogleMapBundle,代码行数:11,代码来源:PlacesAutocompleteTypeTest.php

示例5: testPageException

 public function testPageException()
 {
     $this->request->expects($this->once())->method('getPathInfo')->will($this->returnValue('/fail'));
     $this->twig->expects($this->at(0))->method('render')->with('page/fail.html.twig')->will($this->throwException(new Twig_Error_Loader('Unable to find template')));
     $this->twig->expects($this->at(1))->method('render')->with('error/404.html.twig');
     $result = $this->controller->page($this->request);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $result);
     $this->assertSame(404, $result->getStatusCode());
 }
开发者ID:demontpx,项目名称:easy-twig,代码行数:9,代码来源:ControllerTest.php

示例6: testIsActivePath

 /**
  * Test isActivePath method
  */
 public function testIsActivePath()
 {
     $this->request->expects($this->any())->method('getRequestUri')->will($this->returnValue('some/request/uri'));
     $this->container->expects($this->any())->method('get')->with($this->equalTo('request'))->will($this->returnValue($this->request));
     $this->extension->setActivePaths(array('some/specific/path'));
     $this->assertEquals(array('some/specific/path'), $this->extension->getActivePaths(), 'setActivePaths: Should return an array with "some/specific/path"');
     $this->assertTrue($this->extension->isActivePath('some/specific/path'), 'isActivePath: Should return true');
     $this->assertTrue($this->extension->isActivePath('some/request/uri'), 'isActivePath: Should return false');
 }
开发者ID:leapt,项目名称:core-bundle,代码行数:12,代码来源:NavigationExtensionTest.php

示例7: testProcess

 public function testProcess()
 {
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->request->expects($this->once())->method('getMethod')->will($this->returnValue('POST'));
     $this->form->expects($this->once())->method('submit');
     $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:antrampa,项目名称:crm,代码行数:10,代码来源:AbstractHandlerTest.php

示例8: testOnBuildKernelHandler

 /**
  * @dataProvider buildKernelProvider
  */
 public function testOnBuildKernelHandler($sessionName, $isStarted, $storageKey, $hasPreviousSession)
 {
     $this->session->expects($this->once())->method('getName')->will($this->returnValue($sessionName));
     $this->session->expects($this->once())->method('isStarted')->will($this->returnValue($isStarted));
     $this->request->expects($this->once())->method('hasPreviousSession')->will($this->returnValue($hasPreviousSession));
     $sessionMapper = new SessionMapper($this->sessionStorage, $storageKey, $this->session);
     $sessionMapper->setRequest($this->request);
     $event = new PreBuildKernelEvent(new ParameterBag(), $this->request);
     $sessionMapper->onBuildKernelHandler($event);
     $this->assertSame(array('session' => array('configured' => true, 'started' => $isStarted, 'name' => $sessionName, 'namespace' => $storageKey, 'has_previous' => $hasPreviousSession, 'storage' => $this->sessionStorage), 'injected-settings' => array('site.ini/Session/CookieTimeout' => false, 'site.ini/Session/CookiePath' => false, 'site.ini/Session/CookieDomain' => false, 'site.ini/Session/CookieSecure' => false, 'site.ini/Session/CookieHttponly' => false)), $event->getParameters()->all());
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:14,代码来源:SessionTest.php

示例9: testProcessExistingShoppingList

 public function testProcessExistingShoppingList()
 {
     $this->shoppingList->expects($this->once())->method('getId')->willReturn(1);
     $this->request->expects($this->once())->method('getMethod')->will($this->returnValue('PUT'));
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     /** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $manager */
     $manager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $manager->expects($this->once())->method('persist');
     $manager->expects($this->once())->method('flush');
     $this->registry->expects($this->once())->method('getManagerForClass')->with(self::SHOPPING_LIST_SHORTCUT)->will($this->returnValue($manager));
     $handler = new ShoppingListHandler($this->form, $this->request, $this->manager, $this->registry);
     $this->assertTrue($handler->process($this->shoppingList));
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:14,代码来源:ShoppingListHandlerTest.php

示例10: getRequestMock

 /**
  * @return PHPUnit_Framework_MockObject_MockObject|Request
  */
 protected function getRequestMock()
 {
     if (!isset($this->requestMock)) {
         $this->requestMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
         $this->requestMock->attributes = $this->getRequestAttributesMock();
         $this->requestMock->headers = $this->getRequestHeadersMock();
         if ($this->requestMethod === false) {
             $this->requestMock->expects($this->never())->method('getMethod');
         } else {
             $this->requestMock->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue($this->requestMethod));
         }
     }
     return $this->requestMock;
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:17,代码来源:EventListenerTest.php

示例11: testGetAccount

 /**
  * @dataProvider getAccountDataProvider
  *
  * @param string $method
  * @param string $class
  * @param string $param
  */
 public function testGetAccount($method, $class, $param)
 {
     $entity = $this->getEntity($class, 42);
     $this->request->expects($this->once())->method('get')->with(OrderType::NAME)->willReturn([$param => $entity->getId()]);
     $this->objectManager->expects($this->once())->method('find')->with($class, $entity->getId())->willReturn($entity);
     $this->assertSame($entity, $this->handler->{$method}());
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:14,代码来源:OrderRequestHandlerTest.php

示例12: assertSaveData

 /**
  * @param \PHPUnit_Framework_MockObject_MockObject|Form $form
  * @param object $entity
  * @param string $wid
  * @return array
  */
 protected function assertSaveData($form, $entity, $wid = 'WID')
 {
     $this->request->expects($this->atLeastOnce())->method('get')->with('_wid', false)->will($this->returnValue($wid));
     $formView = $this->getMockBuilder('Symfony\\Component\\Form\\FormView')->disableOriginalConstructor()->getMock();
     $form->expects($this->any())->method('createView')->will($this->returnValue($formView));
     return ['entity' => $entity, 'form' => $formView, 'isWidgetContext' => true];
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:UpdateHandlerTest.php

示例13: testGetShowTierPricesWithRequestAndSaveState

 public function testGetShowTierPricesWithRequestAndSaveState()
 {
     $this->handler->setRequest($this->request);
     $this->request->expects($this->exactly(3))->method('get')->willReturnMap([[FrontendPriceListRequestHandler::TIER_PRICES_KEY, null, false, '1'], [FrontendPriceListRequestHandler::SAVE_STATE_KEY, null, false, true]]);
     $this->session->expects($this->once())->method('set')->with(FrontendPriceListRequestHandler::TIER_PRICES_KEY, true);
     $this->assertEquals(true, $this->handler->getShowTierPrices());
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:7,代码来源:FrontendPriceListRequestHandlerTest.php

示例14: testVisitDatasource

 public function testVisitDatasource()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|DatagridConfiguration $config */
     $config = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\DatagridConfiguration')->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('getName')->will($this->returnValue(AccountUserByAccountExtension::SUPPORTED_GRID));
     $this->request->expects($this->any())->method('get')->with(AccountUserByAccountExtension::ACCOUNT_KEY)->will($this->returnValue(1));
     $expr = $this->getMockBuilder('Doctrine\\ORM\\Query\\Expr')->disableOriginalConstructor()->getMock();
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     $qb->expects($this->once())->method('andWhere')->will($this->returnSelf());
     $qb->expects($this->once())->method('setParameter')->with('account', 1)->will($this->returnSelf());
     $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['au']));
     $qb->expects($this->once())->method('expr')->will($this->returnValue($expr));
     /** @var \PHPUnit_Framework_MockObject_MockObject|OrmDatasource $datasource */
     $datasource = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\OrmDatasource')->disableOriginalConstructor()->getMock();
     $datasource->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($qb));
     $this->extension->visitDatasource($config, $datasource);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:17,代码来源:AccountUserByAccountExtensionTest.php

示例15: testConfirmException

 public function testConfirmException()
 {
     $this->request->expects($this->once())->method('get')->with('token')->willReturn('awesome-token');
     $this->filesystem->expects($this->once())->method('exists')->with(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'awesome-token' . '.txt')->willReturn(true);
     $this->mollieAPIClient->payments = $this->payments;
     $this->payments->expects($this->once())->method('get')->with('test')->willThrowException(new Mollie_API_Exception());
     $this->assertFalse($this->mollieDriver->confirm($this->request));
 }
开发者ID:shivella,项目名称:ideal-bundle,代码行数:8,代码来源:MollieDriverTest.php


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