About Rbac's Bussiness Rule Error

I use RBAC and create permissions and roles.

When I use checkAccess() to test a user_id, an error is occur:

d:\xampp\htdocs\trackstar\protected\tests>phpunit unit/permissionTest.php

PHPUnit 3.7.24 by Sebastian Bergmann.

Configuration read from D:\xampp\htdocs\trackstar\protected\tests\phpunit.xml


Time: 1.99 seconds, Memory: 5.00Mb

There was 1 error:

  1. PermissionTest::testCreate

Illegal string offset ‘userId’






Tests: 1, Assertions: 14, Errors: 1.

my php code :


                $this->_authManager->assign('systemManage', $user->getId());

		$projectId = 1;

		$assignmentWithProject = array('project_id' => $projectId, 'user_id' => 1, 'role' => 'systemManage');


		$result = Yii::app()->db->createCommand()

			->insert('tbl_project_user_role', $assignmentWithProject);


		$project = Project::model()->findByPk($projectId);

		$bizRulesForProject = 'return isset($project) && !empty($project) && $project->isUserInRole("member", $projectId);';

line 119:	[b]$this->assertTrue($user->checkAccess('createIssue', $bizRulesForProject, false));[/b]



class Project extends TrackstarAR




	public function isUserInRole($role, $id){

		$role = Yii::app()->db->createCommand()



			->where('id = :id AND role = :role', array(':id' => $id, ':role' => $role))



		return $role;




The code you show us doesn’t contain the line that the error refers to. The numbers match but there is no ‘userId’ key used.

Also, using bizrules for filtering role associations will be painfully slow, as it will probably be used many times in each request. You really should extend the CDbAuthManager class and change the way auth items are loaded.