![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-store/Test/Unit/App/Action/Plugin/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Store\Test\Unit\App\Action\Plugin; use Magento\Framework\App\Action\AbstractAction; use Magento\Framework\Exception\State\InitException; use Magento\Store\App\Action\Plugin\StoreCheck; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class StoreCheckTest extends TestCase { /** * @var StoreCheck */ protected $_plugin; /** * @var StoreManagerInterface|MockObject */ protected $_storeManagerMock; /** * @var Store|MockObject */ protected $_storeMock; /** * @var AbstractAction|MockObject */ protected $subjectMock; protected function setUp(): void { $this->_storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class); $this->_storeMock = $this->createMock(Store::class); $this->_storeManagerMock->expects( $this->any() )->method( 'getStore' )->willReturn( $this->_storeMock ); $this->subjectMock = $this->getMockBuilder(AbstractAction::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->_plugin = new StoreCheck($this->_storeManagerMock); } public function testBeforeExecuteWhenStoreNotActive() { $this->expectException(InitException::class); $this->expectExceptionMessage('Current store is not active.'); $this->_storeMock->expects($this->any())->method('isActive')->willReturn(false); $this->_plugin->beforeExecute($this->subjectMock); } public function testBeforeExecuteWhenStoreIsActive() { $this->_storeMock->expects($this->any())->method('isActive')->willReturn(true); $result = $this->_plugin->beforeExecute($this->subjectMock); $this->assertNull($result); } }