From a2042225615890f0b363ab8f4c0d922e478a6b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 30 May 2018 12:21:36 +0200 Subject: [PATCH] update help description --- core/Command/User/SyncBackend.php | 18 ++++++++-------- tests/lib/Command/User/SyncBackendTest.php | 15 ++++++------- tests/lib/User/SyncServiceTest.php | 25 +++++++++++----------- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/core/Command/User/SyncBackend.php b/core/Command/User/SyncBackend.php index 5b212c9e6fec..f3b0aeb7dee5 100644 --- a/core/Command/User/SyncBackend.php +++ b/core/Command/User/SyncBackend.php @@ -42,7 +42,6 @@ use Symfony\Component\Console\Input\InputArgument; class SyncBackend extends Command { - const VALID_ACTIONS = ['disable', 'remove']; /** @var AccountMapper */ @@ -78,31 +77,34 @@ protected function configure() { ->addArgument( 'backend-class', InputArgument::OPTIONAL, - 'The PHP class name - e.g., "OCA\User_LDAP\User_Proxy". Please wrap the class name in double quotes. You can use the option --list to list all known backend classes.' + "The quoted PHP class name for the backend, eg\n" + ." - LDAP:\t\t\"OCA\User_LDAP\User_Proxy\"\n" + ." - Samba:\t\t\"OCA\User\SMB\"\n" + ." - Shibboleth:\t\"OCA\User_Shibboleth\UserBackend\"" ) ->addOption( 'list', 'l', InputOption::VALUE_NONE, - 'List all known backend classes' + 'List all enabled backend classes' ) ->addOption( 'uid', 'u', InputOption::VALUE_REQUIRED, - 'sync only the user with the given user id' + 'Sync only the user with the given user id' ) ->addOption( 'seenOnly', 's', InputOption::VALUE_NONE, - 'sync only seen users' + 'Sync only seen users' ) ->addOption( 'showCount', 'c', InputOption::VALUE_NONE, - 'calculate user count before syncing' + 'Calculate user count before syncing' ) ->addOption( 'missing-account-action', @@ -207,7 +209,7 @@ private function syncMultipleUsers ( } $output->writeln(''); - $backendClass = get_class($backend); + $backendClass = \get_class($backend); if ($input->getOption('seenOnly')) { $output->writeln("Updating seen accounts from $backendClass ..."); $iterator = new SeenUsersIterator($this->accountMapper, $backendClass); @@ -415,7 +417,5 @@ function ($uid) use ($output) { } ); } - - } } diff --git a/tests/lib/Command/User/SyncBackendTest.php b/tests/lib/Command/User/SyncBackendTest.php index 5e312b2682a0..fe4dd2213ae3 100644 --- a/tests/lib/Command/User/SyncBackendTest.php +++ b/tests/lib/Command/User/SyncBackendTest.php @@ -219,7 +219,6 @@ public function testInvalidAccountActionShowsError() { $this->assertEquals(1, static::invokePrivate($this->command, 'execute', [$inputInterface, $outputInterface])); } - public function executeProvider() { return [ ['foo', 'Syncing foo ...'], @@ -310,8 +309,8 @@ public function testSingleUserSyncExistingUser() { $syncService->expects($this ->once())->method('run')->with( $this->dummyBackend, - $this->callback(function($subject){ - return count($subject) === 1 && $subject[0] === 'existing-uid'; + $this->callback(function ($subject) { + return \count($subject) === 1 && $subject[0] === 'existing-uid'; }), $this->anything() ); @@ -397,13 +396,13 @@ public function testSyncMultipleUsersExistingUsers() { $syncService->expects($this ->once())->method('run')->with( $this->dummyBackend, - $this->callback(function(\Iterator $iterator) use ($uids) { + $this->callback(function (\Iterator $iterator) use ($uids) { // convert to array so we can test better $items = []; foreach ($iterator as $item) { $items[] = $item; } - return count(array_diff($items, $uids)) === 0; + return \count(\array_diff($items, $uids)) === 0; }), $this->anything() ); @@ -437,13 +436,13 @@ public function testSyncMultipleUsersRemovedUsers($action, $method, $isEnabled, $syncService->expects($this ->once())->method('run')->with( $this->dummyBackend, - $this->callback(function(\Iterator $iterator) use ($uids) { + $this->callback(function (\Iterator $iterator) use ($uids) { // convert to array so we can test better $items = []; foreach ($iterator as $item) { $items[] = $item; } - return count(array_diff($items, $uids)) === 0; + return \count(\array_diff($items, $uids)) === 0; }), $this->anything() ); @@ -481,6 +480,4 @@ public function testReEnableAction() { $this->userManager->expects($this->once())->method('get')->willReturn($user); static::invokePrivate($this->command, 'reEnableUsers', [$reappearedUsers, $nullOutput]); } - - } diff --git a/tests/lib/User/SyncServiceTest.php b/tests/lib/User/SyncServiceTest.php index b560cdae8548..a7d1bc18f9d7 100644 --- a/tests/lib/User/SyncServiceTest.php +++ b/tests/lib/User/SyncServiceTest.php @@ -179,13 +179,14 @@ public function testAnalyseExistingUsers() { $s = new SyncService($this->config, $this->logger, $this->mapper); $this->mapper->expects($this->once()) ->method('callForAllUsers') - ->with($this->callback(function($param) { - return is_callable($param); + ->with($this->callback(function ($param) { + return \is_callable($param); })); $backend = $this->createMock(UserInterface::class); - $result = $s->analyzeExistingUsers($backend, function() {}); - $this->assertTrue(is_array($result)); - $this->assertEquals(2, count($result)); + $result = $s->analyzeExistingUsers($backend, function () { + }); + $this->assertInternalType('array', $result); + $this->assertCount(2, $result); } /** @@ -202,10 +203,9 @@ public function testReAppearingAccountsAreDetected() { $account->expects($this->exactly(2))->method('getUserId')->willReturn('test'); $s = new SyncService($this->config, $this->logger, $this->mapper); $response = static::invokePrivate($s, 'checkIfAccountReappeared', [$account, $backend, $backendClass]); - $this->assertTrue(is_array($response)); - $this->assertEquals(0, count($response[0])); - $this->assertEquals(1, count($response[1])); - + $this->assertInternalType('array', $response); + $this->assertCount(0, $response[0]); + $this->assertCount(1, $response[1]); } /** @@ -222,9 +222,9 @@ public function testRemovedAccountsAreDetected() { $account->expects($this->exactly(2))->method('getUserId')->willReturn('test'); $s = new SyncService($this->config, $this->logger, $this->mapper); $response = static::invokePrivate($s, 'checkIfAccountReappeared', [$account, $backend, $backendClass]); - $this->assertTrue(is_array($response)); - $this->assertEquals(1, count($response[0])); - $this->assertEquals(0, count($response[1])); + $this->assertInternalType('array', $response); + $this->assertCount(1, $response[0]); + $this->assertCount(0, $response[1]); } public function providesSyncQuota() { @@ -275,5 +275,4 @@ public function testSyncQuota($backendProvidesQuota, $backendQuota, $preferences $s = new SyncService($this->config, $this->logger, $this->mapper); static::invokePrivate($s, 'syncQuota', [$a, $backend]); } - }