public function testDetectLanguageWithUserWithSettings() { $expected = 'it'; $request = $this->getMockBuilder(Request::class)->setMethods(['getHeaders'])->getMock(); $request->expects($this->never())->method('getHeaders'); $settings = new \stdClass(); $settings->localization = new \stdClass(); $settings->localization->language = $expected; $user = $this->getMockBuilder(User::class)->getMock(); $user->expects($this->once())->method('getSettings')->with($this->equalTo('Core'))->willReturn($settings); $this->assertSame($expected, $this->localeService->detectLanguage($request, $user)); }
/** * @param MvcEvent $e * @return string */ protected function detectLanguage(MvcEvent $e) { $auth = $e->getApplication()->getServiceManager()->get('AuthenticationService'); $user = $auth->hasIdentity() ? $auth->getUser() : null; return $this->localeService->detectLanguage($e->getRequest(), $user); }