public function testChangePassword() { $newPassword = '******'; $apiUser = new ApiUser('username', 'password'); $apiUser->generateHash(); $apiUser->changePassword($newPassword); $this->assertTrue($apiUser->isActive()); $this->assertEquals($apiUser->getPassword(), $newPassword); }
/** * @param \Diamante\UserBundle\Api\Command\CreateDiamanteUserCommand $command * * @return int */ public function createDiamanteUser(CreateDiamanteUserCommand $command) { $user = $this->diamanteUserRepository->findUserByEmail($command->email); if (!is_null($user)) { if (true === $user->isDeleted()) { $this->restoreUser($user); return $user->getId(); } else { throw new DiamanteUserExistsException('An account with this email address already exists'); } } $user = $this->factory->create($command->email, $command->firstName, $command->lastName); $apiUser = new ApiUserEntity($command->email, static::generateRandomSequence(16), static::generateRandomSequence(64), $user); $apiUser->generateHash(); $user->setDeleted(false); $user->setApiUser($apiUser); $apiUser->setDiamanteUser($user); $this->eventDispatcher->dispatch('user.notification', new UserEvent('created', $user)); $this->diamanteUserRepository->store($user); return $user->getId(); }