Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
LockAdminUserWhenEditingRoleTest.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\User\Test\Page\Adminhtml\UserRoleEditRole;
9 use Magento\User\Test\Page\Adminhtml\UserRoleIndex;
10 use Magento\Mtf\TestCase\Injectable;
14 
33 class LockAdminUserWhenEditingRoleTest extends Injectable
34 {
35  /* tags */
36  const MVP = 'yes';
37  const SEVERITY = 'S2';
38  /* end tags */
39 
45  protected $userRoleIndex;
46 
52  protected $userRoleEditRole;
53 
59  protected $configData;
60 
66  protected $adminAuthLogin;
67 
76  public function __inject(
77  UserRoleIndex $userRoleIndex,
78  UserRoleEditRole $userRoleEditRole,
80  ) {
81  $this->userRoleIndex = $userRoleIndex;
82  $this->userRoleEditRole = $userRoleEditRole;
83  $this->adminAuthLogin = $adminAuthLogin;
84  }
85 
96  public function test(
97  Role $role,
98  Role $initrole,
99  $attempts,
100  User $customAdmin,
102  ) {
103  $this->configData = $configData;
104  // Preconditions
105  $this->objectManager->create(
106  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
107  ['configData' => $this->configData]
108  )->run();
109  $customAdmin->persist();
110  $initrole->persist();
111  // Steps login to backend with new user
112  $this->adminAuthLogin->open();
113  $this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
114  $this->adminAuthLogin->getLoginBlock()->submit();
115  $filter = ['rolename' => $initrole->getRolename()];
116  $this->userRoleIndex->open();
117  $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter);
118  for ($i = 0; $i < $attempts; $i++) {
119  $this->userRoleEditRole->getRoleFormTabs()->fill($role);
120  $this->userRoleEditRole->getPageActions()->save();
121  }
122  // Reload
123  $this->adminAuthLogin->open();
124  $this->adminAuthLogin->getLoginBlock()->fill($customAdmin);
125  $this->adminAuthLogin->getLoginBlock()->submit();
126  }
127 
133  public function tearDown()
134  {
135  $this->objectManager->create(
136  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
137  ['configData' => $this->configData, 'rollback' => true]
138  )->run();
139  }
140 }
__inject(UserRoleIndex $userRoleIndex, UserRoleEditRole $userRoleEditRole, AdminAuthLogin $adminAuthLogin)
test(Role $role, Role $initrole, $attempts, User $customAdmin, $configData)
$i
Definition: gallery.phtml:31