I am tryinng to run a functional test with an authenticated user on YII with selenium.
I wrote the following
protected function _login(){
$id=new UserIdentity('admin','admin');
$id->authenticate();
if($id->errorCode===UserIdentity::ERROR_NONE)
{
Yii::app()->user->login($id);
return true;
}
return false;
}
public function testSpot(){
$this->assertTrue($this->_login());
ob_end_flush();
$this->open('production/request/create');
}
I added an ob_start() on bootstrap.php because the header were being sent twice and flushed it after the login.Still the test when access production/request/create goes to the login page, because the login is not computed even though it’s valid.
EDIT:
the ob_end_flush and ob_start is not needed if you use –stderr option on phpunit.
This wont work because you are only authenticating against the session that is running from the command line. You need to authenticate the web session.
See this comment:
http://www.yiiframework.com/doc/guide/1.1/en/test.functional#c10015