/**
  * Asserts that error message equals to expected message.
  *
  * @param UserEdit $userEdit
  * @param User $user
  * @return void
  */
 public function processAssert(UserEdit $userEdit, User $user)
 {
     $email = $user->getEmail();
     $hostname = substr($email, strpos($email, '@') + 1);
     $expectedMessage = sprintf(self::ERROR_MESSAGE, $hostname, $email);
     $actualMessage = $userEdit->getMessagesBlock()->getErrorMessages();
     \PHPUnit_Framework_Assert::assertEquals($expectedMessage, $actualMessage, 'Wrong error message is displayed.' . "\nExpected: " . $expectedMessage . "\nActual: " . $actualMessage);
 }
 /**
  * Run Revoke all access tokens for admin without tokens test.
  *
  * @param User $user
  * @return void
  */
 public function test(User $user)
 {
     // Preconditions:
     $user->persist();
     // Steps:
     $this->userIndex->open();
     $this->userIndex->getUserGrid()->searchAndOpen(['username' => $user->getUsername()]);
     $this->userEdit->getPageActions()->forceSignIn();
 }
 /**
  * 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();
 }
 /**
  * @param User $user
  * @param User $adminUser
  * @param string $isDuplicated
  * @return void
  */
 public function test(User $user, User $adminUser, $isDuplicated)
 {
     // Prepare data
     if ($isDuplicated != '-') {
         $data = $user->getData();
         $data[$isDuplicated] = $adminUser->getData($isDuplicated);
         $data['role_id'] = ['role' => $user->getDataFieldConfig('role_id')['source']->getRole()];
         $user = $this->fixtureFactory->createByCode('user', ['data' => $data]);
     }
     // Steps
     $this->userIndexPage->open();
     $this->userIndexPage->getPageActions()->addNew();
     $this->userEditPage->getUserForm()->fill($user);
     $this->userEditPage->getPageActions()->save();
 }
 /**
  * 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)];
 }
 /**
  * Asserts that error message equals to expected message.
  *
  * @param UserEdit $userEdit
  * @return void
  */
 public function processAssert(UserEdit $userEdit)
 {
     $errorMessage = $userEdit->getMessagesBlock()->getErrorMessages();
     \PHPUnit_Framework_Assert::assertEquals(self::ERROR_MESSAGE, $errorMessage, 'Wrong error message is displayed.' . "\nExpected: " . self::ERROR_MESSAGE . "\nActual: " . $errorMessage);
 }
 /**
  * Assert that error message appears after click on 'Force Sing-In' button for user without tokens.
  *
  * @param UserEdit $userEdit
  * @return void
  */
 public function processAssert(UserEdit $userEdit)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::ERROR_MESSAGE, $userEdit->getMessagesBlock()->getErrorMessages());
 }