2424 */
2525class PluginListProviderTest extends TestCase
2626{
27- public function testGetPluginsForSpecGenerationIncludesPluginWhenEligible (): void
27+ public function testGetAllowedPluginsIncludesActivatedPluginWhenEligible (): void
2828 {
2929 $ provider = $ this ->makeProvider (
3030 ['HasApi ' ],
3131 ['HasApi ' => true ],
32- ['HasApi ' => true ],
3332 true
3433 );
3534
36- $ this ->assertSame (['HasApi ' ], $ provider ->getPluginsForSpecGeneration ());
35+ $ this ->assertSame (['HasApi ' ], $ provider ->getAllowedPlugins ());
3736 }
3837
39- public function testGetPluginsForSpecGenerationExcludesBlocklistedPlugin (): void
38+ public function testGetAllowedPluginsExcludesBlocklistedPlugin (): void
4039 {
4140 $ provider = $ this ->makeProvider (
4241 ['ConnectAccounts ' ],
4342 ['ConnectAccounts ' => true ],
44- ['ConnectAccounts ' => true ],
4543 true
4644 );
4745
48- $ this ->assertSame ([], $ provider ->getPluginsForSpecGeneration ());
46+ $ this ->assertSame ([], $ provider ->getAllowedPlugins ());
4947 }
5048
51- public function testGetPluginsForSpecGenerationExcludesInactivePlugin (): void
49+ public function testGetAllowedPluginsExcludesPluginNotInFilesystem (): void
5250 {
5351 $ provider = $ this ->makeProvider (
5452 ['InactivePlugin ' ],
5553 ['InactivePlugin ' => false ],
56- ['InactivePlugin ' => true ],
57- true
58- );
59-
60- $ this ->assertSame ([], $ provider ->getPluginsForSpecGeneration ());
61- }
62-
63- public function testGetPluginsForSpecGenerationExcludesPluginNotInFilesystem (): void
64- {
65- $ provider = $ this ->makeProvider (
66- ['MissingPlugin ' ],
67- ['MissingPlugin ' => true ],
68- ['MissingPlugin ' => false ],
6954 true
7055 );
7156
72- $ this ->assertSame ([], $ provider ->getPluginsForSpecGeneration ());
57+ $ this ->assertSame ([], $ provider ->getAllowedPlugins ());
7358 }
7459
75- public function testGetPluginsForSpecGenerationExcludesPluginWithoutApiFile (): void
60+ public function testGetAllowedPluginsExcludesPluginWithoutApiFile (): void
7661 {
7762 $ provider = $ this ->makeProvider (
7863 ['NoApi ' ],
7964 ['NoApi ' => true ],
80- ['NoApi ' => true ],
8165 false
8266 );
8367
84- $ this ->assertSame ([], $ provider ->getPluginsForSpecGeneration ());
68+ $ this ->assertSame ([], $ provider ->getAllowedPlugins ());
8569 }
8670
87- public function testGetPluginsForSpecGenerationAppliesEventUpdates (): void
71+ public function testGetAllowedPluginsAppliesEventUpdates (): void
8872 {
8973 $ provider = $ this ->makeProvider (
9074 ['HasApi ' , 'Login ' ],
9175 ['HasApi ' => true , 'Login ' => true ],
9276 ['HasApi ' => true , 'Login ' => true ],
93- ['HasApi ' => true , 'Login ' => true ],
9477 static function (string $ eventName , array $ params ): void {
9578 $ pluginNames = &$ params [0 ];
9679 $ pluginNames [] = 'Login ' ;
9780 }
9881 );
9982
100- $ this ->assertSame (['HasApi ' , 'Login ' ], $ provider ->getPluginsForSpecGeneration ());
83+ $ this ->assertSame (['HasApi ' , 'Login ' ], $ provider ->getAllowedPlugins ());
10184 }
10285
103- public function testGetPluginsForSpecGenerationReturnsEmptyListWhenNoPluginsInstalled (): void
86+ public function testGetAllowedPluginsReturnsEmptyListWhenNoPluginsInstalled (): void
10487 {
105- $ provider = $ this ->makeProvider ([], [], [], false );
88+ $ provider = $ this ->makeProvider ([], [], false );
10689
107- $ this ->assertSame ([], $ provider ->getPluginsForSpecGeneration ());
90+ $ this ->assertSame ([], $ provider ->getAllowedPlugins ());
10891 }
10992
110- public function testGetPluginsForSpecGenerationDropsInvalidEventUpdatesButKeepsUnactivatedInstalledPlugins (): void
93+ public function testGetAllowedPluginsDropsInvalidEventUpdatesButKeepsEventAddedPlugins (): void
11194 {
11295 $ provider = $ this ->makeProvider (
11396 ['HasApi ' , 'Login ' , 'InactivePlugin ' , 'NoApi ' , 'ConnectAccounts ' ],
114- [
115- 'HasApi ' => true ,
116- 'Login ' => true ,
117- 'InactivePlugin ' => false ,
118- 'NoApi ' => true ,
119- 'ConnectAccounts ' => true ,
120- ],
12197 [
12298 'HasApi ' => true ,
12399 'Login ' => true ,
@@ -142,32 +118,25 @@ static function (string $eventName, array $params): void {
142118 }
143119 );
144120
145- $ this ->assertSame (['HasApi ' , 'Login ' , 'InactivePlugin ' ], $ provider ->getPluginsForSpecGeneration ());
121+ $ this ->assertSame (['HasApi ' , 'Login ' , 'InactivePlugin ' ], $ provider ->getAllowedPlugins ());
146122 }
147123
148124 /**
149- * @param string[] $installedPlugins
150- * @param array<string, bool> $activatedByPlugin
125+ * @param string[] $activatedPlugins
151126 * @param array<string, bool> $inFilesystemByPlugin
152127 * @param bool|array<string, bool> $hasApiFile
153128 */
154129 private function makeProvider (
155- array $ installedPlugins ,
156- array $ activatedByPlugin ,
130+ array $ activatedPlugins ,
157131 array $ inFilesystemByPlugin ,
158132 $ hasApiFile ,
159133 ?callable $ postEventCallback = null
160134 ): PluginListProvider {
161135 $ pluginManager = $ this ->createConfiguredMock (Manager::class, [
162- 'getInstalledPluginsName ' => $ installedPlugins ,
136+ 'getActivatedPlugins ' => $ activatedPlugins ,
163137 'getPluginsLoadedAndActivated ' => [],
164138 ]);
165139
166- $ pluginManager ->method ('isPluginActivated ' )
167- ->willReturnCallback (static function (string $ pluginName ) use ($ activatedByPlugin ): bool {
168- return $ activatedByPlugin [$ pluginName ] ?? false ;
169- });
170-
171140 $ pluginManager ->method ('isPluginInFilesystem ' )
172141 ->willReturnCallback (static function (string $ pluginName ) use ($ inFilesystemByPlugin ): bool {
173142 return $ inFilesystemByPlugin [$ pluginName ] ?? false ;
0 commit comments