本文整理汇总了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');
}
示例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;
}
示例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);
}