/** * @param int $idUser * * @return array */ public function getData($idUser) { $userTransfer = $this->userFacade->getUserById($idUser); $formData = $userTransfer->toArray(); $formData = $this->populateSelectedAclGroups($idUser, $formData); if (array_key_exists(UserForm::FIELD_PASSWORD, $formData)) { unset($formData[UserForm::FIELD_PASSWORD]); } return $formData; }
/** * @return void */ public function testPermissionsWithSystemUserShouldNotAllow() { $systemUsers = $this->userFacade->getSystemUsers(); $this->assertInstanceOf('\\Generated\\Shared\\Transfer\\CollectionTransfer', $systemUsers); foreach ($systemUsers as $user) { $this->assertInstanceOf('\\Generated\\Shared\\Transfer\\UserTransfer', $user); $hasAccess = $this->facade->checkAccess($user, rand(100, 999), rand(100, 999), rand(100, 999)); $this->assertEquals(false, $hasAccess); $hasAccess = $this->facade->checkAccess($user, rand(100, 999), rand(100, 999), rand(100, 999)); $this->assertEquals(false, $hasAccess); } }
/** * @return void */ public function testCheckDoLoginAndCurrentUserIsTheSame() { $userData = $this->mockUserData(); $userDto = $this->mockAddUser($userData); $this->assertInstanceOf('\\Generated\\Shared\\Transfer\\UserTransfer', $userDto); $this->assertNotEquals($userData['password'], $userDto->getPassword()); $login = $this->authFacade->login($userDto->getUsername(), $userData['password']); $this->assertTrue($login); $currentUserDto = $this->userFacade->getCurrentUser(); $this->assertInstanceOf('\\Generated\\Shared\\Transfer\\UserTransfer', $currentUserDto); $this->assertEquals($userDto->getIdUser(), $currentUserDto->getIdUser()); $this->assertEquals($userDto->getUsername(), $currentUserDto->getUsername()); $this->assertEquals($userDto->getPassword(), $currentUserDto->getPassword()); $this->assertEquals($userDto->getFirstName(), $currentUserDto->getFirstName()); $this->assertEquals($userDto->getLastName(), $currentUserDto->getLastName()); }
/** * @return void */ public function testIsValidPassword() { $data = $this->mockUserData(); $user = $this->mockAddUser($data); $this->assertTrue($this->userFacade->isValidPassword($data['password'], $user->getPassword())); }