subject = new UserLanguageService( [ UserLanguageService::OPTION_AUTHORING_LANGUAGE => 'fr-FR', ] ); } public function testGetAuthoringLanguage(): void { $this->assertSame('fr-FR', $this->subject->getAuthoringLanguage()); } public function testGetDefaultLanguageForAuthoringLanguage(): void { $this->subject->setOptions([]); $this->assertSame($this->subject->getDefaultLanguage(), $this->subject->getAuthoringLanguage()); } public function testGetInterfaceLanguageReturnsDefaultLanguageWhenUserDoesNotHaveItSet(): void { $user = $this->createUser(); $this->assertSame($this->subject->getDefaultLanguage(), $this->subject->getInterfaceLanguage($user)); } public function testGetInterfaceLanguageReturnsLanguageFromUser(): void { $user = $this->createUser('en-US'); $this->assertSame('en-US', $this->subject->getInterfaceLanguage($user)); } public function testGetInterfaceLanguageReturnsCustomInterfaceLanguage(): void { $this->subject->setCustomInterfaceLanguage('es-ES'); $user = $this->createUser(); $this->assertSame('es-ES', $this->subject->getInterfaceLanguage($user)); } private function createUser(?string $withLanguage = null): User { /** @var User|ObjectProphecy $user */ $user = $this->prophesize(User::class); if ($withLanguage !== null) { $user->getPropertyValues(Argument::is(GenerisRdf::PROPERTY_USER_UILG)) ->willReturn([$withLanguage]); } return $user->reveal(); } }