/** * @covers OpsWay\TocatUser\Entity\User::getRoles * @covers OpsWay\TocatUser\Entity\User::addRole * @covers OpsWay\TocatUser\Entity\User::updateRoles * @covers OpsWay\TocatUser\Entity\User::removeRoles */ public function testRoles() { // Setup two different roles $role = new Role(); $role2 = new Role(); $role2->setId(2); $role2->setRoleId('fake'); $role2->setParent($role); //Check what current user don't contain any roles $this->assertCount(0, $this->user->getRoles()); //Check count roles after add one roles $this->user->addRole($role); $this->assertCount(1, $this->user->getRoles()); //Check equal one role in list user roles foreach ($this->user->getRoles() as $row) { $this->assertEquals($role, $row); } //Check not equal two role2 in list user roles foreach ($this->user->getRoles() as $row) { $this->assertNotEquals($role2, $row); } //Check same inverted after updating roles $this->user->updateRoles(array($role2)); foreach ($this->user->getRoles() as $row) { $this->assertEquals($role2, $row); } foreach ($this->user->getRoles() as $row) { $this->assertNotEquals($role, $row); } //Check what removing deleting right role $this->user->removeRoles(array($role)); $this->assertCount(1, $this->user->getRoles()); $this->user->removeRoles(array($role2)); $this->assertCount(0, $this->user->getRoles()); }
public function testGetPermission() { $this->assertCount(0, $this->role->getPermissions()); }