diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-05-29 09:29:29 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-06-18 22:11:54 +0200 |
commit | 4c0d7104792cb89b8bc013c08b9c9fcb63dcf0da (patch) | |
tree | 2f23ee511ab06b17128ab123765bac93c9b82ef1 /tests | |
parent | 1f17010e0b4099b41cc72f53e18f4d162ce2e3da (diff) | |
download | nextcloud-server-4c0d7104792cb89b8bc013c08b9c9fcb63dcf0da.tar.gz nextcloud-server-4c0d7104792cb89b8bc013c08b9c9fcb63dcf0da.zip |
Just pass uid to the Token stuff
We don't have user objects in the code everywhere
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Settings/Controller/AuthSettingsControllerTest.php | 12 | ||||
-rw-r--r-- | tests/lib/Authentication/Token/DefaultTokenMapperTest.php | 28 |
2 files changed, 6 insertions, 34 deletions
diff --git a/tests/Settings/Controller/AuthSettingsControllerTest.php b/tests/Settings/Controller/AuthSettingsControllerTest.php index 461b32b7a48..1c957299e39 100644 --- a/tests/Settings/Controller/AuthSettingsControllerTest.php +++ b/tests/Settings/Controller/AuthSettingsControllerTest.php @@ -75,13 +75,9 @@ class AuthSettingsControllerTest extends TestCase { $sessionToken = new DefaultToken(); $sessionToken->setId(100); - $this->userManager->expects($this->once()) - ->method('get') - ->with($this->uid) - ->will($this->returnValue($this->user)); $this->tokenProvider->expects($this->once()) ->method('getTokenByUser') - ->with($this->user) + ->with($this->uid) ->will($this->returnValue($tokens)); $this->session->expects($this->once()) ->method('getId') @@ -192,13 +188,9 @@ class AuthSettingsControllerTest extends TestCase { $id = 123; $user = $this->createMock(IUser::class); - $this->userManager->expects($this->once()) - ->method('get') - ->with($this->uid) - ->will($this->returnValue($user)); $this->tokenProvider->expects($this->once()) ->method('invalidateTokenById') - ->with($user, $id); + ->with($this->uid, $id); $this->assertEquals([], $this->controller->destroy($id)); } diff --git a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php index b5d24a7ab5e..ab09c005297 100644 --- a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php @@ -190,23 +190,11 @@ class DefaultTokenMapperTest extends TestCase { } 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() { @@ -218,23 +206,15 @@ class DefaultTokenMapperTest extends TestCase { ->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, $id); + $this->mapper->deleteById('user1', $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()); } |