protected function setUp() { $this->_session = $this->getMock('Magento\\Backend\\Model\\Session', [], [], '', false); $this->_authSession = $this->getMock('Magento\\Backend\\Model\\Auth\\Session', ['getUser'], [], '', false); $userMock = new \Magento\Framework\Object(); $this->_authSession->expects($this->any())->method('getUser')->will($this->returnValue($userMock)); $this->_translator = $this->getMock('Magento\\Framework\\TranslateInterface', [], [], '', false); $this->_translator->expects($this->any())->method('setLocale')->will($this->returnValue($this->_translator)); $this->_translator->expects($this->any())->method('init')->will($this->returnValue(false)); $this->_model = new \Magento\Backend\Model\Locale\Manager($this->_session, $this->_authSession, $this->_translator); }
public function testRenderIfInlineTranslationIsAllowed() { $theme = 'theme'; $text = 'test'; $result = sprintf('{{{%s}}{{%s}}}', $text, $theme); $this->translator->expects($this->once())->method('getTheme')->will($this->returnValue($theme)); $inlineTranslate = $this->getMock('Magento\\Framework\\Translate\\InlineInterface', [], [], '', []); $inlineTranslate->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); $this->provider->expects($this->once())->method('get')->will($this->returnValue($inlineTranslate)); $this->assertEquals($result, $this->renderer->render([$text], [])); }
public function testStop() { // Test data $initArea = 'initial area'; $initTheme = 'initial design theme'; $initLocale = 'initial locale code'; $initialStore = 1; $initTranslateInline = false; $this->inlineTranslationMock->expects($this->once())->method('isEnabled')->willReturn($initTranslateInline); $this->viewDesignMock->expects($this->once())->method('getArea')->willReturn($initArea); $this->viewDesignMock->expects($this->once())->method('getDesignTheme')->willReturn($initTheme); $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock); $this->storeMock->expects($this->once())->method('getStoreId')->willReturn($initialStore); $this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn($initLocale); $this->model->storeCurrentEnvironmentInfo(); // Expectations $this->inlineTranslationMock->expects($this->once())->method('resume')->with($initTranslateInline); $this->viewDesignMock->expects($this->once())->method('setDesignTheme')->with($initTheme, $initArea); $this->storeManagerMock->expects($this->once())->method('setCurrentStore')->with($initialStore); $this->localeResolverMock->expects($this->once())->method('setLocale')->with($initLocale); $this->translateMock->expects($this->once())->method('setLocale')->with($initLocale); $this->translateMock->expects($this->once())->method('loadData')->with($initArea); // Test $this->model->stopEnvironmentEmulation(); }