Php 通过身份验证的用户进行yii功能测试
我正在尝试使用selenium在YII上对经过身份验证的用户运行功能测试。 我写了以下内容Php 通过身份验证的用户进行yii功能测试,php,authentication,yii,functional-testing,Php,Authentication,Yii,Functional Testing,我正在尝试使用selenium在YII上对经过身份验证的用户运行功能测试。 我写了以下内容 protected function _login(){ $id=new UserIdentity('admin','admin'); $id->authenticate(); if($id->errorCode===UserIdentity::ERROR_NONE) { Yii::app()->user->login($id);
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(),因为头被发送了两次,并且在登录后刷新了它。但是,当访问production/request/create时,测试仍然会转到登录页面,因为登录即使有效,也不会被计算
编辑:
如果在phpunit上使用--stderr选项,则不需要ob_end_flush和ob_start。这不起作用,因为您仅针对从命令行运行的会话进行身份验证。您需要对web会话进行身份验证 见此评论: