Skip to content

Commit

Permalink
Add tests for getUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
paurakhsharma committed Oct 11, 2018
1 parent bb9f906 commit a976333
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ public function theAdministratorSendsAUserDeletionRequestForUserUsingTheOccComma
);
}

/**
* @When the administrator retrieves all the users using the occ command
*
* @return void
*/
public function theAdministratorRetrievesAllTheUsersUsingTheOccCommand() {
$this->featureContext->invokingTheCommand(
"user:list --output=json"
);
}

/**
* @When the administrator retrieves the information of user :username using the occ command
*
Expand Down Expand Up @@ -425,9 +436,18 @@ public function theAppsReturnedByTheOccCommandShouldInclude(TableNode $appListTa
public function theUsersReturnedByTheOccCommandShouldBe(TableNode $useridTable) {
$lastOutput = $this->featureContext->getStdOutOfOccCommand();
$lastOutputUsers = \json_decode($lastOutput, true);
$result = [];
// check if an array is a multi-dimentional array with inner array key 'displayName'
if (\array_column($lastOutputUsers, 'displayName')) {
foreach ($lastOutputUsers as $key => $value) {
$result[$key] = $value['displayName'];
}
} else {
$result = $lastOutputUsers;
}
foreach ($useridTable as $row) {
PHPUnit_Framework_Assert::assertArrayHasKey($row['uid'], $lastOutputUsers);
PHPUnit_Framework_Assert::assertContains($row['display name'], $lastOutputUsers);
PHPUnit_Framework_Assert::assertArrayHasKey($row['uid'], $result);
PHPUnit_Framework_Assert::assertContains($row['display name'], $result);
}
}

Expand Down
15 changes: 15 additions & 0 deletions tests/acceptance/features/cliProvisioning/getUsers.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@cli @skipOnLDAP
Feature: get users
As an admin
I want to be able to list the users that exist
So that I can see who has access to ownCloud

Scenario: admin gets all users
Given this user has been created using the occ command:
| username | displayname | email |
| brand-new-user | Just A User | justauser@example.com |
When the administrator retrieves all the users using the occ command
Then the command should have been successful
And the users returned by the occ command should be
| uid | display name |
| brand-new-user | Just A User |

0 comments on commit a976333

Please sign in to comment.