@@ -50,6 +50,7 @@ public function testHandleDoesNotRegisterIfPermissionOrCapabilitiesMissing() {
5050 $ event = $ this ->createMock (RegisterTemplateCreatorEvent::class);
5151 $ event ->method ('getTemplateManager ' )->willReturn ($ this ->templateManager );
5252 $ this ->permissionManager ->method ('isEnabledForUser ' )->willReturn (false );
53+ $ this ->permissionManager ->method ('userCanEdit ' )->willReturn (true );
5354 $ this ->capabilitiesService ->method ('getCapabilities ' )->willReturn ([]);
5455
5556 $ listener = new RegisterTemplateFileCreatorListener (
@@ -67,6 +68,7 @@ public function testHandleRegistersTemplateFileCreators() {
6768 $ event = $ this ->createMock (RegisterTemplateCreatorEvent::class);
6869 $ event ->method ('getTemplateManager ' )->willReturn ($ this ->templateManager );
6970 $ this ->permissionManager ->method ('isEnabledForUser ' )->willReturn (true );
71+ $ this ->permissionManager ->method ('userCanEdit ' )->willReturn (true );
7072 $ this ->capabilitiesService ->method ('getCapabilities ' )->willReturn (['something ' ]);
7173 $ this ->capabilitiesService ->method ('hasDrawSupport ' )->willReturn (true );
7274 $ this ->config ->method ('getAppValue ' )->willReturn ('ooxml ' );
@@ -88,6 +90,7 @@ public function testHandleRegistersWithoutDrawSupport() {
8890 $ event = $ this ->createMock (RegisterTemplateCreatorEvent::class);
8991 $ event ->method ('getTemplateManager ' )->willReturn ($ this ->templateManager );
9092 $ this ->permissionManager ->method ('isEnabledForUser ' )->willReturn (true );
93+ $ this ->permissionManager ->method ('userCanEdit ' )->willReturn (true );
9194 $ this ->capabilitiesService ->method ('getCapabilities ' )->willReturn (['something ' ]);
9295 $ this ->capabilitiesService ->method ('hasDrawSupport ' )->willReturn (false );
9396 $ this ->config ->method ('getAppValue ' )->willReturn ('ooxml ' );
@@ -104,4 +107,22 @@ public function testHandleRegistersWithoutDrawSupport() {
104107 );
105108 $ listener ->handle ($ event );
106109 }
110+
111+ public function testHandleDoesNotRegisterIfUserCannotEdit () {
112+ $ event = $ this ->createMock (RegisterTemplateCreatorEvent::class);
113+ $ event ->method ('getTemplateManager ' )->willReturn ($ this ->templateManager );
114+ $ this ->permissionManager ->method ('isEnabledForUser ' )->willReturn (true );
115+ $ this ->permissionManager ->method ('userCanEdit ' )->willReturn (false );
116+ $ this ->capabilitiesService ->method ('getCapabilities ' )->willReturn (['something ' ]);
117+
118+ $ listener = new RegisterTemplateFileCreatorListener (
119+ $ this ->l10n ,
120+ $ this ->config ,
121+ $ this ->appManager ,
122+ $ this ->capabilitiesService ,
123+ $ this ->permissionManager
124+ );
125+ $ this ->templateManager ->expects ($ this ->never ())->method ('registerTemplateFileCreator ' );
126+ $ listener ->handle ($ event );
127+ }
107128}
0 commit comments