@@ -23,7 +23,14 @@ class PluginListGeneratorTest extends TestCase
23
23
/**
24
24
* Generated plugin list config for frontend scope
25
25
*/
26
- const CACHE_ID = 'primary|global|frontend|plugin-list ' ;
26
+ const CACHE_ID_FRONTEND = 'primary|global|frontend|plugin-list ' ;
27
+
28
+ /**
29
+ * Generated plugin list config for dummy scope
30
+ */
31
+ const CACHE_ID_DUMMY = 'primary|global|dummy|plugin-list ' ;
32
+
33
+ private $ cacheIds = [self ::CACHE_ID_FRONTEND , self ::CACHE_ID_DUMMY ];
27
34
28
35
/**
29
36
* @var PluginListGenerator
@@ -90,31 +97,51 @@ protected function setUp(): void
90
97
*/
91
98
public function testPluginListConfigGeneration ()
92
99
{
93
- $ scopes = ['frontend ' ];
100
+ $ scopes = ['global ' , 'frontend ' , 'dummy ' ];
101
+ $ globalPlugin = 'genericHeaderPlugin ' ;
102
+ $ frontendPlugin = 'response-http-page-cache ' ;
94
103
$ this ->model ->write ($ scopes );
95
- $ configData = $ this ->model ->load (self ::CACHE_ID );
96
- $ this ->assertNotEmpty ($ configData [0 ]);
97
- $ this ->assertNotEmpty ($ configData [1 ]);
98
- $ this ->assertNotEmpty ($ configData [2 ]);
99
- $ expected = [
104
+ $ configDataFrontend = $ this ->model ->load (self ::CACHE_ID_FRONTEND );
105
+ $ this ->assertNotEmpty ($ configDataFrontend [0 ]);
106
+ $ this ->assertNotEmpty ($ configDataFrontend [1 ]);
107
+ $ this ->assertNotEmpty ($ configDataFrontend [2 ]);
108
+ $ expectedFrontend = [
100
109
1 => [
101
- 0 => ' genericHeaderPlugin ' ,
102
- 1 => ' response-http-page-cache '
110
+ 0 => $ globalPlugin ,
111
+ 1 => $ frontendPlugin
103
112
]
104
113
];
105
114
// Here in test is assumed that this class below has 3 plugins. But the amount of plugins and class itself
106
115
// may vary. If it is changed, please update these assertions.
107
116
$ this ->assertArrayHasKey (
108
117
'Magento \\Framework \\App \\Response \\Http_sendResponse___self ' ,
109
- $ configData [2 ],
118
+ $ configDataFrontend [2 ],
110
119
'Processed plugin does not exist in the processed plugins array. '
111
120
);
112
121
113
122
$ this ->assertSame (
114
- $ expected ,
115
- $ configData [2 ]['Magento \\Framework \\App \\Response \\Http_sendResponse___self ' ],
123
+ $ expectedFrontend ,
124
+ $ configDataFrontend [2 ]['Magento \\Framework \\App \\Response \\Http_sendResponse___self ' ],
116
125
'Plugin configurations are not equal '
117
126
);
127
+
128
+ $ configDataDummy = $ this ->model ->load (self ::CACHE_ID_DUMMY );
129
+ /**
130
+ * Make sure "dummy" scope with no plugins in system should not contain plugins from "frontend" scope
131
+ */
132
+ $ this ->assertNotContains (
133
+ $ frontendPlugin ,
134
+ $ configDataDummy [2 ]['Magento \\Framework \\App \\Response \\Http_sendResponse___self ' ][1 ],
135
+ 'Plugin configurations are not equal. "dummy" scope should not contain plugins from "frontend" scope '
136
+ );
137
+ /**
138
+ * Make sure "dummy" scope with no plugins in system should contain plugins from "global" scope
139
+ */
140
+ $ this ->assertContains (
141
+ $ globalPlugin ,
142
+ $ configDataDummy [2 ]['Magento \\Framework \\App \\Response \\Http_sendResponse___self ' ][1 ],
143
+ 'Plugin configurations are not equal. "dummy" scope should contain plugins from "global" scope '
144
+ );
118
145
}
119
146
120
147
/**
@@ -137,11 +164,13 @@ private function getCustomDirs(): array
137
164
*/
138
165
protected function tearDown (): void
139
166
{
140
- $ filePath = $ this ->directoryList ->getPath (DirectoryList::GENERATED_METADATA )
141
- . '/ ' . self ::CACHE_ID . '. ' . 'php ' ;
167
+ foreach ($ this ->cacheIds as $ cacheId ) {
168
+ $ filePath = $ this ->directoryList ->getPath (DirectoryList::GENERATED_METADATA )
169
+ . '/ ' . $ cacheId . '. ' . 'php ' ;
142
170
143
- if (file_exists ($ filePath )) {
144
- $ this ->file ->deleteFile ($ filePath );
171
+ if (file_exists ($ filePath )) {
172
+ $ this ->file ->deleteFile ($ filePath );
173
+ }
145
174
}
146
175
}
147
176
}
0 commit comments