/** * testSetParentRoleId * * @return void */ public function testSetParentRoleId() { $aclRole = new AclRole(); $parentAclRole = new AclRole(); $parentAclRole->setRoleId('2222'); $aclRole->setParentRoleId(''); $this->assertNull($aclRole->getParentRoleId(), 'Role id that is set empty should be null'); $aclRole->setParentRole($parentAclRole); $this->assertEquals($parentAclRole->getRoleId(), $aclRole->getParentRoleId(), 'Parent role id not populated.'); $aclRole->setParentRoleId('3333'); $this->assertNull($aclRole->getParentRole(), 'New parent id should clear parent role object'); }
/** * 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'); }