當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::initialize方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\Request::initialize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::initialize方法的具體用法?PHP Request::initialize怎麽用?PHP Request::initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\Request的用法示例。


在下文中一共展示了Request::initialize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testNoDispatch

 public function testNoDispatch()
 {
     $this->mapping->setParameter('key');
     $this->request->initialize(array('key' => 'nomethodhere'));
     $this->action->execute($this->mapping, null, $this->request, $this->response);
     $this->assertNotEmpty($this->response->getContent());
     $this->assertEquals(500, $this->response->getStatusCode());
 }
開發者ID:cammanderson,項目名稱:phruts,代碼行數:8,代碼來源:ActionDispatcherTest.php

示例2: testGetDataWithContentTypeJsonWithInvalidSha

 public function testGetDataWithContentTypeJsonWithInvalidSha()
 {
     $this->mockRequest->initialize(['test' => 1], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json', 'HTTP_QUICKPAY_CHECKSUM_SHA256' => '83ce13dffa6523334daa14f33d1fc2adc98ff8b57c4df5be5d2f58b1c2c78fa1e'], '[]');
     try {
         $this->request->getData();
         $this->fail('Expected an exception');
     } catch (InvalidResponseException $e) {
         $this->assertEquals('Invalid response from payment gateway', $e->getMessage());
     }
 }
開發者ID:nobrainerweb,項目名稱:omnipay-quickpay,代碼行數:10,代碼來源:CompleteRequestTest.php

示例3: testInitialize

 /**
  * @covers Symfony\Component\HttpFoundation\Request::initialize
  */
 public function testInitialize()
 {
     $request = new Request();
     $request->initialize(array('foo' => 'bar'));
     $this->assertEquals('bar', $request->query->get('foo'), '->initialize() takes an array of query parameters as its first argument');
     $request->initialize(null, array('foo' => 'bar'));
     $this->assertEquals('bar', $request->request->get('foo'), '->initialize() takes an array of request parameters as its second argument');
     $request->initialize(null, null, array('foo' => 'bar'));
     $this->assertEquals('bar', $request->attributes->get('foo'), '->initialize() takes an array of attributes as its thrid argument');
     $request->initialize(null, null, null, null, null, array('HTTP_FOO' => 'bar'));
     $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its fourth argument');
 }
開發者ID:netixpro,項目名稱:symfony,代碼行數:15,代碼來源:RequestTest.php

示例4: initialize

 /**
  *  do custom initialization stuff
  *
  *  @since  7-25-11
  *  @see  parent::initialize for params      
  */
 public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
 {
     $cli_query = null;
     if (!empty($server['argv'])) {
         $cli = $server['argv'];
         // in a real cli request, the 0 will be the script, in a http request, 0 will be the query string
         // but we only care about argv if it has more than the first item...
         if (isset($cli[1])) {
             $cli_query = new \ParseOpt($cli);
             // treat all the key/vals as query vars...
             if ($cli_query->hasFields()) {
                 $query = array_merge($query, $cli_query->getFields());
             }
             //if
         }
         //if
     }
     //if
     ///\out::e($query, $request, $attributes, $cookies, $files, $server, $content);
     parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
     // treat any cli vals as appendages to the path...
     if (!empty($cli_query) && $cli_query->hasList()) {
         // this overrides automagic path finding...
         $this->pathInfo = join('/', $cli_query->getList());
     }
     //if
 }
開發者ID:Jaymon,項目名稱:Montage,代碼行數:33,代碼來源:Request.php

示例5: setUp

 protected function setUp()
 {
     $this->requestStack = new RequestStack();
     $request = new Request();
     $request->initialize(array('foobar' => 'bar'));
     $this->requestStack->push($request);
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:7,代碼來源:RequestHelperTest.php

示例6: superfeedr_tracker

 private function superfeedr_tracker($content, $args)
 {
     $request = new Request();
     $request->initialize([], [], [], [], [], [], $content);
     $response = new Response();
     return $this->client->superfeedr_tracker($request, $response, $args);
 }
開發者ID:aaronpk,項目名稱:Telegraph,代碼行數:7,代碼來源:APITest.php

示例7: initialize

 public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
 {
     parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
     $this->soapMessage = null;
     $this->soapHeaders = new Collection('getName');
     $this->soapAttachments = new Collection('getId');
     $this->setRequestFormat('soap');
 }
開發者ID:RogerWebb,項目名稱:WebServiceBundle,代碼行數:8,代碼來源:SoapRequest.php

示例8: _queryService

 /**
  * Magic, do not touch. Fucking ugly but provides incredibly huge speedup :]
  * 
  * @param string $service
  * @param string $query
  * @param string $language
  * @return \stdClass 
  */
 private function _queryService($service, $query, $language)
 {
     $request = new Request();
     $request->initialize(array('query_string' => 'query=' . $query . '&lang=' . $language));
     $controllerName = '\\Service\\' . $service . '\\Controller\\SearchController';
     $controller = new $controllerName();
     return json_decode($controller->indexAction($request)->getContent());
 }
開發者ID:niutech,項目名稱:SOA,代碼行數:16,代碼來源:SoapFacade.php

示例9: it_does_not_match_a_path_not_in_the_multi_path_configuration

 /**
  * @test
  */
 public function it_does_not_match_a_path_not_in_the_multi_path_configuration()
 {
     $nonMatchingRequest = new Request();
     $nonMatchingRequest->server->set('REQUEST_URI', '/incorrect/path');
     $nonMatchingRequest->initialize($nonMatchingRequest->query->all(), $nonMatchingRequest->request->all(), $nonMatchingRequest->attributes->all(), $nonMatchingRequest->cookies->all(), $nonMatchingRequest->files->all(), $nonMatchingRequest->server->all(), $nonMatchingRequest->getContent());
     $matches = $this->requestMatcher->matches($nonMatchingRequest);
     $this->assertFalse($matches);
 }
開發者ID:cultuurnet,項目名稱:silex-uitid-provider,代碼行數:11,代碼來源:MultiPathRequestMatcherTest.php

示例10: decorateWithExtendedQuery

 /**
  * @test 
  */
 public function decorateWithExtendedQuery()
 {
     $request = new Request();
     $request->initialize(array('query_string' => 'query=doesnt_matter'));
     $urlParamsMapper = new UrlParamsMapperInterfaceMock();
     $queryDecorator = new QueryDecorator(new QueryMock());
     $query = $queryDecorator->decorate($request, $urlParamsMapper);
     $this->assertEquals('q=label%3Aphp+sf', $query->encode());
 }
開發者ID:niutech,項目名稱:SOA,代碼行數:12,代碼來源:QueryDecoratorTest.php

示例11: testShouldDetectAndroid

 public function testShouldDetectAndroid()
 {
     $server = array('HTTP_USER_AGENT' => 'Mozilla/5.0 (Linux; U; Android 2.1-update1; ja-jp; HTCX06HT Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17');
     $request = new Request();
     $request->initialize(array(), array(), array(), array(), array(), $server);
     $mobile = new Detector();
     $result = $mobile->detect($request);
     $this->assertEquals($result, 'iphone', '->detect() returns iphone');
 }
開發者ID:hidenorigoto,項目名稱:Dua,代碼行數:9,代碼來源:UserAgentDetectorTest.php

示例12: getSearchResultsEmptyQuery

 /**
  * @test 
  */
 public function getSearchResultsEmptyQuery()
 {
     $urlParamsMapper = new UrlParamsMapper();
     $request = new Request();
     $request->initialize(array($urlParamsMapper->getQueryParamName() => '', $urlParamsMapper->getLanguageParamName() => ''));
     $manager = new GithubManager($request);
     $resultSet = $manager->getSearchResults();
     $this->assertFalse($resultSet->success);
     $this->assertCount(0, $resultSet->results);
     $this->assertNull($resultSet->message);
 }
開發者ID:niutech,項目名稱:SOA,代碼行數:14,代碼來源:ManagerTest.php

示例13: initialize

 /**
  * Sets the parameters for this request.
  *
  * This method also re-initializes all properties.
  *
  * @param array $query The GET parameters
  * @param array $request The POST parameters
  * @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
  * @param array $cookies The COOKIE parameters
  * @param array $files The FILES parameters
  * @param array $server The SERVER parameters
  * @param string $content The raw body data
  *
  * @api
  */
 public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
 {
     parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
     $basePath = trim(App::$Properties->get('basePath'), '/');
     if ($basePath !== null && Str::length($basePath) > 0) {
         $basePath = '/' . $basePath;
     }
     if (!defined('env_no_uri') || env_no_uri === false) {
         $basePath .= '/' . strtolower(env_name);
     }
     // we never try to use path's without friendly url's
     $this->basePath = $this->baseUrl = $basePath;
 }
開發者ID:phpffcms,項目名稱:ffcms-core,代碼行數:28,代碼來源:Request.php

示例14: initialize

 /**
  * {@inheritdoc}
  *
  */
 public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
 {
     parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
     $vars_in_body = in_array($this->getMethod(), ['PUT', 'POST', 'PATCH', 'DELETE']);
     if (!$this->isJson() || !$vars_in_body) {
         return;
     }
     if (!($data = json_decode($this->getContent(), TRUE))) {
         return;
     }
     foreach ($data as $key => $value) {
         $this->request->set($key, $value);
     }
 }
開發者ID:erpframework,項目名稱:restapi,代碼行數:18,代碼來源:JsonRequest.php

示例15: cacheWorksCorrectly

 /**
  * @test 
  */
 public function cacheWorksCorrectly()
 {
     $sha1 = sha1(mktime());
     $hash = md5('https://github.com/search?repo=&langOverride=&start_value=1&type=Code&q=' . $sha1 . '&language=php');
     $cacheFile = __DIR__ . '/../../../../../app/cache/servicecache/' . $hash;
     if (file_exists($cacheFile)) {
         unlink($cacheFile);
     }
     $request = new Request();
     $request->initialize(array('query_string' => 'query=' . $sha1 . '&lang=php'));
     $manager = new ManagerAbstractMock($request);
     $manager->getSearchResults();
     $cacheFileTime = filectime($cacheFile);
     sleep(1);
     $manager->getSearchResults();
     $this->assertEquals($cacheFileTime, filectime($cacheFile), 'File overwritten, problem with cache.');
 }
開發者ID:niutech,項目名稱:SOA,代碼行數:20,代碼來源:ManagerTest.php


注:本文中的Symfony\Component\HttpFoundation\Request::initialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。