@@ -178,7 +178,13 @@ protected function setUp()
178
178
);
179
179
}
180
180
181
- public function testApplyCustomLayoutUpdate ()
181
+ /**
182
+ * Apply custom layout update is correct
183
+ *
184
+ * @dataProvider getInvokationData
185
+ * @return void
186
+ */
187
+ public function testApplyCustomLayoutUpdate (array $ expectedData ): void
182
188
{
183
189
$ categoryId = 123 ;
184
190
$ pageLayout = 'page_layout ' ;
@@ -199,11 +205,45 @@ public function testApplyCustomLayoutUpdate()
199
205
\Magento \Framework \DataObject::class,
200
206
['getPageLayout ' , 'getLayoutUpdates ' ]
201
207
);
208
+ $ this ->expectationForPageLayoutHandles ($ expectedData );
202
209
$ settings ->expects ($ this ->atLeastOnce ())->method ('getPageLayout ' )->will ($ this ->returnValue ($ pageLayout ));
203
210
$ settings ->expects ($ this ->once ())->method ('getLayoutUpdates ' )->willReturn (['update1 ' , 'update2 ' ]);
204
-
205
211
$ this ->catalogDesign ->expects ($ this ->any ())->method ('getDesignSettings ' )->will ($ this ->returnValue ($ settings ));
206
212
207
213
$ this ->action ->execute ();
208
214
}
215
+
216
+ /**
217
+ * Expected invocation for Layout Handles
218
+ *
219
+ * @param array $data
220
+ * @return void
221
+ */
222
+ private function expectationForPageLayoutHandles ($ data ): void
223
+ {
224
+ $ index = 2 ;
225
+ foreach ($ data as $ expectedData ) {
226
+ $ this ->page ->expects ($ this ->at ($ index ))
227
+ ->method ('addPageLayoutHandles ' )
228
+ ->with ($ expectedData [0 ], $ expectedData [1 ], $ expectedData [2 ]);
229
+ $ index ++;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Data provider for execute method.
235
+ *
236
+ * @return array
237
+ */
238
+ public function getInvokationData (): array
239
+ {
240
+ return [
241
+ [
242
+ 'layoutHandles ' => [
243
+ [['type ' => 'default_without_children ' ], null , false ],
244
+ [['displaymode ' => '' ], null , false ]
245
+ ]
246
+ ]
247
+ ];
248
+ }
209
249
}
0 commit comments