Skip to content

Commit ae0ab69

Browse files
committed
Cover changes with unit test
1 parent 88da782 commit ae0ab69

File tree

1 file changed

+42
-2
lines changed
  • app/code/Magento/Catalog/Test/Unit/Controller/Category

1 file changed

+42
-2
lines changed

app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ protected function setUp()
178178
);
179179
}
180180

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
182188
{
183189
$categoryId = 123;
184190
$pageLayout = 'page_layout';
@@ -199,11 +205,45 @@ public function testApplyCustomLayoutUpdate()
199205
\Magento\Framework\DataObject::class,
200206
['getPageLayout', 'getLayoutUpdates']
201207
);
208+
$this->expectationForPageLayoutHandles($expectedData);
202209
$settings->expects($this->atLeastOnce())->method('getPageLayout')->will($this->returnValue($pageLayout));
203210
$settings->expects($this->once())->method('getLayoutUpdates')->willReturn(['update1', 'update2']);
204-
205211
$this->catalogDesign->expects($this->any())->method('getDesignSettings')->will($this->returnValue($settings));
206212

207213
$this->action->execute();
208214
}
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+
}
209249
}

0 commit comments

Comments
 (0)