Skip to content

Commit

Permalink
Adjust files:scan groups option so groups are listed individually
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jun 29, 2018
1 parent c05ccc8 commit 0be9e4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions apps/files/lib/Command/Scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ protected function configure() {
->addOption(
'groups',
'g',
InputArgument::OPTIONAL,
'Scan user(s) under the group(s). This option can be used as --groups=foo,bar to scan groups foo and bar'
InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED,
'Scan user(s) under the group(s). This option can be used as --groups=foo --groups=bar to scan groups foo and bar'
)
->addOption(
'quiet',
Expand Down Expand Up @@ -276,7 +276,7 @@ protected function getAllUsersFromGroup($group) {

protected function execute(InputInterface $input, OutputInterface $output) {
$inputPath = $input->getOption('path');
$groups = $input->getOption('groups') ? \explode(',', $input->getOption('groups')) : [];
$groups = $input->getOption('groups');
$shouldRepairStoragesIndividually = (bool) $input->getOption('repair');

if (\count($groups) >= 1) {
Expand Down
17 changes: 9 additions & 8 deletions apps/files/tests/Command/ScanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ protected function tearDown() {

public function dataInput() {
return [
[['--groups' => 'haystack'], 'Group name haystack doesn\'t exist'],
[['--groups' => 'group1'], 'Starting scan for user 1 out of 1 (user1)'],
[['--groups' => ['haystack']], 'Group name haystack doesn\'t exist'],
[['--groups' => ['haystack,barn']], 'Group name haystack,barn doesn\'t exist'],
[['--groups' => ['group1']], 'Starting scan for user 1 out of 1 (user1)'],
[['user_id' => ['user1']], 'Starting scan for user 1 out of 1 (user1)'],
[['user_id' => ['user2']], 'Starting scan for user 1 out of 1 (user2)']
];
Expand All @@ -158,7 +159,7 @@ public function testCommandInput($input, $expectedOutput) {

public function userInputData() {
return [
[['--groups' => 'group1'], 'Starting scan for user 1 out of 200']
[['--groups' => ['group1']], 'Starting scan for user 1 out of 200']
];
}

Expand All @@ -171,7 +172,7 @@ public function testGroupPaginationForUsers($input, $expectedOutput) {
//First we populate the users
$user = 'user';
$numberOfUsersInGroup = 210;
for ($i = 2; $i <= 210; $i++) {
for ($i = 2; $i <= $numberOfUsersInGroup; $i++) {
$userObj = $this->createUser($user.$i);
$this->groupManager->get('group1')->addUser($userObj);
}
Expand All @@ -180,13 +181,13 @@ public function testGroupPaginationForUsers($input, $expectedOutput) {
$output = $this->commandTester->getDisplay();
$this->assertContains($expectedOutput, $output);
//If pagination works then below assert shouldn't fail
$this->assertNotContains('Starting scan for user 1 out of 210', $output);
$this->assertNotContains("Starting scan for user 1 out of $numberOfUsersInGroup", $output);
}

public function multipleGroupTest() {
return [
[['--groups' => 'group1,group2'], ''],
[['--groups' => 'group1,group2,group3'], '']
[['--groups' => ['group1,x','group2']], ''],
[['--groups' => ['group1','group2,x','group3']], '']
];
}

Expand All @@ -196,7 +197,7 @@ public function multipleGroupTest() {
*/
public function testMultipleGroups($input) {
//Create 10 users in each group
$groups = \explode(',', $input['--groups']);
$groups = $input['--groups'];
$user = "user";
$userObj = [];
for ($i = 1; $i <= (10 * \count($groups)); $i++) {
Expand Down

0 comments on commit 0be9e4f

Please sign in to comment.