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


PHP RequestStack::expects方法代码示例

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


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

示例1: testConfigureNoRequest

 public function testConfigureNoRequest()
 {
     $response = new Response();
     $expected_response = clone $response;
     $this->request_stack->expects($this->once())->method('getMasterRequest')->will($this->returnValue(null));
     $configurator = new ResponseConfigurator($this->key_builder, $this->request_stack, []);
     $this->assertEquals($expected_response, $configurator->configure($response, new \DateTime(), -1));
 }
开发者ID:anime-db,项目名称:cache-time-keeper-bundle,代码行数:8,代码来源:ResponseConfiguratorTest.php

示例2: setUp

 /**
  * setup type we want to test
  *
  * @return void
  */
 public function setUp()
 {
     $this->converter = $this->getMockBuilder('\\Graviton\\DocumentBundle\\Service\\ExtReferenceConverterInterface')->disableOriginalConstructor()->getMock();
     $this->requestAttrs = $this->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\ParameterBag')->disableOriginalConstructor()->setMethods(['get'])->getMock();
     $this->request = new Request();
     $this->request->attributes = $this->requestAttrs;
     $this->requestStack = $this->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\RequestStack')->disableOriginalConstructor()->setMethods(['getCurrentRequest'])->getMock();
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->willReturn($this->request);
 }
开发者ID:alebon,项目名称:graviton,代码行数:14,代码来源:ExtReferenceSearchListenerTest.php

示例3: setUp

 /**
  * Setup the test
  *
  * @return void
  */
 protected function setUp()
 {
     $this->requestAttrs = $this->getMockBuilder(ParameterBag::class)->disableOriginalConstructor()->setMethods(['get'])->getMock();
     $this->request = new Request();
     $this->request->attributes = $this->requestAttrs;
     $this->requestStack = $this->getMockBuilder(RequestStack::class)->disableOriginalConstructor()->setMethods(['getCurrentRequest'])->getMock();
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->willReturn($this->request);
     parent::setUp();
 }
开发者ID:alebon,项目名称:graviton,代码行数:14,代码来源:FieldNameSearchListenerTest.php

示例4: testLocalesWithApiRequestWithoutAcceptLanguageHeader

 public function testLocalesWithApiRequestWithoutAcceptLanguageHeader()
 {
     $request = $this->createRequestMock();
     $request->headers->expects($this->once())->method('get')->with($this->identicalTo('Accept-Language'))->will($this->returnValue(null));
     $request->expects($this->once())->method('getLocale')->will($this->returnValue($locale = 'en'));
     $this->requestStack->expects($this->once())->method('getMasterRequest')->will($this->returnValue($request));
     $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(true));
     $this->assertSame([$locale], $this->localeContext->getLocales());
 }
开发者ID:blazarecki,项目名称:lug,代码行数:9,代码来源:LocaleContextTest.php

示例5: 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->requestStackMock = $this->getMock('Symfony\\Component\\HttpFoundation\\RequestStack');
     $this->requestStackMock->expects($this->any())->method('getCurrentRequest')->willReturn($this->requestMock);
     $this->placesAutocompleteType = new PlacesAutocompleteType($this->placesAutocompleteHelperMock, $this->requestStackMock);
     $this->factory = Forms::createFormFactoryBuilder()->addType($this->placesAutocompleteType)->getFormFactory();
     //        var_dump($this->factory);die;
 }
开发者ID:petrepatrasc,项目名称:IvoryGoogleMapBundle,代码行数:14,代码来源:PlacesAutocompleteTypeTest.php

示例6: setUp

 public function setUp()
 {
     $this->contentQuery = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Query\\ContentQueryExecutorInterface');
     $this->contentQueryBuilder = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Query\\ContentQueryBuilderInterface');
     $this->tagManager = $this->getMockForAbstractClass('Sulu\\Bundle\\TagBundle\\Tag\\TagManagerInterface', [], '', false, true, true, ['resolveTagIds', 'resolveTagNames']);
     $this->requestStack = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\RequestStack')->getMock();
     $this->request = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->getMock();
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($this->request));
     $this->smartContent = new SmartContent($this->contentQuery, $this->contentQueryBuilder, $this->tagManager, $this->requestStack, 'SuluContentBundle:Template:content-types/smart_content.html.twig');
     $this->tagManager->expects($this->any())->method('resolveTagIds')->will($this->returnValueMap([[[1, 2], ['Tag1', 'Tag2']]]));
     $this->tagManager->expects($this->any())->method('resolveTagName')->will($this->returnValueMap([[['Tag1', 'Tag2'], [1, 2]]]));
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:12,代码来源:SmartContentTest.php

