2626namespace Test \AppFramework \Middleware ;
2727
2828use OC \AppFramework \Middleware \AdditionalScriptsMiddleware ;
29+ use OC \EventDispatcher \SymfonyAdapter ;
2930use OCP \AppFramework \Controller ;
3031use OCP \AppFramework \Http \Events \BeforeTemplateRenderedEvent ;
3132use OCP \AppFramework \Http \Response ;
3233use OCP \AppFramework \Http \StandaloneTemplateResponse ;
3334use OCP \AppFramework \Http \TemplateResponse ;
3435use OCP \AppFramework \PublicShareController ;
36+ use OCP \EventDispatcher \Event ;
3537use OCP \EventDispatcher \IEventDispatcher ;
3638use OCP \IUserSession ;
3739use PHPUnit \Framework \MockObject \MockObject ;
@@ -54,7 +56,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase {
5456 protected function setUp (): void {
5557 parent ::setUp ();
5658
57- $ this ->legacyDispatcher = $ this ->createMock (EventDispatcherInterface ::class);
59+ $ this ->legacyDispatcher = $ this ->createMock (SymfonyAdapter ::class);
5860 $ this ->userSession = $ this ->createMock (IUserSession::class);
5961 $ this ->dispatcher = $ this ->createMock (IEventDispatcher::class);
6062 $ this ->middleWare = new AdditionalScriptsMiddleware (
@@ -93,7 +95,7 @@ public function testStandaloneTemplateResponse() {
9395 ->method ('dispatch ' )
9496 ->willReturnCallback (function ($ eventName ) {
9597 if ($ eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS ) {
96- return ;
98+ return new Event () ;
9799 }
98100
99101 $ this ->fail ('Wrong event dispatched ' );
@@ -118,7 +120,7 @@ public function testTemplateResponseNotLoggedIn() {
118120 ->method ('dispatch ' )
119121 ->willReturnCallback (function ($ eventName ) {
120122 if ($ eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS ) {
121- return ;
123+ return new Event () ;
122124 }
123125
124126 $ this ->fail ('Wrong event dispatched ' );
@@ -147,7 +149,7 @@ public function testTemplateResponseLoggedIn() {
147149 if ($ eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS ||
148150 $ eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN ) {
149151 $ events [] = $ eventName ;
150- return ;
152+ return new Event () ;
151153 }
152154
153155 $ this ->fail ('Wrong event dispatched ' );
0 commit comments