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


PHP Client::getServerParameter方法代碼示例

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


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

示例1: testJsonDeleteGame

 /**
  * Test deleting a game
  */
 public function testJsonDeleteGame()
 {
     $this->authenticate('IAmDev', 'passdev');
     $games = $this->loadGames();
     // find a game created by user
     $gamesByUser = array_filter($games, function ($item) {
         return $item->getOwner()->getUsername() == $this->client->getServerParameter('PHP_AUTH_USER');
     });
     if (empty($gamesByUser)) {
         $this->markTestSkipped('You need an user with games to perform a delete');
     }
     $game = array_pop($gamesByUser);
     $this->client->request('DELETE', $this->getUrl('api_1_delete_game', array('slug' => $game->getSlug())));
     $response = $this->client->getResponse();
     $this->assertEquals($response->getStatusCode(), 204, 'The response must be 204 No Content');
     // Verify that the game was well deleted
     $this->client->request('GET', $this->getUrl('api_1_get_game', array('slug' => $game->getSlug())));
     $response = $this->client->getResponse();
     $this->assertEquals($response->getStatusCode(), 404, 'The game has not been deleted as expected');
 }
開發者ID:Brindesable,項目名稱:website,代碼行數:23,代碼來源:GameControllerTest.php

示例2: getAbsoluteUri

 /**
  * Takes a URI and converts it to absolute if it is not already absolute.
  *
  * @param string $uri A URI
  * @return string An absolute URI
  */
 public function getAbsoluteUri($uri)
 {
     // already absolute?
     if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) {
         return $uri;
     }
     $currentUri = sprintf('http%s://%s/', $this->client->getServerParameter('HTTPS') ? 's' : '', $this->client->getServerParameter('HTTP_HOST', 'localhost'));
     // protocol relative URL
     if (0 === strpos($uri, '//')) {
         return parse_url($currentUri, PHP_URL_SCHEME) . ':' . $uri;
     }
     // anchor?
     if (!$uri || '#' == $uri[0]) {
         return preg_replace('/#.*?$/', '', $currentUri) . $uri;
     }
     if ('/' !== $uri[0]) {
         $path = parse_url($currentUri, PHP_URL_PATH);
         if ('/' !== substr($path, -1)) {
             $path = substr($path, 0, strrpos($path, '/') + 1);
         }
         $uri = $path . $uri;
     }
     return preg_replace('#^(.*?//[^/]+)\\/.*$#', '$1', $currentUri) . $uri;
 }
開發者ID:glavweb,項目名稱:GlavwebRestBundle,代碼行數:30,代碼來源:RestTestCase.php

示例3: getServerParameter

 /**
  * Gets single server parameter for specified key.
  *
  * @param string $key     A key of the parameter to get
  * @param string $default A default value when key is undefined
  *
  * @return string A value of the parameter
  */
 public function getServerParameter($key, $default = '')
 {
     return $this->subject->getServerParameter($key, $default);
 }
開發者ID:kleijnweb,項目名稱:swagger-bundle,代碼行數:12,代碼來源:ApiTestClient.php


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