Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for getUsers #33146

Merged
merged 1 commit into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-dimensional array with inner array key 'displayName'
if (\array_column($lastOutputUsers, 'displayName')) {
Copy link
Member Author

@paurakhsharma paurakhsharma Oct 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is because when we run occ command to get users from a group we get a single dimensional array but when we run occ command to get all users on ownCloud server we get multi-dimensional array

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 |