Chapter 8 Unit Test Failure

I am currently trying to pass the testUserAccessBasedOnProjectRole, but phpunit returns the error:

Failed asserting that false is true

… apparently on line 96.

Here is the code for the function, which as far as I can tell, mirrors the text correctly:

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->assertFalse(Yii::app()->user->checkAccess('updateProject',$params));


}

I also checked the database and everything appears to be correct. User 2 is assigned to Project 2 as a member, the bizrule is in the AuthAssignment table, readIssue is assigned to reader in AuthItemChild, updateIssue to member, and updateProject to owner.

I can’t see any reason why the test would fail the assertion.

Which line is #96? I’m not sure what is failing here. I am on the same function, but I am getting


CException: Unknown authorization item "member"

I suspect that I am supposed to have entries in those databases that were set up- probably when running the yiic shell RbacCommand script, but they are empty. I’m not even sure what they should contain.

I am having the same issue. Has this been solved?