示例7: setUp

 protected function setUp()
 {
     $this->router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $this->requestStack = $this->getMock('Symfony\\Component\\HttpFoundation\\RequestStack');
     $this->requestStack->expects($this->any())->method('getMasterRequest')->will($this->returnValue(new Request()));
     $column = new Action($this->router, $this->requestStack);
     $column->setName('action');
     $column->initOptions();
     $extension = new DefaultColumnOptionsExtension();
     $extension->initOptions($column);
     $this->column = $column;
 }
开发者ID:norzechowicz,项目名称:datagrid-bundle,代码行数:12,代码来源:ActionTest.php

示例8: setup

 /**
  * Test setup.
  */
 public function setup()
 {
     $this->controller = [new \stdClass(), 'fooAction'];
     $this->params = [];
     $this->paramReader = $this->getMock('FOS\\RestBundle\\Request\\ParamReaderInterface');
     $this->validator = $this->getMock('Symfony\\Component\\Validator\\Validator\\ValidatorInterface');
     $this->violationFormatter = $this->getMock('FOS\\RestBundle\\Validator\\ViolationFormatterInterface');
     $this->request = new Request();
     $this->requestStack = $this->getMock('Symfony\\Component\\HttpFoundation\\RequestStack', array());
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->willReturn($this->request);
     $this->paramFetcherBuilder = $this->getMockBuilder('FOS\\RestBundle\\Request\\ParamFetcher');
     $this->paramFetcherBuilder->setConstructorArgs(array($this->paramReader, $this->requestStack, $this->violationFormatter, $this->validator))->setMethods(null);
 }
开发者ID:GTheron,项目名称:FOSRestBundle,代码行数:16,代码来源:ParamFetcherTest.php

示例9: testHash

 /**
  * @dataProvider getHashParams
  *
  * @param string $algorithm
  * @param Request|null $request
  */
 public function testHash($algorithm, Request $request = null)
 {
     $last_modified = new \DateTime('-1 day');
     $response = (new Response())->setLastModified($last_modified);
     $this->request_stack->expects($this->atLeastOnce())->method('getMasterRequest')->will($this->returnValue($request));
     $hasher = new EtagHasher($this->request_stack, $algorithm);
     $suffix = '';
     if ($request) {
         $suffix = EtagHasher::ETAG_SEPARATOR . http_build_query($request->cookies->all());
     }
     $etag = hash($algorithm, $response->getLastModified()->format(\DateTime::ISO8601) . $suffix);
     $this->assertEquals($etag, $hasher->hash($response));
 }
开发者ID:anime-db,项目名称:cache-time-keeper-bundle,代码行数:19,代码来源:EtagHasherTest.php

示例10: testForceLogin

 /**
  * Test the forcedLogin redirect.
  *
  * @covers ::forceLogin
  * @covers ::__construct
  */
 public function testForceLogin()
 {
     $request = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
     $query = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag');
     $request->query = $query;
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request));
     $parameters = array('returnto' => 'node/1', 'foo' => 'bar');
     $query->expects($this->once())->method('all')->will($this->returnValue($parameters));
     $this->casHelper->expects($this->once())->method('getServerLoginUrl')->with($this->equalTo($parameters))->will($this->returnValue('https://example.com'));
     $expected_response = new TrustedRedirectResponse('https://example.com', 302);
     $force_login_controller = new ForceLoginController($this->casHelper, $this->requestStack);
     $response = $force_login_controller->forceLogin();
     $this->assertEquals($expected_response, $response);
 }
开发者ID:anarshi,项目名称:recap,代码行数:20,代码来源:ForceLoginControllerTest.php

示例11: setup

 /**
  * Test setup.
  */
 public function setup()
 {
     $this->controller = [new \stdClass(), 'fooAction'];
     $this->params = [];
     $this->paramReader = $this->getMock(ParamReaderInterface::class);
     $this->validator = $this->getMock(ValidatorInterface::class);
     $this->violationFormatter = $this->getMock(ViolationFormatterInterface::class);
     $this->request = new Request();
     $this->requestStack = $this->getMock(RequestStack::class, array());
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->willReturn($this->request);
     $this->paramFetcherBuilder = $this->getMockBuilder(ParamFetcher::class);
     $this->paramFetcherBuilder->setConstructorArgs(array($this->paramReader, $this->requestStack, $this->violationFormatter, $this->validator))->setMethods(null);
     $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
 }
开发者ID:AAstakhov,项目名称:FOSRestBundle,代码行数:17,代码来源:ParamFetcherTest.php

