36 protected function setUp()
38 $this->catalogLayerMock = $this->createMock(\
Magento\Catalog\Model\Layer::class);
39 $this->filterListMock = $this->createMock(\
Magento\Catalog\Model\Layer\FilterList::class);
40 $this->visibilityFlagMock = $this->createMock(\
Magento\Catalog\Model\Layer\AvailabilityFlagInterface::class);
43 $layerResolver = $this->getMockBuilder(\
Magento\Catalog\Model\Layer\Resolver::class)
44 ->disableOriginalConstructor()
45 ->setMethods([
'get',
'create'])
47 $layerResolver->expects($this->any())
48 ->method($this->anything())
49 ->will($this->returnValue($this->catalogLayerMock));
51 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
53 \
Magento\LayeredNavigation\Block\Navigation::class,
55 'layerResolver' => $layerResolver,
56 'filterList' => $this->filterListMock,
57 'visibilityFlag' => $this->visibilityFlagMock
60 $this->layoutMock = $this->createMock(\
Magento\Framework\View\LayoutInterface::class);
65 $stateHtml =
'I feel good';
66 $this->filterListMock->expects($this->any())->method(
'getFilters')->will($this->returnValue([]));
67 $this->layoutMock->expects($this->at(0))->method(
'getChildName')
69 ->will($this->returnValue(
'state block'));
71 $this->layoutMock->expects($this->once())->method(
'renderElement')
72 ->with(
'state block',
true)
73 ->will($this->returnValue($stateHtml));
75 $this->model->setLayout($this->layoutMock);
76 $this->assertEquals($stateHtml, $this->model->getStateHtml());
87 $filters = [
'To' =>
'be',
'or' =>
'not',
'to' =>
'be'];
89 $this->filterListMock->expects($this->exactly(2))->method(
'getFilters')
90 ->with($this->catalogLayerMock)
91 ->will($this->returnValue(
$filters));
92 $this->assertEquals(
$filters, $this->model->getFilters());
96 $this->visibilityFlagMock
97 ->expects($this->once())
99 ->with($this->catalogLayerMock,
$filters)
100 ->will($this->returnValue($enabled));
101 $this->assertEquals($enabled, $this->model->canShowBlock());
106 $this->filterListMock->expects($this->any())->method(
'getFilters')->will($this->returnValue([]));
107 $this->model->setLayout($this->layoutMock);
108 $this->layoutMock->expects($this->once())->method(
'getChildName')->will($this->returnValue(
'sample block'));
110 $blockMock = $this->getMockForAbstractClass(
111 \
Magento\Framework\View\Element\AbstractBlock::class,
116 $clearUrl =
'very clear URL';
117 $blockMock->setClearUrl($clearUrl);
119 $this->layoutMock->expects($this->once())->method(
'getBlock')->will($this->returnValue($blockMock));
120 $this->assertEquals($clearUrl, $this->model->getClearUrl());