customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class); $this->httpContextMock = $this->createMock(\Magento\Framework\App\Http\Context::class); $this->subjectMock = $this->createMock(\Magento\Framework\App\Action\Action::class); $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); $this->plugin = new \Magento\Customer\Model\App\Action\ContextPlugin( $this->customerSessionMock, $this->httpContextMock ); } /** * Test aroundDispatch */ public function testBeforeDispatch() { $this->customerSessionMock->expects($this->once()) ->method('getCustomerGroupId') ->will($this->returnValue(1)); $this->customerSessionMock->expects($this->once()) ->method('isLoggedIn') ->will($this->returnValue(true)); $this->httpContextMock->expects($this->atLeastOnce()) ->method('setValue') ->will( $this->returnValueMap( [ [Context::CONTEXT_GROUP, 'UAH', $this->httpContextMock], [Context::CONTEXT_AUTH, 0, $this->httpContextMock], ] ) ); $this->plugin->beforeDispatch($this->subjectMock, $this->requestMock); } }