/** * @magentoDataFixture roleDataFixture */ public function testGetRole() { $this->_model->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); $role = $this->_model->getRole(); $this->assertInstanceOf('Magento\\User\\Model\\Role', $role); $this->assertEquals(1, $role->getId()); $this->_model->setRoleId(self::$_newRole->getId())->save(); $role = $this->_model->getRole(); $this->assertEquals(self::$_newRole->getId(), $role->getId()); }
/** * Associate resources with the specified role. All resources previously assigned to the role will be unassigned. * * @param Role $role * @param string[] $resources * @return void * @throws \LogicException */ protected function _associateResourcesWithRole($role, array $resources) { /** @var \Magento\User\Model\Rules $rules */ $rules = $this->_rulesFactory->create(); $rules->setRoleId($role->getId())->setResources($resources)->saveRel(); }
/** * Get role users * * @param \Magento\User\Model\Role $role * @return array */ public function getRoleUsers(\Magento\User\Model\Role $role) { $read = $this->_getReadAdapter(); $binds = array('role_id' => $role->getId(), 'role_type' => RoleUser::ROLE_TYPE); $select = $read->select()->from($this->getMainTable(), array('user_id'))->where('parent_id = :role_id')->where('role_type = :role_type')->where('user_id > 0'); return $read->fetchCol($select, $binds); }