/**
  * Runs Delete User Role Entity test.
  *
  * @param AdminUserRole $role
  * @param User $adminUser
  * @param string $isDefaultUser
  * @return void
  */
 public function testDeleteAdminUserRole(AdminUserRole $role, User $adminUser, $isDefaultUser)
 {
     $filter = ['rolename' => $role->getRoleName()];
     //Steps
     if ($isDefaultUser == 0) {
         $this->adminAuthLogin->open();
         $this->adminAuthLogin->getLoginBlock()->fill($adminUser);
         $this->adminAuthLogin->getLoginBlock()->submit();
     }
     $this->userRoleIndex->open();
     $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter);
     $this->userRoleEditRole->getPageActions()->delete();
 }
 /**
  * @param Role $role
  * @param Role $updatedRole
  * @param User $user
  * @return void
  */
 public function testLoginAfterChangingPermissions(Role $role, Role $updatedRole, User $user)
 {
     /** Create role and a new user with this role */
     $role->persist();
     /** @var User $user */
     $user = $this->fixtureFactory->create('Magento\\User\\Test\\Fixture\\User', ['data' => array_merge($user->getData(), ['role_id' => ['role' => $role]])]);
     $user->persist();
     /** Change the scope of resources available for the role created earlier */
     $filter = ['rolename' => $role->getRoleName()];
     $this->userRoleIndex->open();
     $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter);
     $this->userRoleEditRole->getRoleFormTabs()->fill($updatedRole);
     $this->userRoleEditRole->getPageActions()->save();
     $this->dashboard->getAdminPanelHeader()->logOut();
 }
 /**
  * Runs Update Admin User Roles Entity test
  *
  * @param Role $roleInit
  * @param Role $role
  * @param User $user
  * @return array
  */
 public function testUpdateAdminUserRolesEntity(Role $roleInit, Role $role, User $user)
 {
     // Preconditions
     $roleInit->persist();
     if (!$user->hasData('user_id')) {
         $user->persist();
     }
     // Steps
     $filter = ['rolename' => $roleInit->getRoleName()];
     $this->adminAuthLogin->open();
     $this->adminAuthLogin->getLoginBlock()->fill($user);
     $this->adminAuthLogin->getLoginBlock()->submit();
     $this->rolePage->open();
     $this->rolePage->getRoleGrid()->searchAndOpen($filter);
     $this->userRoleEditRole->getRoleFormTabs()->fill($role);
     $this->userRoleEditRole->getPageActions()->save();
     return ['user' => $role->hasData('in_role_users') ? $role->getDataFieldConfig('in_role_users')['source']->getAdminUsers()[0] : $user];
 }
Example #4
0
 /**
  * Asserts that role is not present in Role Grid.
  *
  * @param UserRoleIndex $rolePage
  * @param AdminUserRole $role
  * @return void
  */
 public function processAssert(UserRoleIndex $rolePage, AdminUserRole $role)
 {
     $filter = ['rolename' => $role->getRoleName()];
     $rolePage->open();
     \PHPUnit_Framework_Assert::assertFalse($rolePage->getRoleGrid()->isRowVisible($filter), 'Role with name \'' . $role->getRoleName() . '\' is present in Roles grid.');
 }
Example #5
0
 /**
  * Asserts that saved role is present in Role Grid.
  *
  * @param UserRoleIndex $rolePage
  * @param AdminUserRole $role
  * @param AdminUserRole $roleInit
  * @return void
  */
 public function processAssert(UserRoleIndex $rolePage, AdminUserRole $role, AdminUserRole $roleInit = null)
 {
     $filter = ['rolename' => $role->hasData('rolename') ? $role->getRoleName() : $roleInit->getRoleName()];
     $rolePage->open();
     \PHPUnit_Framework_Assert::assertTrue($rolePage->getRoleGrid()->isRowVisible($filter), 'Role with name \'' . $filter['rolename'] . '\' is absent in Roles grid.');
 }