Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StateKeyTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Catalog\Model\Layer\Category\StateKey;
10 
11 class StateKeyTest extends \PHPUnit\Framework\TestCase
12 {
16  protected $storeManagerMock;
17 
22 
26  protected $model;
27 
28  protected function setUp()
29  {
30  $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
31  $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class);
32  $this->model = new StateKey($this->storeManagerMock, $this->customerSessionMock);
33  }
34 
39  public function testToString()
40  {
41  $categoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
42  $categoryMock->expects($this->once())->method('getId')->will($this->returnValue('1'));
43 
44  $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
45  $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
46  $storeMock->expects($this->once())->method('getId')->will($this->returnValue('2'));
47 
48  $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('3'));
49 
50  $this->assertEquals('STORE_2_CAT_1_CUSTGROUP_3', $this->model->toString($categoryMock));
51  }
52 }