diff options
Diffstat (limited to 'tests/lib/L10N/FactoryTest.php')
-rw-r--r-- | tests/lib/L10N/FactoryTest.php | 118 |
1 files changed, 41 insertions, 77 deletions
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php index faf9dff48cc..4e01602a4f7 100644 --- a/tests/lib/L10N/FactoryTest.php +++ b/tests/lib/L10N/FactoryTest.php @@ -146,20 +146,21 @@ class FactoryTest extends TestCase { public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguage(): void { $factory = $this->getFactory(['languageExists'], true); $this->invokePrivate($factory, 'requestLanguage', ['de']); - $factory->expects(self::at(0)) - ->method('languageExists') - ->with('MyApp', 'de') - ->willReturn(false); + $factory->expects($this->exactly(3)) + ->method('languageExists') + ->willReturnMap([ + ['MyApp', 'de', false], + ['MyApp', 'jp', false], + ['MyApp', 'es', true], + ]); $this->config - ->expects(self::at(0)) + ->expects($this->exactly(3)) ->method('getSystemValue') - ->with('force_language', false) - ->willReturn(false); - $this->config - ->expects(self::at(1)) - ->method('getSystemValue') - ->with('installed', false) - ->willReturn(true); + ->willReturnMap([ + ['force_language', false, false], + ['installed', false, true], + ['default_language', false, 'es'] + ]); $user = $this->getMockBuilder(IUser::class) ->getMock(); $user->expects(self::once()) @@ -174,19 +175,6 @@ class FactoryTest extends TestCase { ->method('getUserValue') ->with('MyUserUid', 'core', 'lang', null) ->willReturn('jp'); - $factory->expects(self::at(1)) - ->method('languageExists') - ->with('MyApp', 'jp') - ->willReturn(false); - $this->config - ->expects(self::at(3)) - ->method('getSystemValue') - ->with('default_language', false) - ->willReturn('es'); - $factory->expects(self::at(2)) - ->method('languageExists') - ->with('MyApp', 'es') - ->willReturn(true); self::assertSame('es', $factory->findLanguage('MyApp')); } @@ -194,20 +182,21 @@ class FactoryTest extends TestCase { public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguageAndNotExistingDefault(): void { $factory = $this->getFactory(['languageExists'], true); $this->invokePrivate($factory, 'requestLanguage', ['de']); - $factory->expects(self::at(0)) - ->method('languageExists') - ->with('MyApp', 'de') - ->willReturn(false); + $factory->expects($this->exactly(3)) + ->method('languageExists') + ->willReturnMap([ + ['MyApp', 'de', false], + ['MyApp', 'jp', false], + ['MyApp', 'es', false], + ]); $this->config - ->expects(self::at(0)) + ->expects($this->exactly(3)) ->method('getSystemValue') - ->with('force_language', false) - ->willReturn(false); - $this->config - ->expects(self::at(1)) - ->method('getSystemValue') - ->with('installed', false) - ->willReturn(true); + ->willReturnMap([ + ['force_language', false, false], + ['installed', false, true], + ['default_language', false, 'es'] + ]); $user = $this->getMockBuilder(IUser::class) ->getMock(); $user->expects(self::once()) @@ -222,19 +211,6 @@ class FactoryTest extends TestCase { ->method('getUserValue') ->with('MyUserUid', 'core', 'lang', null) ->willReturn('jp'); - $factory->expects(self::at(1)) - ->method('languageExists') - ->with('MyApp', 'jp') - ->willReturn(false); - $this->config - ->expects(self::at(3)) - ->method('getSystemValue') - ->with('default_language', false) - ->willReturn('es'); - $factory->expects(self::at(2)) - ->method('languageExists') - ->with('MyApp', 'es') - ->willReturn(false); $this->config ->expects(self::never()) ->method('setUserValue'); @@ -245,20 +221,21 @@ class FactoryTest extends TestCase { public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguageAndNotExistingDefaultAndNoAppInScope(): void { $factory = $this->getFactory(['languageExists'], true); $this->invokePrivate($factory, 'requestLanguage', ['de']); - $factory->expects(self::at(0)) - ->method('languageExists') - ->with('MyApp', 'de') - ->willReturn(false); + $factory->expects($this->exactly(3)) + ->method('languageExists') + ->willReturnMap([ + ['MyApp', 'de', false], + ['MyApp', 'jp', false], + ['MyApp', 'es', false], + ]); $this->config - ->expects(self::at(0)) + ->expects($this->exactly(3)) ->method('getSystemValue') - ->with('force_language', false) - ->willReturn(false); - $this->config - ->expects(self::at(1)) - ->method('getSystemValue') - ->with('installed', false) - ->willReturn(true); + ->willReturnMap([ + ['force_language', false, false], + ['installed', false, true], + ['default_language', false, 'es'] + ]); $user = $this->getMockBuilder(IUser::class) ->getMock(); $user->expects(self::once()) @@ -273,19 +250,6 @@ class FactoryTest extends TestCase { ->method('getUserValue') ->with('MyUserUid', 'core', 'lang', null) ->willReturn('jp'); - $factory->expects(self::at(1)) - ->method('languageExists') - ->with('MyApp', 'jp') - ->willReturn(false); - $this->config - ->expects(self::at(3)) - ->method('getSystemValue') - ->with('default_language', false) - ->willReturn('es'); - $factory->expects(self::at(2)) - ->method('languageExists') - ->with('MyApp', 'es') - ->willReturn(false); $this->config ->expects(self::never()) ->method('setUserValue') @@ -298,12 +262,12 @@ class FactoryTest extends TestCase { public function testFindLanguageWithForcedLanguage(): void { $factory = $this->getFactory(['languageExists']); $this->config - ->expects(self::at(0)) + ->expects($this->once()) ->method('getSystemValue') ->with('force_language', false) ->willReturn('de'); - $factory->expects(self::once()) + $factory->expects($this->once()) ->method('languageExists') ->with('MyApp', 'de') ->willReturn(true); |