Exemplo n.º 1
0
 protected function setUp()
 {
     $helper = new ObjectManager($this);
     $this->category = $this->getMockBuilder('Magento\\Catalog\\Model\\Category')->setMethods(['getId', '__wakeup'])->disableOriginalConstructor()->getMock();
     $this->registry = $this->getMockBuilder('Magento\\Framework\\Registry')->setMethods(['registry'])->disableOriginalConstructor()->getMock();
     $this->store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getRootCategoryId', 'getFilters', '__wakeup'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->storeManager = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->setMethods(['getStore'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->stateKeyGenerator = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\Category\\StateKey')->setMethods(['toString'])->disableOriginalConstructor()->getMock();
     $this->collectionFilter = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\Category\\CollectionFilter')->setMethods(['filter'])->disableOriginalConstructor()->getMock();
     $this->collectionProvider = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\ItemCollectionProviderInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->filter = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\Filter\\Item')->setMethods(['getFilter', 'getValueString'])->disableOriginalConstructor()->getMock();
     $this->abstractFilter = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\Filter\\AbstractFilter')->setMethods(['getRequestVar'])->disableOriginalConstructor()->getMock();
     $this->context = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\ContextInterface')->setMethods(['getStateKey', 'getCollectionFilter'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->context->expects($this->any())->method('getStateKey')->will($this->returnValue($this->stateKeyGenerator));
     $this->context->expects($this->any())->method('getCollectionFilter')->will($this->returnValue($this->collectionFilter));
     $this->context->expects($this->any())->method('getCollectionProvider')->will($this->returnValue($this->collectionProvider));
     $this->state = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\State')->disableOriginalConstructor()->getMock();
     $this->stateFactory = $this->getMockBuilder('Magento\\Catalog\\Model\\Layer\\StateFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->stateFactory->expects($this->any())->method('create')->will($this->returnValue($this->state));
     $this->collection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection')->disableOriginalConstructor()->getMock();
     $this->categoryRepository = $this->getMock('Magento\\Catalog\\Api\\CategoryRepositoryInterface');
     $this->currentCategory = $this->getMock('Magento\\Catalog\\Model\\Category', ['getId', '__wakeup'], [], '', false);
     $this->model = $helper->getObject('Magento\\Catalog\\Model\\Layer', ['registry' => $this->registry, 'storeManager' => $this->storeManager, 'context' => $this->context, 'layerStateFactory' => $this->stateFactory, 'categoryRepository' => $this->categoryRepository]);
 }
Exemplo n.º 2
0
 /**
  * Retrieve layer state object
  *
  * @return \Magento\Catalog\Model\Layer\State
  */
 public function getState()
 {
     $state = $this->getData('state');
     if (is_null($state)) {
         \Magento\Framework\Profiler::start(__METHOD__);
         $state = $this->_layerStateFactory->create();
         $this->setData('state', $state);
         \Magento\Framework\Profiler::stop(__METHOD__);
     }
     return $state;
 }