Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StoreCheckTest.php
Go to the documentation of this file.
1 <?php
7 
8 class StoreCheckTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_plugin;
14 
18  protected $_storeManagerMock;
19 
23  protected $_storeMock;
24 
28  protected $subjectMock;
29 
33  protected $requestMock;
34 
35  protected function setUp()
36  {
37  $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
38  $this->_storeMock = $this->createMock(\Magento\Store\Model\Store::class);
39  $this->_storeManagerMock->expects(
40  $this->any()
41  )->method(
42  'getStore'
43  )->will(
44  $this->returnValue($this->_storeMock)
45  );
46  $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class);
47  $this->subjectMock = $this->getMockBuilder(\Magento\Framework\App\Action\AbstractAction::class)
48  ->disableOriginalConstructor()
49  ->getMockForAbstractClass();
50 
51  $this->_plugin = new \Magento\Store\App\Action\Plugin\StoreCheck($this->_storeManagerMock);
52  }
53 
59  {
60  $this->_storeMock->expects($this->any())->method('isActive')->will($this->returnValue(false));
61  $this->_plugin->beforeDispatch($this->subjectMock, $this->requestMock);
62  }
63 
65  {
66  $this->_storeMock->expects($this->any())->method('isActive')->will($this->returnValue(true));
67  $result = $this->_plugin->beforeDispatch($this->subjectMock, $this->requestMock);
68  $this->assertNull($result);
69  }
70 }