Beispiel #1
0
 /**
  * testSetGet
  *
  * @covers \RcmUser\Acl\Entity\AclRole
  *
  * @return void
  */
 public function testSetGet()
 {
     $aclRole = new AclRole();
     $parentAclRole = new AclRole('ppp');
     $parentAclRole->setRoleId('ppp');
     $role = 'testrole';
     $prole = 'parenttestrole';
     $desc = 'Descript';
     $aclRole->setRoleId($role);
     $aclRole->setParentRoleId($prole);
     $aclRole->setDescription($desc);
     $this->assertTrue($aclRole->getRoleId() === $role, 'Setter or getter failed.');
     $this->assertTrue($aclRole->getRoleId() === $role, 'Setter or getter failed.');
     $this->assertTrue($aclRole->getParentRoleId() === $prole, 'Setter or getter failed.');
     $this->assertTrue($aclRole->getParent() === $prole, 'Setter or getter failed.');
     $this->assertTrue($aclRole->getDescription() === $desc, 'Setter or getter failed.');
     $aclRole->setParentRole($parentAclRole);
     $this->assertTrue($aclRole->getParent() === $parentAclRole, 'Setter or getter failed.');
 }
Beispiel #2
0
 /**
  * populate
  *
  * @param array|AclRole $data data to populate with
  *
  * @return void
  * @throws RcmUserException
  */
 public function populate($data = [])
 {
     if ($data instanceof AclRole) {
         $this->setRoleId($data->getRoleId());
         $this->setDescription($data->getDescription());
         $this->setParentRoleId($data->getParentRoleId());
         $parentRole = $data->getParentRole();
         if (!empty($parentRole)) {
             $this->setParentRole($parentRole);
         }
         return;
     }
     if (is_array($data)) {
         if (isset($data['roleId'])) {
             $this->setRoleId($data['roleId']);
         }
         if (isset($data['description'])) {
             $this->setDescription($data['description']);
         }
         if (isset($data['parentRoleId'])) {
             $this->setParentRoleId($data['parentRoleId']);
         }
         if (isset($data['parentRole'])) {
             $this->setParentRoleId($data['parentRole']);
         }
         return;
     }
     throw new RcmUserException('Role data could not be populated, data format not supported');
 }