storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $this->model = new Group($this->storeManagerMock); } protected function tearDown() { unset($this->storeManagerMock); } public function testGetScope() { $scopeMock = $this->createMock(\Magento\Framework\App\ScopeInterface::class); $this->storeManagerMock ->expects($this->once()) ->method('getGroup') ->with(0) ->will($this->returnValue($scopeMock)); $this->assertEquals($scopeMock, $this->model->getScope()); } /** * @expectedException \Magento\Framework\Exception\State\InitException */ public function testGetScopeWithInvalidScope() { $scopeMock = new \StdClass(); $this->storeManagerMock ->expects($this->once()) ->method('getGroup') ->with(0) ->will($this->returnValue($scopeMock)); $this->assertEquals($scopeMock, $this->model->getScope()); } }