protected function setUp()
 {
     $this->_category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Category');
     $this->_category->load(5);
     $layer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Layer\\Category', ['data' => ['current_category' => $this->_category]]);
     $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\CatalogSearch\\Model\\Layer\\Filter\\Category', ['layer' => $layer]);
     $this->_model->setRequestVar('cat');
 }
Example #2
0
 public function testApply()
 {
     $categoryId = 123;
     $requestVar = 'test_request_var';
     $this->target->setRequestVar($requestVar);
     $this->request->expects($this->exactly(2))->method('getParam')->will($this->returnCallback(function ($field) use($requestVar, $categoryId) {
         $this->assertTrue(in_array($field, [$requestVar, 'id']));
         return $categoryId;
     }));
     $this->dataProvider->expects($this->once())->method('setCategoryId')->with($categoryId)->will($this->returnSelf());
     $this->category->expects($this->once())->method('getId')->will($this->returnValue($categoryId));
     $this->fulltextCollection->expects($this->once())->method('addCategoryFilter')->with($this->category)->will($this->returnSelf());
     $this->target->apply($this->request);
 }