示例12: testCallback

 /**
  * Test the proxy callback.
  *
  * @covers ::callback
  * @covers ::__construct
  *
  * @dataProvider callbackDataProvider
  */
 public function testCallback($pgt_iou, $pgt_id, $request_exception)
 {
     $proxy_callback_controller = $this->getMockBuilder('\\Drupal\\cas\\Controller\\ProxyCallbackController')->setConstructorArgs(array($this->connection, $this->requestStack, $this->casHelper))->setMethods(array('storePgtMapping'))->getMock();
     $request = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
     $query = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag');
     $request->query = $query;
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request));
     if (!$request_exception) {
         $query->expects($this->any())->method('get')->will($this->onConsecutiveCalls($pgt_id, $pgt_iou));
         $expected_response = new Response('OK', 200);
     } else {
         $query->expects($this->any())->method('get')->will($this->returnValue(FALSE));
         $expected_response = new Response('Missing necessary parameters', 400);
     }
     $response = $proxy_callback_controller->callback();
     $this->assertEquals($expected_response->getStatusCode(), $response->getStatusCode());
 }
开发者ID:pulibrary,项目名称:recap,代码行数:25,代码来源:ProxyCallbackControllerTest.php

示例13: testApiWithHateoasButWithoutRequest

 /**
  * @expectedException \Lug\Bundle\ResourceBundle\Exception\RequestNotFoundException
  * @expectedExceptionMessage The request could not be found.
  */
 public function testApiWithHateoasButWithoutRequest()
 {
     $this->parameterResolver->expects($this->once())->method('resolveApi')->will($this->returnValue(true));
     $this->parameterResolver->expects($this->once())->method('resolveHateoas')->will($this->returnValue(true));
     $event = $this->createViewEventMock();
     $event->expects($this->once())->method('getView')->will($this->returnValue($view = $this->createViewMock()));
     $view->expects($this->once())->method('getData')->will($this->returnValue($pagerfanta = $this->createPagerfantaMock()));
     $this->requestStack->expects($this->once())->method('getMasterRequest')->will($this->returnValue(null));
     $this->subscriber->onApi($event);
 }
开发者ID:php-lug,项目名称:lug,代码行数:14,代码来源:PagerfantaViewSubscriberTest.php

示例14: setUp

 public function setUp()
 {
     $this->contentDataProvider = $this->prophesize(DataProviderInterface::class);
     $this->contentDataProvider->getConfiguration()->willReturn($this->getProviderConfiguration());
     $this->contentDataProvider->getDefaultPropertyParameter()->willReturn([]);
     $this->dataProviderPool = new DataProviderPool();
     $this->dataProviderPool->add('content', $this->contentDataProvider->reveal());
     $this->tagManager = $this->getMockForAbstractClass(TagManagerInterface::class, [], '', false, true, true, ['resolveTagIds', 'resolveTagNames']);
     $this->requestStack = $this->getMockBuilder(RequestStack::class)->getMock();
     $this->request = $this->getMockBuilder(Request::class)->getMock();
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($this->request));
     $this->tagRequestHandler = $this->prophesize(TagRequestHandlerInterface::class);
     $this->tagRequestHandler->getTags('tags')->willReturn([]);
     $this->categoryRequestHandler = $this->prophesize(CategoryRequestHandlerInterface::class);
     $this->categoryRequestHandler->getCategories('categories')->willReturn([]);
     $this->smartContent = new SmartContent($this->dataProviderPool, $this->tagManager, $this->requestStack, $this->tagRequestHandler->reveal(), $this->categoryRequestHandler->reveal(), 'SuluContentBundle:Template:content-types/smart_content.html.twig');
     $this->tagManager->expects($this->any())->method('resolveTagIds')->will($this->returnValueMap([[[1, 2], ['Tag1', 'Tag2']]]));
     $this->tagManager->expects($this->any())->method('resolveTagName')->will($this->returnValueMap([[['Tag1', 'Tag2'], [1, 2]]]));
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:19,代码来源:ContentTypeTest.php

示例15: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->entityFormBuilder = $this->getMock(EntityFormBuilderInterface::class);
     $this->paymentLineItemManager = $this->getMock(PaymentLineItemManagerInterface::class);
     $this->fieldDefinition = $this->getMock(FieldDefinitionInterface::class);
     $this->renderer = $this->getMock(RendererInterface::class);
     $this->request = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock();
     $this->requestStack = $this->getMockBuilder(RequestStack::class)->disableOriginalConstructor()->getMock();
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->willReturn($this->request);
     $this->paymentStorage = $this->getMock(EntityStorageInterface::class);
     $this->sut = new PaymentForm($this->randomMachineName(), [], $this->fieldDefinition, [], $this->randomMachineName(), $this->randomMachineName(), [], $this->requestStack, $this->entityFormBuilder, $this->paymentStorage, $this->paymentLineItemManager);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:15,代码来源:PaymentFormTest.php


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