Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UnlockAdminUserTest.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Mtf\Fixture\FixtureFactory;
12 use Magento\Mtf\TestCase\Injectable;
13 use Magento\Mtf\TestStep\TestStepFactory;
15 use Magento\User\Test\Page\Adminhtml\UserLocks;
16 
31 class UnlockAdminUserTest extends Injectable
32 {
33  /* tags */
34  const MVP = 'no';
35  /* end tags */
36 
42  protected $testStepFactory;
43 
49  protected $adminAuth;
50 
56  protected $userLocks;
57 
63  protected $fixtureFactory;
64 
70  protected $configData;
71 
81  public function __inject(
82  TestStepFactory $testStepFactory,
84  FixtureFactory $fixtureFactory,
85  UserLocks $userLocks
86  ) {
87  $this->testStepFactory = $testStepFactory;
88  $this->adminAuth = $adminAuth;
89  $this->fixtureFactory = $fixtureFactory;
90  $this->userLocks = $userLocks;
91  }
92 
103  public function test(
104  User $customAdmin,
105  $incorrectPassword,
106  $attempts,
107  $configData,
109  ) {
110  // Preconditions
111  $this->configData = $configData;
112  $config->persist();
113  $this->testStepFactory->create(
114  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
115  ['configData' => $configData]
116  )->run();
117  $customAdmin->persist();
119  $incorrectUser = $this->fixtureFactory->createByCode(
120  'user',
121  ['data' => ['username' => $customAdmin->getUsername(), 'password' => $incorrectPassword]]
122  );
123  for ($i = 0; $i < $attempts; $i++) {
124  $this->adminAuth->open();
125  $this->adminAuth->getLoginBlock()->fill($incorrectUser);
126  $this->adminAuth->getLoginBlock()->submit();
127  }
128 
129  // Test steps
130  $this->userLocks->open();
131  $this->userLocks->getLockedUsersGrid()->massaction([['username' => $customAdmin->getUsername()]], 'Unlock');
132 
133  return ['user' => $customAdmin];
134  }
135 
141  public function tearDown()
142  {
143  $this->testStepFactory->create(
144  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
145  ['configData' => $this->configData, 'rollback' => true]
146  )->run();
147  }
148 }
$config
Definition: fraud_order.php:17
__inject(TestStepFactory $testStepFactory, AdminAuthLogin $adminAuth, FixtureFactory $fixtureFactory, UserLocks $userLocks)
$i
Definition: gallery.phtml:31