本文整理汇总了PHP中sfTestBrowser::checkResponseElement方法的典型用法代码示例。如果您正苦于以下问题:PHP sfTestBrowser::checkResponseElement方法的具体用法?PHP sfTestBrowser::checkResponseElement怎么用?PHP sfTestBrowser::checkResponseElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfTestBrowser
的用法示例。
在下文中一共展示了sfTestBrowser::checkResponseElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sfTestBrowser
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 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->initialize();
// exceptions
$b->get('/exception/noException')->isStatusCode(200)->isRequestParameter('module', 'exception')->isRequestParameter('action', 'noException')->responseContains('foo')->get('/exception/throwsException')->isStatusCode(200)->isRequestParameter('module', 'exception')->isRequestParameter('action', 'throwsException')->throwsException('Exception')->throwsException('Exception', 'Exception message')->throwsException('Exception', '/message/')->throwsException(null, '!/sfException/')->get('/exception/throwsSfException')->isStatusCode(200)->isRequestParameter('module', 'exception')->isRequestParameter('action', 'throwsSfException')->throwsException('sfException')->throwsException('sfException', 'sfException message');
$b->get('/browser')->responseContains('html')->checkResponseElement('h1', 'html')->get('/browser/text')->responseContains('text');
try {
$b->checkResponseElement('h1', 'text');
$b->test()->fail('The DOM is not accessible if the response content type is not HTML');
} catch (sfException $e) {
$b->test()->pass('The DOM is not accessible if the response content type is not HTML');
}
// check response headers
$b->get('/browser/responseHeader')->isStatusCode()->isResponseHeader('content-type', 'text/plain; charset=utf-8')->isResponseHeader('foo', 'bar')->isResponseHeader('foo', 'foobar');
示例2: isRequestParameter
isRequestParameter('module', 'agent')->
isRequestParameter('action', 'list')->
checkResponseElement('meta[content="text/html; charset=utf-8"]', true)->
checkResponseElement('meta[content="text/css"]', true)->
checkResponseElement('meta[content="en"]', true)->
checkResponseElement('meta[name="robots"]', true)->
checkResponseElement('meta[content="index,follow"]', true)->
checkResponseElement('meta[name="description"]', true)->
checkResponseElement('meta[name="keywords"]', true)->
checkResponseElement('meta[name="language"]', true)->
checkResponseElement('meta[content="en"]', true)->
checkResponseElement('link[rel="shortcut icon"]', true)
;
//dynamic head settings
$browser->
checkResponseElement('script[src="/sf/prototype/js/prototype.js"]', true)->
checkResponseElement('script[src="/sf/prototype/js/builder.js"]', true)->
checkResponseElement('script[src="/sf/prototype/js/effects.js"]', true)->
checkResponseElement('link[href="/jpAdminPlugin/css/main.css"]', true)->
checkResponseElement('link[href="/css/main.css"]', true)->
checkResponseElement('link[href="/css/layout.css"]', true)->
checkResponseElement('link[href="/css/agent/layout.css"]', true)
;
//admin sidebar
$browser->
checkResponseElement('div#content_bar > div#panel_admin > h2', '/administration/')
;
//list
$browser->
示例3: isStatusCode
//if it's forbidden
$forwardTo = $actionArray['roles'][$role][$key]['forwardTo'];
if (is_array($forwardTo))
{
//we should get forwarded to login
$browser->
isStatusCode(200)->
isForwardedTo($forwardTo[0], $forwardTo[1])->
isStatusCode(200)
;
echo "\n****** Forbidden OK -- " . $role . " :: " . $key . " Access :: " . $action . "\n";
}
else if (isset($selectors))
{
// test everything for this role
foreach ($selectors as $selector => $test)
{
$browser->checkResponseElement($test[0], $test[1]);
}
}
}
}
//foreach $selectors as $selector => $test
//checkResponseElement($test[0], $test[1], 'Checking -- ' . $selector)->
}
}