Skip to content

Commit

Permalink
EZP-29574: [Tests] Fixed randomly failing testLoadUserByToken
Browse files Browse the repository at this point in the history
For more details see https://issues.ibexa.co/browse/EZP-29574 and #382

* Moved `UserServiceTest::testLoadUserByTokenThrowsNotFoundException` after tests depending on `testLoadUserByToken`

* Removed unnecessary `updateUserToken` operation causing side-effects.
  • Loading branch information
mateuszdebinski authored Aug 8, 2023
1 parent 5251385 commit e7cebd1
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions eZ/Publish/API/Repository/Tests/UserServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2971,29 +2971,6 @@ public function testLoadUserByToken()
return $userTokenUpdateStruct->hashKey;
}

/**
* Test trying to load User by invalid Token.
*
* @covers \eZ\Publish\API\Repository\UserService::loadUserByToken
*/
public function testLoadUserByTokenThrowsNotFoundException()
{
$this->expectException(NotFoundException::class);

$repository = $this->getRepository();
$userService = $repository->getUserService();

$user = $this->createUserVersion1();

$userTokenUpdateStruct = new UserTokenUpdateStruct();
$userTokenUpdateStruct->hashKey = md5('hash');
$userTokenUpdateStruct->time = new DateTime();

$userService->updateUserToken($user, $userTokenUpdateStruct);

$userService->loadUserByToken('not_existing_token');
}

/**
* Test updating User Token.
*
Expand Down Expand Up @@ -3045,6 +3022,20 @@ public function testExpireUserToken($userToken)
$userService->loadUserByToken($userToken);
}

/**
* Test trying to load User by invalid Token.
*
* @covers \eZ\Publish\API\Repository\UserService::loadUserByToken
*/
public function testLoadUserByTokenThrowsNotFoundException(): void
{
$repository = $this->getRepository();
$userService = $repository->getUserService();

$this->expectException(NotFoundException::class);
$userService->loadUserByToken('not_existing_token');
}

/**
* @covers \eZ\Publish\API\Repository\UserService::validatePassword()
*/
Expand Down

0 comments on commit e7cebd1

Please sign in to comment.