File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 33
44use OCA \Solid \DpopFactoryTrait ;
55use OCA \Solid \ServerConfig ;
6+ use OCA \Solid \Service \UserService ;
67
78use OCP \AppFramework \Controller ;
89use OCP \AppFramework \Http ;
@@ -47,6 +48,8 @@ class ServerController extends Controller
4748 /* @var \Pdsinterop\Solid\Auth\TokenGenerator */
4849 private $ tokenGenerator ;
4950
51+ private UserService $ userService ;
52+
5053 public function __construct (
5154 $ AppName ,
5255 IRequest $ request ,
@@ -55,7 +58,7 @@ public function __construct(
5558 IURLGenerator $ urlGenerator ,
5659 $ userId ,
5760 IConfig $ config ,
58- \ OCA \ Solid \ Service \ UserService $ UserService ,
61+ UserService $ userService ,
5962 IDBConnection $ connection ,
6063 ) {
6164 parent ::__construct ($ AppName , $ request );
@@ -66,6 +69,7 @@ public function __construct(
6669 $ this ->request = $ request ;
6770 $ this ->urlGenerator = $ urlGenerator ;
6871 $ this ->session = $ session ;
72+ $ this ->userService = $ userService ;
6973
7074 $ this ->setJtiStorage ($ connection );
7175
Original file line number Diff line number Diff line change @@ -450,6 +450,29 @@ public function testToken()
450450 $ this ->assertEquals ($ expected , $ actual );
451451 }
452452
453+ /**
454+ * @testdox ServerController should return an OK when asked to logout
455+ *
456+ * @covers ::logout
457+ */
458+ public function testLogout () {
459+ $ parameters = $ this ->createMockConstructorParameters ();
460+ $ index = self ::provideConstructorParameterIndex ();
461+ $ mockUserService = $ parameters [$ index ['userService ' ][0 ]];
462+
463+ $ mockUserService ->expects ($ this ->once ())
464+ ->method ('logout ' )
465+ ->willReturn (null )
466+ ;
467+
468+ $ controller = new ServerController (...array_values ($ parameters ));
469+
470+ $ actual = $ controller ->logout ();
471+ $ expected = new JSONResponse ('ok ' , Http::STATUS_OK );
472+
473+ $ this ->assertEquals ($ expected , $ actual );
474+ }
475+
453476 ////////////////////////////// MOCKS AND STUBS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
454477
455478 public function createMockConfig ($ clientData ): IConfig |MockObject
You can’t perform that action at this time.
0 commit comments