Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdatePasswordUserEntityPciRequirementsTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Backend\Test\Page\Adminhtml\Dashboard;
11 use Magento\Mtf\Fixture\FixtureFactory;
12 use Magento\Mtf\TestCase\Injectable;
14 use Magento\User\Test\Page\Adminhtml\UserEdit;
15 
32 {
38  protected $userEdit;
39 
45  protected $dashboard;
46 
52  protected $adminAuth;
53 
59  protected $fixtureFactory;
60 
70  public function __inject(
71  UserEdit $userEdit,
72  Dashboard $dashboard,
74  FixtureFactory $fixtureFactory
75  ) {
76  $this->userEdit = $userEdit;
77  $this->dashboard = $dashboard;
78  $this->adminAuth = $adminAuth;
79  $this->fixtureFactory = $fixtureFactory;
80  }
81 
89  public function test(
90  User $user,
91  array $passwords
92  ) {
93  // Preconditions
94  $user->persist();
95  $initialPassword = $user->getPassword();
96  $currentPassword = $user->getPassword();
97  $passwords[] = $initialPassword;
98 
99  // Steps
100  $this->adminAuth->open();
101  $this->adminAuth->getLoginBlock()->fill($user);
102  $this->adminAuth->getLoginBlock()->submit();
103 
104  foreach ($passwords as $password) {
105  $data = [
106  'password' => $password,
107  'password_confirmation' => $password,
108  'current_password' => $currentPassword,
109 
110  ];
111  $updatedUser = $this->fixtureFactory->createByCode('user', ['data' => $data]);
112 
113  $this->userEdit->open(['user_id' => $user->getUserId()]);
114  $this->userEdit->getUserForm()->fill($updatedUser);
115  $this->userEdit->getPageActions()->save();
116  $currentPassword = $password;
117  }
118  }
119 
125  public function tearDown()
126  {
127  if ($this->dashboard->getAdminPanelHeader()->isVisible()) {
128  $this->dashboard->getAdminPanelHeader()->logOut();
129  }
130  }
131 }
$user
Definition: dummy_user.php:13
__inject(UserEdit $userEdit, Dashboard $dashboard, AdminAuthLogin $adminAuth, FixtureFactory $fixtureFactory)