protected function prepareData()
 {
     User::reset();
     $rule = new AuthorRule();
     $this->auth->add($rule);
     $uniqueTrait = $this->auth->createPermission('Fast Metabolism');
     $uniqueTrait->description = 'Your metabolic rate is twice normal. This means that you are much less resistant to radiation and poison, but your body heals faster.';
     $this->auth->add($uniqueTrait);
     $createPost = $this->auth->createPermission('createPost');
     $createPost->description = 'create a post';
     $this->auth->add($createPost);
     $readPost = $this->auth->createPermission('readPost');
     $readPost->description = 'read a post';
     $this->auth->add($readPost);
     $deletePost = $this->auth->createPermission('deletePost');
     $deletePost->description = 'delete a post';
     $this->auth->add($deletePost);
     $updatePost = $this->auth->createPermission('updatePost');
     $updatePost->description = 'update a post';
     $updatePost->ruleName = $rule->name;
     $this->auth->add($updatePost);
     $updateAnyPost = $this->auth->createPermission('updateAnyPost');
     $updateAnyPost->description = 'update any post';
     $this->auth->add($updateAnyPost);
     $reader = $this->auth->createRole('reader');
     $this->auth->add($reader);
     $this->auth->addChild($reader, $readPost);
     $author = $this->auth->createRole('author');
     $this->auth->add($author);
     $this->auth->addChild($author, $createPost);
     $this->auth->addChild($author, $updatePost);
     $this->auth->addChild($author, $reader);
     $admin = $this->auth->createRole('admin');
     $this->auth->add($admin);
     $this->auth->addChild($admin, $author);
     $this->auth->addChild($admin, $updateAnyPost);
     $this->auth->assign($uniqueTrait, 'reader A');
     $this->auth->assign($reader, 'reader A');
     $this->auth->assign($author, 'author B');
     $this->auth->assign($deletePost, 'author B');
     $this->auth->assign($admin, 'admin C');
 }
 public function testSaveAssignments()
 {
     $this->auth->removeAll();
     $role = $this->auth->createRole('Admin');
     $this->auth->add($role);
     $this->auth->assign($role, 13);
     $this->assertContains('Admin', User::findAuthRoleIdentity(13)->getAuthRoleNames());
     $role->name = 'NewAdmin';
     $this->auth->update('Admin', $role);
     $this->assertContains('NewAdmin', User::findAuthRoleIdentity(13)->getAuthRoleNames());
     $this->auth->remove($role);
     $this->assertNotContains('NewAdmin', User::findAuthRoleIdentity(13)->getAuthRoleNames());
 }