调试测试sfPHPUnit Symfony1.4
Debugging test sfPHPUnit Symfony1.4
嘿抱歉,如果这个问题太具体但我不得不重构一些遗留的 Symfony1.4 代码并且我不知道如何在测试中转储 get 请求的响应,以帮助调试一个奇怪的错误.
有问题的测试如下所示:
public function testDataset () {
$browser = $this->getBrowser();
$browser->
get('/search/dataset')->
with('request')->begin()->
isParameter('module', 'search')->
isParameter('action', 'dataset')->
end()->
with('response')->begin()->
isStatusCode(200)->
checkElement('body', '/Choose your dataset/')->
checkElement('#compareBy', '/High-density residental/')->
checkElement('#compareBy', '/Medium-density residential/')->
checkElement('#compareBy', '/Low-density residential/')->
checkElement('#compareBy', '/Commercial/')->
checkElement('#compareBy', '/CBD/')->
checkElement('#compareBy', '/Heavy industrial/')->
checkElement('#compareBy', '/Light industrial/')->
checkElement('#compareBy', '/Highway \/ Motorway/')->
checkElement('#compareBy', '/Arterial roads/')->
checkElement('#compareBy', '/Local roads/')->
checkElement('#compareBy', '/Open space/')->
checkElement('#dataLocation','/All New Zealand/')->
checkElement('#dataLocation','/All North Island/')->
checkElement('#dataLocation','/All South Island/')->
checkElement('#dataLocation','/Northland/')->
checkElement('#dataLocation','/Auckland/')->
checkElement('#dataLocation','/Waikato/')->
checkElement('#dataLocation','/Bay of Plenty/')->
checkElement('#dataLocation','/Taranaki/')->
checkElement('#dataLocation','/Gisborne/')->
checkElement('#dataLocation','/Hawkes Bay/')->
checkElement('#dataLocation','/Manawatu-Wanganui/')->
checkElement('#dataLocation','/Wellington/')->
checkElement('#dataLocation','/Nelson/')->
checkElement('#dataLocation','/Tasman/')->
checkElement('#dataLocation','/Marlborough/')->
checkElement('#dataLocation','/West Coast/')->
checkElement('#dataLocation','/Canterbury/')->
checkElement('#dataLocation','/Otago/')->
checkElement('#dataLocation','/Southland/')->
checkElement('#waterTypes','/All stormwater/')->
checkElement('#waterTypes','/Untreated stormwater/')->
checkElement('#waterTypes','/Treated stormwater/')->
checkElement('#waterTypes','/Urban streams/')->
checkElement('#waterTypes','/All water types/')->
checkElement('#flowType','/Storm event/')->
checkElement('#flowType','/Baseflow/')->
end();
}
它失败了:
functional_frontend_searchActionsTest::testDataset
response selector "#compareBy" matches regex "/High-density residental/"
Failed asserting that false is true.
页面加载正常,但我不知道如何在测试中实际转储页面响应正文以调查测试看到的内容。
我试过 $browser->getContent(), $browser->getResponse(), $browser->getBody()..
这在 phpunit / Symfony2 中相当微不足道,我确定有办法做到这一点,有人可以帮忙吗?
您可以在 sfWebResponse
对象上使用 debug
方法。例如:
$browser->with('response')->debug();
您可以在legacy doc here:
签到
Debugging Functional Tests
Sometimes a functional test fails. As symfony simulates a browser
without any graphical interface, it can be hard to diagnose the
problem. Thankfully, symfony provides the debug()
method to output
the response header and content:
$browser->with('response')->debug();
The debug() method can be inserted anywhere in a response tester block
and will halt the script execution.
希望对您有所帮助
嘿抱歉,如果这个问题太具体但我不得不重构一些遗留的 Symfony1.4 代码并且我不知道如何在测试中转储 get 请求的响应,以帮助调试一个奇怪的错误.
有问题的测试如下所示:
public function testDataset () {
$browser = $this->getBrowser();
$browser->
get('/search/dataset')->
with('request')->begin()->
isParameter('module', 'search')->
isParameter('action', 'dataset')->
end()->
with('response')->begin()->
isStatusCode(200)->
checkElement('body', '/Choose your dataset/')->
checkElement('#compareBy', '/High-density residental/')->
checkElement('#compareBy', '/Medium-density residential/')->
checkElement('#compareBy', '/Low-density residential/')->
checkElement('#compareBy', '/Commercial/')->
checkElement('#compareBy', '/CBD/')->
checkElement('#compareBy', '/Heavy industrial/')->
checkElement('#compareBy', '/Light industrial/')->
checkElement('#compareBy', '/Highway \/ Motorway/')->
checkElement('#compareBy', '/Arterial roads/')->
checkElement('#compareBy', '/Local roads/')->
checkElement('#compareBy', '/Open space/')->
checkElement('#dataLocation','/All New Zealand/')->
checkElement('#dataLocation','/All North Island/')->
checkElement('#dataLocation','/All South Island/')->
checkElement('#dataLocation','/Northland/')->
checkElement('#dataLocation','/Auckland/')->
checkElement('#dataLocation','/Waikato/')->
checkElement('#dataLocation','/Bay of Plenty/')->
checkElement('#dataLocation','/Taranaki/')->
checkElement('#dataLocation','/Gisborne/')->
checkElement('#dataLocation','/Hawkes Bay/')->
checkElement('#dataLocation','/Manawatu-Wanganui/')->
checkElement('#dataLocation','/Wellington/')->
checkElement('#dataLocation','/Nelson/')->
checkElement('#dataLocation','/Tasman/')->
checkElement('#dataLocation','/Marlborough/')->
checkElement('#dataLocation','/West Coast/')->
checkElement('#dataLocation','/Canterbury/')->
checkElement('#dataLocation','/Otago/')->
checkElement('#dataLocation','/Southland/')->
checkElement('#waterTypes','/All stormwater/')->
checkElement('#waterTypes','/Untreated stormwater/')->
checkElement('#waterTypes','/Treated stormwater/')->
checkElement('#waterTypes','/Urban streams/')->
checkElement('#waterTypes','/All water types/')->
checkElement('#flowType','/Storm event/')->
checkElement('#flowType','/Baseflow/')->
end();
}
它失败了:
functional_frontend_searchActionsTest::testDataset
response selector "#compareBy" matches regex "/High-density residental/"
Failed asserting that false is true.
页面加载正常,但我不知道如何在测试中实际转储页面响应正文以调查测试看到的内容。 我试过 $browser->getContent(), $browser->getResponse(), $browser->getBody()..
这在 phpunit / Symfony2 中相当微不足道,我确定有办法做到这一点,有人可以帮忙吗?
您可以在 sfWebResponse
对象上使用 debug
方法。例如:
$browser->with('response')->debug();
您可以在legacy doc here:
签到Debugging Functional Tests
Sometimes a functional test fails. As symfony simulates a browser without any graphical interface, it can be hard to diagnose the problem. Thankfully, symfony provides the
debug()
method to output the response header and content:
$browser->with('response')->debug();
The debug() method can be inserted anywhere in a response tester block and will halt the script execution.
希望对您有所帮助