/**
  * @covers \Magento\Catalog\Model\Layer\Category\StateKey::toString
  * @covers \Magento\Catalog\Model\Layer\Category\StateKey::__construct
  */
 public function testToString()
 {
     $categoryMock = $this->getMock('\\Magento\\Catalog\\Model\\Category', [], [], '', false);
     $categoryMock->expects($this->once())->method('getId')->will($this->returnValue('1'));
     $storeMock = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
     $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
     $storeMock->expects($this->once())->method('getId')->will($this->returnValue('2'));
     $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('3'));
     $this->assertEquals('STORE_2_CAT_1_CUSTGROUP_3', $this->model->toString($categoryMock));
 }
Example #2
0
 /**
  * Get layer state key
  *
  * @return string
  */
 public function getStateKey()
 {
     if (!$this->_stateKey) {
         $this->_stateKey = $this->stateKeyGenerator->toString($this->getCurrentCategory());
     }
     return $this->_stateKey;
 }
 public function testApply()
 {
     $stateKey = 'sk';
     $this->registry->expects($this->once())->method('registry')->with($this->equalTo('current_category'))->will($this->returnValue($this->category));
     $this->stateKeyGenerator->expects($this->once())->method('toString')->with($this->equalTo($this->category))->will($this->returnValue($stateKey));
     $this->state->expects($this->any())->method('getFilters')->will($this->returnValue([$this->filter]));
     $this->filter->expects($this->once())->method('getFilter')->will($this->returnValue($this->abstractFilter));
     $this->filter->expects($this->once())->method('getValueString')->will($this->returnValue('t'));
     $this->abstractFilter->expects($this->once())->method('getRequestVar')->will($this->returnValue('t'));
     $result = $this->model->apply();
     $this->assertInstanceOf('\\Magento\\Catalog\\Model\\Layer', $result);
 }
Example #4
0
 /**
  * @param \Magento\Catalog\Model\Category $category
  * @return string|void
  */
 public function toString($category)
 {
     return 'Q_' . $this->queryFactory->get()->getId() . '_' . \Magento\Catalog\Model\Layer\Category\StateKey::toString($category);
 }
Example #5
0
 /**
  * @param \Magento\Catalog\Model\Category $category
  * @return string|void
  */
 public function toString($category)
 {
     return 'Q_' . $this->helper->getQuery()->getId() . '_' . parent::toString($category);
 }