@@ -53,6 +53,7 @@ public function testHandleDoesNotRegisterIfPermissionOrCapabilitiesMissing() {
5353 $ event = $ this ->createMock (RegisterTemplateCreatorEvent::class);
5454 $ event ->method ('getTemplateManager ' )->willReturn ($ this ->templateManager );
5555 $ this ->permissionManager ->method ('isEnabledForUser ' )->willReturn (false );
56+ $ this ->permissionManager ->method ('userCanEdit ' )->willReturn (true );
5657 $ this ->capabilitiesService ->method ('getCapabilities ' )->willReturn ([]);
5758
5859 $ listener = new RegisterTemplateFileCreatorListener (
@@ -70,6 +71,7 @@ public function testHandleRegistersTemplateFileCreators() {
7071 $ event = $ this ->createMock (RegisterTemplateCreatorEvent::class);
7172 $ event ->method ('getTemplateManager ' )->willReturn ($ this ->templateManager );
7273 $ this ->permissionManager ->method ('isEnabledForUser ' )->willReturn (true );
74+ $ this ->permissionManager ->method ('userCanEdit ' )->willReturn (true );
7375 $ this ->capabilitiesService ->method ('getCapabilities ' )->willReturn (['something ' ]);
7476 $ this ->capabilitiesService ->method ('hasDrawSupport ' )->willReturn (true );
7577 $ this ->config ->method ('getAppValue ' )->willReturn ('ooxml ' );
@@ -91,6 +93,7 @@ public function testHandleRegistersWithoutDrawSupport() {
9193 $ event = $ this ->createMock (RegisterTemplateCreatorEvent::class);
9294 $ event ->method ('getTemplateManager ' )->willReturn ($ this ->templateManager );
9395 $ this ->permissionManager ->method ('isEnabledForUser ' )->willReturn (true );
96+ $ this ->permissionManager ->method ('userCanEdit ' )->willReturn (true );
9497 $ this ->capabilitiesService ->method ('getCapabilities ' )->willReturn (['something ' ]);
9598 $ this ->capabilitiesService ->method ('hasDrawSupport ' )->willReturn (false );
9699 $ this ->config ->method ('getAppValue ' )->willReturn ('ooxml ' );
@@ -107,4 +110,22 @@ public function testHandleRegistersWithoutDrawSupport() {
107110 );
108111 $ listener ->handle ($ event );
109112 }
113+
114+ public function testHandleDoesNotRegisterIfUserCannotEdit () {
115+ $ event = $ this ->createMock (RegisterTemplateCreatorEvent::class);
116+ $ event ->method ('getTemplateManager ' )->willReturn ($ this ->templateManager );
117+ $ this ->permissionManager ->method ('isEnabledForUser ' )->willReturn (true );
118+ $ this ->permissionManager ->method ('userCanEdit ' )->willReturn (false );
119+ $ this ->capabilitiesService ->method ('getCapabilities ' )->willReturn (['something ' ]);
120+
121+ $ listener = new RegisterTemplateFileCreatorListener (
122+ $ this ->l10n ,
123+ $ this ->config ,
124+ $ this ->appManager ,
125+ $ this ->capabilitiesService ,
126+ $ this ->permissionManager
127+ );
128+ $ this ->templateManager ->expects ($ this ->never ())->method ('registerTemplateFileCreator ' );
129+ $ listener ->handle ($ event );
130+ }
110131}
0 commit comments