Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
  • Loading branch information
rullzer committed Jun 1, 2018
1 parent 50f9783 commit 29c5f86
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,11 @@ public function testGetInvalidTokenById() {
}

public function testGetTokenByUser() {
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user1'));

$this->assertCount(2, $this->mapper->getTokenByUser($user));
$this->assertCount(2, $this->mapper->getTokenByUser('user1'));
}

public function testGetTokenByUserNotFound() {
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user1000'));

$this->assertCount(0, $this->mapper->getTokenByUser($user));
$this->assertCount(0, $this->mapper->getTokenByUser('user1000'));
}

public function testDeleteById() {
Expand All @@ -232,23 +220,17 @@ public function testDeleteById() {
->where($qb->expr()->eq('token', $qb->createNamedParameter('9c5a2e661482b65597408a6bb6c4a3d1af36337381872ac56e445a06cdb7fea2b1039db707545c11027a4966919918b19d875a8b774840b18c6cbb7ae56fe206')));
$result = $qb->execute();
$id = $result->fetch()['id'];
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user1'));

$this->mapper->deleteById($user, (int)$id);
$this->mapper->deleteById('user1', (int)$id);
$this->assertEquals(2, $this->getNumberOfTokens());
}

public function testDeleteByIdWrongUser() {
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock(IUser::class);
$id = 33;
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('user10000'));

$this->mapper->deleteById($user, $id);
$this->mapper->deleteById('user1000', $id);
$this->assertEquals(3, $this->getNumberOfTokens());
}

Expand Down

0 comments on commit 29c5f86

Please sign in to comment.