2012-07-03 33 views
2

我试着用硒对YII上的已认证用户运行功能测试。 我写了下面yii与认证用户的功能测试

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'); 
} 

我添加上一个bootstrap.php中ob_start(),因为头部被发送两次,并且将login.Still后冲洗它时,访问生产/请求/创建测试进入到登录页面,因为登录即使有效也不计算。编辑: 如果您在phpunit上使用--stderr选项,则不需要ob_end_flush和ob_start。

回答