diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-01-08 12:57:14 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-01-08 12:57:14 +0100 |
commit | e4310648dfcc57618c4a0d61ae73f889e08f3b53 (patch) | |
tree | a2e870ab7835f980adb9868fea6cf83b5c5270bf /apps | |
parent | a565bf0b9f9d81d46ff705498b66b676fe9a628a (diff) | |
download | nextcloud-server-e4310648dfcc57618c4a0d61ae73f889e08f3b53.tar.gz nextcloud-server-e4310648dfcc57618c4a0d61ae73f889e08f3b53.zip |
add unit test for determining next cycle
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/user_ldap/tests/Jobs/SyncTest.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php index 686455f5ac6..338b1210a98 100644 --- a/apps/user_ldap/tests/Jobs/SyncTest.php +++ b/apps/user_ldap/tests/Jobs/SyncTest.php @@ -196,4 +196,45 @@ class SyncTest extends TestCase { $this->assertSame($expected, $hasMoreResults); } + public function cycleDataProvider() { + $cycle1 = ['prefix' => 's01', 'offset' => 1000]; + return [ + [ null, ['s01'], ['prefix' => 's01', 'offset' => 0] ], + [ $cycle1, ['s01', 's02'], ['prefix' => 's02', 'offset' => 0] ], + [ $cycle1, [], null ], + ]; + } + + /** + * @dataProvider cycleDataProvider + */ + public function testDetermineNextCycle($cycleData, $prefixes, $expectedCycle) { + $this->helper->expects($this->any()) + ->method('getServerConfigurationPrefixes') + ->with(true) + ->willReturn($prefixes); + + if(is_array($expectedCycle)) { + $this->config->expects($this->exactly(2)) + ->method('setAppValue') + ->withConsecutive( + ['user_ldap', 'background_sync_prefix', $expectedCycle['prefix']], + ['user_ldap', 'background_sync_offset', $expectedCycle['offset']] + ); + } else { + $this->config->expects($this->never()) + ->method('setAppValue'); + } + + $this->sync->setArgument($this->arguments); + $nextCycle = $this->sync->determineNextCycle($cycleData); + + if($expectedCycle === null) { + $this->assertNull($nextCycle); + } else { + $this->assertSame($expectedCycle['prefix'], $nextCycle['prefix']); + $this->assertSame($expectedCycle['offset'], $nextCycle['offset']); + } + } + } |