/**
  * Verify incorrect credentials message while login to admin
  *
  * @param AdminAuthLogin $adminAuth
  * @param User $customAdmin
  * @return void
  */
 public function processAssert(AdminAuthLogin $adminAuth, User $customAdmin)
 {
     $adminAuth->open();
     $adminAuth->getLoginBlock()->fill($customAdmin);
     $adminAuth->getLoginBlock()->submit();
     \PHPUnit_Framework_Assert::assertEquals(self::INVALID_CREDENTIALS_MESSAGE, $adminAuth->getMessagesBlock()->getErrorMessages(), 'Message "' . self::INVALID_CREDENTIALS_MESSAGE . '" is not visible.');
 }
 /**
  * Run step flow.
  *
  * @return void
  */
 public function run()
 {
     $this->adminAuth->open();
     if ($this->dashboard->getAdminPanelHeader()->isVisible()) {
         $this->dashboard->getAdminPanelHeader()->logOut();
     }
 }
 /**
  * Run step flow.
  *
  * @return void
  */
 public function run()
 {
     $this->logoutUserOnBackendStep->run();
     $this->adminAuth->open();
     $this->adminAuth->getLoginBlock()->fill($this->user);
     $this->adminAuth->getLoginBlock()->submit();
     $this->adminAuth->getLoginBlock()->waitFormNotVisible();
 }
 /**
  * Run step flow.
  *
  * @return void
  */
 public function run()
 {
     $this->adminAuth->open();
     if (!$this->adminAuth->getLoginBlock()->isVisible()) {
         $this->logoutUserOnBackendStep->run();
     }
     $this->adminAuth->getLoginBlock()->fill($this->user);
     $this->adminAuth->getLoginBlock()->submit();
     $this->adminAuth->getLoginBlock()->waitFormNotVisible();
     $this->dashboard->getSystemMessageDialog()->closePopup();
 }
 /**
  * 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();
 }
 /**
  * Runs Delete User Entity test
  *
  * @param User $user
  * @param string $isDefaultUser
  * @return void
  */
 public function testDeleteAdminUserEntity(User $user, $isDefaultUser)
 {
     $filter = ['username' => $user->getUsername()];
     //Steps
     if ($isDefaultUser == 0) {
         $this->adminAuthLogin->open();
         $this->adminAuthLogin->getLoginBlock()->fill($user);
         $this->adminAuthLogin->getLoginBlock()->submit();
     }
     $this->userIndex->open();
     $this->userIndex->getUserGrid()->searchAndOpen($filter);
     $this->userEdit->getPageActions()->delete();
 }
 /**
  * Runs Update Admin User test.
  *
  * @param User $initialUser
  * @param User $user
  * @param string $loginAsDefaultAdmin
  * @return array
  * @throws \Exception
  */
 public function testUpdateAdminUser(User $initialUser, User $user, $loginAsDefaultAdmin)
 {
     // Precondition
     $initialUser->persist();
     // Steps
     $filter = ['username' => $initialUser->getUsername()];
     if ($loginAsDefaultAdmin == '0') {
         $this->adminAuth->open();
         $this->adminAuth->getLoginBlock()->fill($initialUser);
         $this->adminAuth->getLoginBlock()->submit();
     }
     $this->userIndex->open();
     $this->userIndex->getUserGrid()->searchAndOpen($filter);
     $this->userEdit->getUserForm()->fill($user);
     $this->userEdit->getPageActions()->save();
     return ['user' => $this->mergeUsers($initialUser, $user)];
 }
 /**
  * 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];
 }
 /**
  * Run Lock user when creating new integration test.
  *
  * @param Integration $integration
  * @param int $attempts
  * @param User $customAdmin
  * @param string $configData
  * @return void
  */
 public function test(Integration $integration, $attempts, User $customAdmin, $configData = null)
 {
     $this->configData = $configData;
     // Preconditions
     $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run();
     $customAdmin->persist();
     $this->adminAuthLogin->open();
     $this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
     $this->adminAuthLogin->getLoginBlock()->submit();
     // Steps
     $this->integrationIndexPage->open();
     $this->integrationIndexPage->getGridPageActions()->addNew();
     for ($i = 0; $i < $attempts; $i++) {
         $this->integrationNewPage->getIntegrationForm()->fill($integration);
         $this->integrationNewPage->getFormPageActions()->saveNew();
     }
     // Reload page
     $this->adminAuthLogin->open();
     $this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
     $this->adminAuthLogin->getLoginBlock()->submit();
 }
 /**
  * Open backend system config.
  * Save default configuration value.
  * Set new configuration value.
  * Reopen backend system config.
  *
  * @param SystemConfigEdit $systemConfigEdit
  * @param ConfigData $sessionLifetimeConfig
  * @param AdminAuthLogin $adminAuthLogin
  * @return void
  */
 public function test(SystemConfigEdit $systemConfigEdit, ConfigData $sessionLifetimeConfig, AdminAuthLogin $adminAuthLogin)
 {
     $this->systemConfigEdit = $systemConfigEdit;
     $this->sessionLifetimeConfig = $sessionLifetimeConfig;
     $this->systemConfigEdit->open();
     $section = $sessionLifetimeConfig->getSection();
     $keys = array_keys($section);
     $parts = explode('/', $keys[0], 3);
     $tabName = $parts[0];
     $groupName = $parts[1];
     $fieldName = $parts[2];
     $this->oldValue = $this->systemConfigEdit->getForm()->getGroup($tabName, $groupName)->getValue($tabName, $groupName, $fieldName);
     $this->systemConfigEdit->getForm()->getGroup($tabName, $groupName)->setValue($tabName, $groupName, $fieldName, $section[$keys[0]]['label']);
     $this->systemConfigEdit->getPageActions()->save();
     $this->systemConfigEdit->getMessagesBlock()->waitSuccessMessage();
     /**
      * Wait admin session to expire.
      */
     sleep($section[$keys[0]]['label']);
     $adminAuthLogin->open();
 }
 /**
  * Run step flow.
  *
  * @return void
  */
 public function run()
 {
     $this->adminAuth->open();
     $this->dashboard->getSystemMessageDialog()->closePopup();
     $this->dashboard->getAdminPanelHeader()->logOut();
 }