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


PHP sfTestBrowser::setHttpHeader方法代碼示例

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


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

示例1: get

$b->
  get('/format/js')->
  with('request')->begin()->
    isParameter('module', 'format')->
    isParameter('action', 'js')->
    isFormat('js')->
  end()->
  with('response')->begin()->
    isStatusCode(200)->
    isHeader('content-type', 'application/javascript')->
    matches('/A js file/')->
  end()
;

$b->
  setHttpHeader('User-Agent', 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3')->
  get('/format/forTheIPhone')->
  with('request')->begin()->
    isParameter('module', 'format')->
    isParameter('action', 'forTheIPhone')->
    isFormat('iphone')->
  end()->
  with('response')->begin()->
    isStatusCode(200)->
    isHeader('content-type', 'text/html; charset=utf-8')->
    checkElement('#content', 'This is an HTML file for the iPhone')->
    checkElement('link[href*="iphone.css"]')->
  end()
;

$b->
開發者ID:nationalfield,項目名稱:symfony,代碼行數:31,代碼來源:formatTest.php

示例2: sfTestBrowser

<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$app = 'frontend';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
    return;
}
$b = new sfTestBrowser();
$b->get('/format_test.js')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('js')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'application/javascript')->matches('!/<body>/')->matches('/Some js headers/')->matches('/This is a js file/')->end();
$b->get('/format_test.css')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('css')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/css; charset=utf-8')->matches('/This is a css file/')->end();
$b->get('/format_test')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('html')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/html; charset=utf-8')->checkElement('body #content', 'This is an HTML file')->end();
$b->get('/format_test.xml')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('xml')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/xml; charset=utf-8')->checkElement('sentences sentence:first', 'This is a XML file')->end();
$b->get('/format_test.foo')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('foo')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/html; charset=utf-8')->isHeader('x-foo', 'true')->checkElement('body #content', 'This is an HTML file')->end();
$b->get('/format/js')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'js')->isFormat('js')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'application/javascript')->matches('/A js file/')->end();
$b->setHttpHeader('User-Agent', 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3')->get('/format/forTheIPhone')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'forTheIPhone')->isFormat('iphone')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/html; charset=utf-8')->checkElement('#content', 'This is an HTML file for the iPhone')->checkElement('link[href*="iphone.css"]')->end();
$b->getAndCheck('format', 'throwsException', null, 500)->throwsException('Exception', '/message/');
開發者ID:sensorsix,項目名稱:app,代碼行數:22,代碼來源:formatTest.php

示例3: sfTestBrowser

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$app = 'frontend';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
    return;
}
$b = new sfTestBrowser();
$b->get('/format_test.js')->isStatusCode(200)->isRequestParameter('module', 'format')->isRequestParameter('action', 'index')->isRequestFormat('js')->isResponseHeader('content-type', 'application/javascript');
$b->test()->unlike($b->getResponse()->getContent(), '/<body>/', 'response content is ok');
$b->test()->like($b->getResponse()->getContent(), '/Some js headers/', 'response content is ok');
$b->test()->like($b->getResponse()->getContent(), '/This is a js file/', 'response content is ok');
$b->get('/format_test.css')->isStatusCode(200)->isRequestParameter('module', 'format')->isRequestParameter('action', 'index')->isRequestFormat('css')->isResponseHeader('content-type', 'text/css; charset=utf-8');
$b->test()->is($b->getResponse()->getContent(), 'This is a css file', 'response content is ok');
$b->get('/format_test')->isStatusCode(200)->isRequestParameter('module', 'format')->isRequestParameter('action', 'index')->isRequestFormat('html')->isResponseHeader('content-type', 'text/html; charset=utf-8')->checkResponseElement('body #content', 'This is an HTML file');
$b->get('/format_test.xml')->isStatusCode(200)->isRequestParameter('module', 'format')->isRequestParameter('action', 'index')->isRequestFormat('xml')->isResponseHeader('content-type', 'text/xml; charset=utf-8')->checkResponseElement('sentences sentence:first', 'This is a XML file');
$b->get('/format_test.foo')->isStatusCode(200)->isRequestParameter('module', 'format')->isRequestParameter('action', 'index')->isRequestFormat('foo')->isResponseHeader('content-type', 'text/html; charset=utf-8')->isResponseHeader('x-foo', 'true')->checkResponseElement('body #content', 'This is an HTML file');
$b->setHttpHeader('Accept', 'application/javascript')->get('/format/jsWithAccept')->isStatusCode(200)->isRequestParameter('module', 'format')->isRequestParameter('action', 'jsWithAccept')->isRequestFormat('js')->isResponseHeader('content-type', 'application/javascript');
$b->test()->like($b->getResponse()->getContent(), '/This is a js file/', 'response content is ok');
$b->get('/format/js')->isStatusCode(200)->isRequestParameter('module', 'format')->isRequestParameter('action', 'js')->isRequestFormat('js')->isResponseHeader('content-type', 'application/javascript');
$b->test()->is($b->getResponse()->getContent(), 'A js file', 'response content is ok');
$b->setHttpHeader('User-Agent', 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3')->get('/format/forTheIPhone')->isStatusCode(200)->isRequestParameter('module', 'format')->isRequestParameter('action', 'forTheIPhone')->isRequestFormat('iphone')->isResponseHeader('content-type', 'text/html; charset=utf-8')->checkResponseElement('#content', 'This is an HTML file for the iPhone')->checkResponseElement('link[href*="iphone.css"]');
$b->getAndCheck('format', 'throwsException', null, 500)->throwsException('Exception', '/message/');
$b->setHttpHeader('Accept', 'application/javascript')->getAndCheck('format', 'throwsException', null, 500)->isRequestFormat('js')->isResponseHeader('content-type', 'application/javascript')->throwsException('Exception', '/message/');
$b->test()->like($b->getResponse()->getContent(), '/Exception/', 'response is exception template');
$b->setHttpHeader('Accept', 'text/css')->getAndCheck('format', 'throwsNonDebugException', null, 500)->isRequestFormat('css')->isResponseHeader('content-type', 'text/css; charset=utf-8')->throwsException('Exception', '/message/');
$b->test()->unlike($b->getResponse()->getContent(), '/Exception/', 'response is error 500 template');
開發者ID:WIZARDISHUNGRY,項目名稱:symfony,代碼行數:31,代碼來源:formatTest.php


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