@@ -107,6 +107,67 @@ static function (string $eventName, array $params): void {
107107 $ this ->assertSame (['HasApi ' , 'Login ' , 'InactivePlugin ' ], $ provider ->getAllowedPlugins ());
108108 }
109109
110+ public function testGetAllowedPluginMetadataReturnsDescriptionPerAllowedPlugin (): void
111+ {
112+ $ provider = $ this ->getMockBuilder (PluginListProvider::class)
113+ ->disableOriginalConstructor ()
114+ ->onlyMethods (['getAllowedPlugins ' , 'getPluginDescription ' ])
115+ ->getMock ();
116+
117+ $ provider ->method ('getAllowedPlugins ' )
118+ ->willReturn (['Login ' , 'ActivityLog ' ]);
119+ $ provider ->method ('getPluginDescription ' )
120+ ->willReturnMap ([
121+ ['Login ' , 'Login API description ' ],
122+ ['ActivityLog ' , 'Activity log API description ' ],
123+ ]);
124+
125+ $ this ->assertSame ([
126+ 'Login ' => ['description ' => 'Login API description ' ],
127+ 'ActivityLog ' => ['description ' => 'Activity log API description ' ],
128+ ], $ provider ->getAllowedPluginMetadata ());
129+ }
130+
131+ public function testGetAllowedPluginMetadataReturnsEmptyStringWhenDescriptionMissing (): void
132+ {
133+ $ provider = $ this ->getMockBuilder (PluginListProvider::class)
134+ ->disableOriginalConstructor ()
135+ ->onlyMethods (['getAllowedPlugins ' , 'getPluginDescription ' ])
136+ ->getMock ();
137+
138+ $ provider ->method ('getAllowedPlugins ' )
139+ ->willReturn (['Login ' ]);
140+ $ provider ->method ('getPluginDescription ' )
141+ ->willReturn ('' );
142+
143+ $ this ->assertSame (['Login ' => ['description ' => '' ]], $ provider ->getAllowedPluginMetadata ());
144+ }
145+
146+ public function testGetAllowedPluginMetadataContinuesWhenOnePluginDescriptionFails (): void
147+ {
148+ $ provider = $ this ->getMockBuilder (PluginListProvider::class)
149+ ->disableOriginalConstructor ()
150+ ->onlyMethods (['getAllowedPlugins ' , 'getPluginDescription ' ])
151+ ->getMock ();
152+
153+ $ provider ->method ('getAllowedPlugins ' )
154+ ->willReturn (['Login ' , 'BrokenPlugin ' , 'ActivityLog ' ]);
155+ $ provider ->method ('getPluginDescription ' )
156+ ->willReturnCallback (static function (string $ pluginName ): string {
157+ if ($ pluginName === 'BrokenPlugin ' ) {
158+ throw new \RuntimeException ('Could not register API class ' );
159+ }
160+
161+ return $ pluginName === 'Login ' ? 'Login API description ' : 'Activity log API description ' ;
162+ });
163+
164+ $ this ->assertSame ([
165+ 'Login ' => ['description ' => 'Login API description ' ],
166+ 'BrokenPlugin ' => ['description ' => '' ],
167+ 'ActivityLog ' => ['description ' => 'Activity log API description ' ],
168+ ], $ provider ->getAllowedPluginMetadata ());
169+ }
170+
110171 /**
111172 * @param string[] $activatedPlugins
112173 * @param array<string, bool> $inFilesystemByPlugin
0 commit comments