How do you: Symfony functional test on a secure app?
- by Dan Tudor
Im trying to perform some function tests in symfony 1.4. My application is secure so the tests return 401 response codes not 200 as expected. I've tried creating a context and authentication the user prior to performing the test but to no avail. Any suggestions?
Do I need to pass sfContext to the sfTestFunctional?
Thanks
include(dirname(FILE).'/../../bootstrap/functional.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('backend', 'test', true);
$context = sfContext::createInstance($configuration);
new sfDatabaseManager($configuration);
$loader = new sfPropelData();
$loader-loadData(sfConfig::get('sf_test_dir').'/fixtures'); // load test data
$user = sfGuardUserPeer::retrieveByUsername('test');
$context-getUser()-signin($user);
$browser = new sfTestFunctional(new sfBrowser());
$browser-
get('/')-
with('request')-begin()-
isParameter('module', 'video')-
isParameter('action', 'index')-
end()-
with('response')-begin()-
isStatusCode(200)-
//checkElement('body', '!/This is a temporary page/')-
end()
;