/**
  * Runs Create Admin User Role Entity test.
  *
  * @param Role $role
  */
 public function testCreateUserRole(Role $role)
 {
     //Steps
     $this->userRoleIndex->open();
     $this->userRoleIndex->getRoleActions()->addNew();
     $this->userRoleEditRole->getRoleFormTabs()->fill($role);
     $this->userRoleEditRole->getPageActions()->save();
 }
 /**
  * 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];
 }
 /**
  * Runs Lock admin user when creating new role test.
  *
  * @param Role $role
  * @param int $attempts
  * @param User $customAdmin,
  * @param string $configData
  * @return void
  */
 public function testLockAdminUser(Role $role, $attempts, User $customAdmin, $configData = null)
 {
     $this->configData = $configData;
     // Preconditions
     $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run();
     $customAdmin->persist();
     // Steps
     $this->adminAuthLogin->open();
     $this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
     $this->adminAuthLogin->getLoginBlock()->submit();
     $this->userRoleIndex->open();
     $this->userRoleIndex->getRoleActions()->addNew();
     for ($i = 0; $i < $attempts; $i++) {
         $this->userRoleEditRole->getRoleFormTabs()->fill($role);
         $this->userRoleEditRole->getPageActions()->save();
     }
     // Reload
     $this->adminAuthLogin->open();
     $this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
     $this->adminAuthLogin->getLoginBlock()->submit();
 }
 /**
  * Asserts that success delete message equals to expected message.
  *
  * @param UserRoleIndex $rolePage
  * @return void
  */
 public function processAssert(UserRoleIndex $rolePage)
 {
     $successMessage = $rolePage->getMessagesBlock()->getSuccessMessage();
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_DELETE_MESSAGE, $successMessage, 'Wrong success message is displayed.' . "\nExpected: " . self::SUCCESS_DELETE_MESSAGE . "\nActual: " . $successMessage);
 }
Пример #7
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.');
 }
 /**
  * Asserts that invalid password message equals to expected message.
  *
  * @param UserRoleIndex $rolePage
  * @return void
  */
 public function processAssert(UserRoleIndex $rolePage)
 {
     $errorMessage = $rolePage->getMessagesBlock()->getErrorMessage();
     \PHPUnit_Framework_Assert::assertEquals(self::ERROR_MESSAGE, $errorMessage, 'Wrong error message is displayed.' . "\nExpected: " . self::ERROR_MESSAGE . "\nActual: " . $errorMessage);
 }
Пример #9
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.');
 }