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