diff options
Diffstat (limited to 'tests/lib/L10N/FactoryTest.php')
-rw-r--r-- | tests/lib/L10N/FactoryTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php index 3008e0a239c..be842cf12c7 100644 --- a/tests/lib/L10N/FactoryTest.php +++ b/tests/lib/L10N/FactoryTest.php @@ -14,6 +14,7 @@ use OCP\IConfig; use OCP\IRequest; use OCP\IUser; use OCP\IUserSession; +use OCP\L10N\ILanguageIterator; use Test\TestCase; /** @@ -596,4 +597,33 @@ class FactoryTest extends TestCase { $this->assertSame($expected, $result); } + public function languageIteratorRequestProvider():array { + return [ + [ true, $this->createMock(IUser::class)], + [ false, $this->createMock(IUser::class)], + [ false, null] + ]; + } + + /** + * @dataProvider languageIteratorRequestProvider + */ + public function testGetLanguageIterator(bool $hasSession, IUser $iUserMock = null) { + $factory = $this->getFactory(); + + if($iUserMock === null) { + $matcher = $this->userSession->expects($this->once()) + ->method('getUser'); + + if($hasSession) { + $matcher->willReturn($this->createMock(IUser::class)); + } else { + $this->expectException(\RuntimeException::class); + } + } + + $iterator = $factory->getLanguageIterator($iUserMock); + $this->assertInstanceOf(ILanguageIterator::class, $iterator); + } + } |