]> source.dussan.org Git - nextcloud-server.git/commitdiff
adjust SettingsController tests
authorArtur Neumann <artur@jankaritech.com>
Tue, 22 Nov 2022 06:30:28 +0000 (12:15 +0545)
committerArtur Neumann <artur@jankaritech.com>
Fri, 19 May 2023 06:17:06 +0000 (12:02 +0545)
Signed-off-by: Artur Neumann <artur@jankaritech.com>
apps/oauth2/tests/Controller/SettingsControllerTest.php

index 6be8a4ee4b98334adcf0195bd49436a571d4cc20..b11c59fd414920ff24153e5d4bb6d75eb674d2b2 100644 (file)
@@ -27,7 +27,7 @@
 namespace OCA\OAuth2\Tests\Controller;
 
 use OC\Authentication\Token\IToken;
-use OC\Authentication\Token\IProvider as IAuthTokenProvider;
+use OCP\Authentication\Token\IProvider as IAuthTokenProvider;
 use OCA\OAuth2\Controller\SettingsController;
 use OCA\OAuth2\Db\AccessTokenMapper;
 use OCA\OAuth2\Db\Client;
@@ -133,24 +133,13 @@ class SettingsControllerTest extends TestCase {
                };
                $userManager->callForAllUsers($function);
                $user1 = $userManager->createUser('test101', 'test101');
-               $tokenMocks[0] = $this->getMockBuilder(IToken::class)->getMock();
-               $tokenMocks[0]->method('getName')->willReturn('Firefox session');
-               $tokenMocks[0]->method('getId')->willReturn(1);
-               $tokenMocks[1] = $this->getMockBuilder(IToken::class)->getMock();
-               $tokenMocks[1]->method('getName')->willReturn('My Client Name');
-               $tokenMocks[1]->method('getId')->willReturn(2);
-               $tokenMocks[2] = $this->getMockBuilder(IToken::class)->getMock();
-               $tokenMocks[2]->method('getName')->willReturn('mobile client');
-               $tokenMocks[2]->method('getId')->willReturn(3);
-
                $tokenProviderMock = $this->getMockBuilder(IAuthTokenProvider::class)->getMock();
-               $tokenProviderMock->method('getTokenByUser')->willReturn($tokenMocks);
 
-               // expect one call per user and make sure the correct tokeId is selected
+               // expect one call per user and ensure the correct client name
                $tokenProviderMock
                        ->expects($this->exactly($count + 1))
-                       ->method('invalidateTokenById')
-                       ->with($this->isType('string'), 2);
+                       ->method('invalidateTokensOfUser')
+                       ->with($this->isType('string'), 'My Client Name');
 
                $client = new Client();
                $client->setId(123);
@@ -168,6 +157,7 @@ class SettingsControllerTest extends TestCase {
                        ->method('deleteByClientId')
                        ->with(123);
                $this->clientMapper
+                       ->expects($this->once())
                        ->method('delete')
                        ->with($client);