I was getting this error, whenever I ran the php unit, can someone please point the thing
that I was missing here ? ( I don’t really understand what the error is trying to say. I get the same error
even after I truncated those tables at the bottom and re-run the test file
ProjectTest unit test code
<?php
class ProjectTest extends CDbTestCase
{
public $fixtures = array(
'projects' => 'Project',
'users' => 'User',
'projUsrAssign' => ':tbl_project_user_assignment',
'projUserRole' => ':tbl_project_user_role',
'authAssign' => ':AuthAssignment',
);
public function testGetUserOptions()
{
$project = $this->projects('project1');
$options = $project->userOptions;
$this->assertTrue(is_array($options));
$this->assertTrue(count($options) > 0);
}
public function testUserRoleAssignment()
{
$project = $this->projects('project1');
$user = $this->users('user1');
$this->assertEquals(1,$project->associateUserToRole('owner',$user->id));
$this->assertEquals(1,$project->removeUserFromRole('owner',$user->id));
}
public function testIsInRole()
{
$row1 = $this->projUserRole['row1'];
Yii::app()->user->setId($row1['user_id']);
$project = Project::model()->findByPk($row1['project_id']);
$this->assertTrue($project->isUserInRole('member'));
}
public function testUserAccessBasedOnProjectRole()
{
$row1 = $this->projUserRole['row1'];
Yii::app()->user->setId($row1['user_id']);
$project = Project::model()->findByPk($row1['project_id']);
$auth = Yii::app()->authManager;
$bizRule = 'return isset($params["project"]) && $params["project"]->isUserInRole("member");';
$auth->assign('member', $row1['user_id'],$bizRule);
$params=array('project'=>$project);
$this->assertTrue(Yii::app()->user->checkAccess('updateIssue',$params));
$this->assertTrue(Yii::app()->user->checkAccess('readIssue',$params));
$this->assertTrue(Yii::app()->user->checkAccess('updateProject', $params));
$project = Project::model()->findByPk(1);
$params = array('project'=>$project);
$this->assertFalse(Yii::app()->user->checkAccess('updateIssue',$params));
$this->assertFalse(Yii::app()->user->checkAccess('readIssue', $params));
$this->assertFalse(Yii::app()->user->checkAccess('updateProject', $params));
}
}
AuthAssignment table
tbl_project_user_role