36 $this->layoutMock = $this->createPartialMock(\
Magento\Framework\View\Layout::class, [
'createBlock']);
38 $this->swatchHelperMock = $this->createPartialMock(\
Magento\Swatches\Helper\Data::class, [
'isSwatchAttribute']);
40 $this->blockMock = $this->createPartialMock(
41 \
Magento\Swatches\Block\LayeredNavigation\RenderLayered::class,
42 [
'setSwatchFilter',
'toHtml']
45 $this->filterMock = $this->createPartialMock(
46 \
Magento\Catalog\Model\Layer\Filter\AbstractFilter::class,
47 [
'getAttributeModel',
'hasAttributeModel']
50 $this->filterRendererMock = $this->createMock(
51 \
Magento\LayeredNavigation\Block\Navigation\FilterRenderer::class
54 $this->closureMock =
function () {
58 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
60 \
Magento\Swatches\Model\Plugin\FilterRenderer::class,
62 'layout' => $this->layoutMock,
63 'swatchHelper' => $this->swatchHelperMock
71 $this->filterMock->expects($this->atLeastOnce())->method(
'getAttributeModel')->willReturn($attributeMock);
72 $this->filterMock->expects($this->once())->method(
'hasAttributeModel')->willReturn(
true);
73 $this->swatchHelperMock
74 ->expects($this->once())
75 ->method(
'isSwatchAttribute')
76 ->with($attributeMock)
79 $this->layoutMock->expects($this->once())->method(
'createBlock')->willReturn($this->blockMock);
80 $this->blockMock->expects($this->once())->method(
'setSwatchFilter')->will($this->returnSelf());
82 $this->plugin->aroundRender($this->filterRendererMock, $this->closureMock, $this->filterMock);
88 $this->filterMock->expects($this->atLeastOnce())->method(
'getAttributeModel')->willReturn($attributeMock);
89 $this->filterMock->expects($this->once())->method(
'hasAttributeModel')->willReturn(
true);
90 $this->swatchHelperMock
91 ->expects($this->once())
92 ->method(
'isSwatchAttribute')
93 ->with($attributeMock)
96 $result = $this->plugin->aroundRender($this->filterRendererMock, $this->closureMock, $this->filterMock);
97 $this->assertEquals(
$result, $this->filterMock);