[英]Symfony 1.4 : functional test for authenticated and unauthenticated users
我正在使用 Propel ORM 為 symfony 1.4.19 網站編寫一些功能測試。 我的一些頁面顯示不同,這取決於用戶是否登錄(經過身份驗證)。
我一直在看在線文檔,看看如何實現:
但是,我似乎找不到任何顯示如何執行此操作的內容。
登錄:
$username = 'root';
$password = 'root';
$browser->
post('/login', array('signin' => array('username' => $username, 'password' => $password)))->
with('request')->begin()->
isParameter('module', 'sfGuardAuth')->
isParameter('action', 'signin')->
end()->
with('response')->begin()->
isStatusCode(302)->
isRedirected()->
end()->
followRedirect()
;
登出:
$browser->
get('/logout')->
with('request')->begin()->
isParameter('module', 'sfGuardAuth')->
isParameter('action', 'signout')->
end()->
with('response')->begin()->
isStatusCode(302)->
isRedirected()->
end()->
followRedirect()
;
// this will reset session
$browser->restart();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.