Esempio n. 1
0
 /**
  * @construct
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataSet']) && $data['dataSet'] !== '-') {
         $this->role = $fixtureFactory->createByCode('adminUserRole', ['dataSet' => $data['dataSet']]);
         if (!$this->role->hasData('role_id')) {
             $this->role->persist();
         }
         $this->data = $this->role->getRoleName();
     }
     if (isset($data['role']) && $data['role'] instanceof AdminUserRole) {
         $this->role = $data['role'];
         $this->data = $data['role']->getRoleName();
     }
 }
Esempio n. 2
0
 /**
  * Asserts that role is not present in Role Grid.
  *
  * @param UserRoleIndex $rolePage
  * @param AdminUserRole $role
  * @return void
  */
 public function processAssert(UserRoleIndex $rolePage, AdminUserRole $role)
 {
     $filter = ['rolename' => $role->getRoleName()];
     $rolePage->open();
     \PHPUnit_Framework_Assert::assertFalse($rolePage->getRoleGrid()->isRowVisible($filter), 'Role with name \'' . $role->getRoleName() . '\' is present in Roles grid.');
 }
 /**
  * Runs Delete User Role Entity test.
  *
  * @param AdminUserRole $role
  * @param User $adminUser
  * @param string $isDefaultUser
  * @return void
  */
 public function testDeleteAdminUserRole(AdminUserRole $role, User $adminUser, $isDefaultUser)
 {
     $filter = ['rolename' => $role->getRoleName()];
     //Steps
     if ($isDefaultUser == 0) {
         $this->adminAuthLogin->open();
         $this->adminAuthLogin->getLoginBlock()->fill($adminUser);
         $this->adminAuthLogin->getLoginBlock()->submit();
     }
     $this->userRoleIndex->open();
     $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter);
     $this->userRoleEditRole->getPageActions()->delete();
 }
Esempio n. 4
0
 /**
  * Asserts that saved role is present in Role Grid.
  *
  * @param UserRoleIndex $rolePage
  * @param AdminUserRole $role
  * @param AdminUserRole $roleInit
  * @return void
  */
 public function processAssert(UserRoleIndex $rolePage, AdminUserRole $role, AdminUserRole $roleInit = null)
 {
     $filter = ['rolename' => $role->hasData('rolename') ? $role->getRoleName() : $roleInit->getRoleName()];
     $rolePage->open();
     \PHPUnit_Framework_Assert::assertTrue($rolePage->getRoleGrid()->isRowVisible($filter), 'Role with name \'' . $filter['rolename'] . '\' is absent in Roles grid.');
 }
 /**
  * Runs Update Admin User Roles Entity test
  *
  * @param AdminUserRole $roleInit
  * @param AdminUserRole $role
  * @param User $user
  * @return array
  */
 public function testUpdateAdminUserRolesEntity(AdminUserRole $roleInit, AdminUserRole $role, User $user)
 {
     // Preconditions
     $roleInit->persist();
     if (!$user->hasData('user_id')) {
         $user->persist();
     }
     // Steps
     $filter = ['rolename' => $roleInit->getRoleName()];
     $this->adminAuthLogin->open();
     $this->adminAuthLogin->getLoginBlock()->fill($user);
     $this->adminAuthLogin->getLoginBlock()->submit();
     $this->rolePage->open();
     $this->rolePage->getRoleGrid()->searchAndOpen($filter);
     $this->userRoleEditRole->getRoleFormTabs()->fill($role);
     $this->userRoleEditRole->getPageActions()->save();
     return ['customAdmin' => $role->hasData('in_role_users') ? $role->getDataFieldConfig('in_role_users')['source']->getAdminUsers()[0] : $user];
 }