getService(); $user = $this->getUser(); $this->assertEquals('en-US', $service->getInterfaceLanguage($user)); $user = $this->getUser('fr-FR'); $this->assertEquals('fr-FR', $service->getInterfaceLanguage($user)); } public function testGetDataLanguage() { $service = $this->getService([ UserLanguageService::OPTION_LOCK_DATA_LANGUAGE => false ]); $user = $this->getUser(); $this->assertEquals('en-US', $service->getDataLanguage($user)); $user = $this->getUser('fr-FR', 'fr-FR'); $this->assertEquals('fr-FR', $service->getDataLanguage($user)); $service = $this->getService([ UserLanguageService::OPTION_LOCK_DATA_LANGUAGE => true ]); $user = $this->getUser(); $this->assertEquals('en-US', $service->getDataLanguage($user)); $user = $this->getUser('fr-FR', 'fr-FR'); $this->assertEquals('en-US', $service->getDataLanguage($user)); } public function testIsDataLanguageEnabled() { $service = $this->getService(); $this->assertEquals(true, $service->isDataLanguageEnabled()); $service = $this->getService([ UserLanguageService::OPTION_LOCK_DATA_LANGUAGE => false ]); $this->assertEquals(true, $service->isDataLanguageEnabled()); $service = $this->getService([ UserLanguageService::OPTION_LOCK_DATA_LANGUAGE => true ]); $this->assertEquals(false, $service->isDataLanguageEnabled()); } /** * @param string $uiLg * @param string $dataLg * @return User */ private function getUser($uiLg = null, $dataLg = null) { $user = $this->prophesize(User::class); $user->getPropertyValues(GenerisRdf::PROPERTY_USER_DEFLG) ->willReturn($dataLg === null ? [] : [$dataLg]); $user->getPropertyValues(GenerisRdf::PROPERTY_USER_UILG) ->willReturn($uiLg === null ? [] : [$uiLg]); return $user->reveal(); } /** * @param array $options * @return UserLanguageService */ private function getService($options = []) { $service = new UserLanguageService($options); return $service; } }