/** * Set locale * * @param string $locale * @return $this */ public function setLocale($locale = null) { $forceLocale = $this->_request->getParam('locale', null); if (!$this->_localeValidator->isValid($forceLocale)) { $forceLocale = false; } $sessionLocale = $this->_session->getSessionLocale(); $userLocale = $this->_localeManager->getUserInterfaceLocale(); $localeCodes = array_filter([$forceLocale, $sessionLocale, $userLocale]); if (count($localeCodes)) { $locale = reset($localeCodes); } return parent::setLocale($locale); }
/** * @covers \Magento\Backend\Model\Locale\Manager::getUserInterfaceLocale */ public function testGetUserInterfaceLocale() { $this->_model->switchBackendInterfaceLocale('de_DE'); $locale = $this->_model->getUserInterfaceLocale(); $this->assertEquals($locale, 'de_DE'); }
/** * @covers \Magento\Backend\Model\Locale\Manager::getUserInterfaceLocale */ public function testGetUserInterfaceGeneralLocale() { $this->_backendConfig->expects($this->any())->method('getValue')->with('general/locale/code')->willReturn('test_locale'); $locale = $this->_model->getUserInterfaceLocale(); $this->assertEquals($locale, 'test_locale'); }