예제 #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]);
 }
예제 #2
0
 /**
  * @param Layer\ContextInterface $context
  * @param Layer\StateFactory $layerStateFactory
  * @param CategoryFactory $categoryFactory
  * @param Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory
  * @param Resource\Product $catalogProduct
  * @param \Magento\Framework\StoreManagerInterface $storeManager
  * @param \Magento\Framework\Registry $registry
  * @param array $data
  */
 public function __construct(\Magento\Catalog\Model\Layer\ContextInterface $context, \Magento\Catalog\Model\Layer\StateFactory $layerStateFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Catalog\Model\Resource\Product $catalogProduct, \Magento\Framework\StoreManagerInterface $storeManager, \Magento\Framework\Registry $registry, array $data = array())
 {
     $this->_layerStateFactory = $layerStateFactory;
     $this->_categoryFactory = $categoryFactory;
     $this->_attributeCollectionFactory = $attributeCollectionFactory;
     $this->_catalogProduct = $catalogProduct;
     $this->_storeManager = $storeManager;
     $this->registry = $registry;
     $this->collectionProvider = $context->getCollectionProvider();
     $this->stateKeyGenerator = $context->getStateKey();
     $this->collectionFilter = $context->getCollectionFilter();
     parent::__construct($data);
 }