]> source.dussan.org Git - nextcloud-server.git/commitdiff
Adds tests for the AuthSettingsController
authorRoeland Jago Douma <roeland@famdouma.nl>
Fri, 11 Nov 2016 10:35:11 +0000 (11:35 +0100)
committerRobin Appelman <robin@icewind.nl>
Wed, 16 Nov 2016 14:24:31 +0000 (15:24 +0100)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
tests/Settings/Controller/AuthSettingsControllerTest.php

index 339c698bcbb3ca30695d241720e84860731c8e04..782c9f644e0b4ac1b8307773f1fc8d3028350e09 100644 (file)
@@ -42,6 +42,7 @@ class AuthSettingsControllerTest extends TestCase {
        /** @var AuthSettingsController */
        private $controller;
        private $request;
+       /** @var IProvider|\PHPUnit_Framework_MockObject_MockObject */
        private $tokenProvider;
        private $userManager;
        private $session;
@@ -200,4 +201,26 @@ class AuthSettingsControllerTest extends TestCase {
                $this->assertEquals([], $this->controller->destroy($id));
        }
 
+       public function testUpdateToken() {
+               $token = $this->createMock(DefaultToken::class);
+
+               $this->tokenProvider->expects($this->once())
+                       ->method('getTokenById')
+                       ->with($this->equalTo(42))
+                       ->willReturn($token);
+
+               $token->expects($this->once())
+                       ->method('setScope')
+                       ->with($this->equalTo([
+                               'filesystem' => true,
+                               'app' => ['dav', 'myapp']
+                       ]));
+
+               $this->tokenProvider->expects($this->once())
+                       ->method('updateToken')
+                       ->with($this->equalTo($token));
+
+               $this->assertSame([], $this->controller->update(42, ['filesystem' => true, 'apps' => ['dav', 'myapp']]));
+       }
+
 }