Skip to content

Commit 5732e03

Browse files
MAGETWO-63932: Add fixtures to generate admin users
- Fixtures updated for more reliability
1 parent 6bf7df1 commit 5732e03

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

setup/src/Magento/Setup/Fixtures/AdminUsersFixture.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public function execute()
3232
/** @var \Magento\Authorization\Model\RoleFactory $roleFactory */
3333
$roleFactory = $this->fixtureModel->getObjectManager()->create(\Magento\Authorization\Model\RoleFactory::class);
3434

35+
$defaultAdminUser = $adminUserFactory->create()->loadByUsername('admin');
36+
$defaultAdminRole = $roleFactory->create()->load($defaultAdminUser->getAclRole());
37+
3538
for ($i = 1; $i <= $adminUsersNumber; $i++) {
3639
$adminUser = $adminUserFactory->create();
3740
$adminUser
@@ -47,11 +50,11 @@ public function execute()
4750
$role
4851
->setUserId($adminUser->getId())
4952
->setRoleName('admin')
50-
->setRoleType('U')
51-
->setUserType(2)
52-
->setTreeLevel(2)
53-
->setSortOrder(0)
54-
->setParentId(1);
53+
->setRoleType($defaultAdminRole->getRoleType())
54+
->setUserType($defaultAdminRole->getUserType())
55+
->setTreeLevel($defaultAdminRole->getTreeLevel())
56+
->setSortOrder($defaultAdminRole->getSortOrder())
57+
->setParentId($defaultAdminRole->getParentId());
5558
$role->save();
5659
}
5760

0 commit comments

Comments
 (0)