52 $this->request = $this->getMockBuilder(\
Magento\Framework\
App\RequestInterface::class)
53 ->disableOriginalConstructor()
54 ->setMethods([
'getParam'])
55 ->getMockForAbstractClass();
57 $dataProviderFactory = $this->getMockBuilder(
59 )->disableOriginalConstructor()->setMethods([
'create'])->getMock();
61 $this->dataProvider = $this->getMockBuilder(\
Magento\Catalog\Model\Layer\Filter\
DataProvider\Category::class)
62 ->disableOriginalConstructor()
63 ->setMethods([
'setCategoryId',
'getCategory'])
66 $dataProviderFactory->expects($this->once())
68 ->will($this->returnValue($this->dataProvider));
70 $this->category = $this->getMockBuilder(\
Magento\Catalog\Model\Category::class)
71 ->disableOriginalConstructor()
72 ->setMethods([
'getId',
'getChildrenCategories',
'getIsActive'])
75 $this->dataProvider->expects($this->any())
76 ->method(
'getCategory',
'isValid')
77 ->will($this->returnValue($this->category));
79 $this->layer = $this->getMockBuilder(\
Magento\Catalog\Model\Layer::class)
80 ->disableOriginalConstructor()
81 ->setMethods([
'getState',
'getProductCollection'])
84 $this->fulltextCollection = $this->fulltextCollection = $this->getMockBuilder(
87 ->disableOriginalConstructor()
88 ->setMethods([
'addCategoryFilter',
'getFacetedData',
'getSize'])
91 $this->layer->expects($this->any())
92 ->method(
'getProductCollection')
93 ->will($this->returnValue($this->fulltextCollection));
95 $this->itemDataBuilder = $this->getMockBuilder(\
Magento\Catalog\Model\Layer\Filter\Item\DataBuilder::class)
96 ->disableOriginalConstructor()
97 ->setMethods([
'addItemData',
'build'])
100 $this->filterItemFactory = $this->getMockBuilder(
101 \
Magento\Catalog\Model\Layer\Filter\ItemFactory::class
103 ->disableOriginalConstructor()
104 ->setMethods([
'create'])
107 $filterItem = $this->getMockBuilder(
108 \
Magento\Catalog\Model\Layer\Filter\Item::class
110 ->disableOriginalConstructor()
111 ->setMethods([
'setFilter',
'setLabel',
'setValue',
'setCount'])
113 $filterItem->expects($this->any())
114 ->method($this->anything())
115 ->will($this->returnSelf());
116 $this->filterItemFactory->expects($this->any())
118 ->will($this->returnValue($filterItem));
120 $escaper = $this->getMockBuilder(\
Magento\Framework\Escaper::class)
121 ->disableOriginalConstructor()
122 ->setMethods([
'escapeHtml'])
124 $escaper->expects($this->any())
125 ->method(
'escapeHtml')
126 ->will($this->returnArgument(0));
128 $objectManagerHelper =
new ObjectManagerHelper($this);
129 $this->target = $objectManagerHelper->getObject(
130 \
Magento\CatalogSearch\Model\Layer\Filter\Category::class,
132 'categoryDataProviderFactory' => $dataProviderFactory,
133 'layer' => $this->layer,
134 'itemDataBuilder' => $this->itemDataBuilder,
135 'filterItemFactory' => $this->filterItemFactory,
136 'escaper' => $escaper,