Skip to content

Commit

Permalink
Add integration tests for the editable fields
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed May 27, 2021
1 parent 94584ee commit 3b6b4c8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
30 changes: 30 additions & 0 deletions build/integration/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,36 @@ public function userHasSetting($user, $settings) {
}
}

/**
* @Then /^user "([^"]*)" has editable fields$/
*
* @param string $user
* @param \Behat\Gherkin\Node\TableNode|null $fields
*/
public function userHasEditableFields($user, $fields) {
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/user/fields";
if ($user !== 'self') {
$fullUrl .= '/' . $user;
}
$client = new Client();
$options = [];
if ($this->currentUser === 'admin') {
$options['auth'] = $this->adminUser;
} else {
$options['auth'] = [$this->currentUser, $this->regularUser];
}
$options['headers'] = [
'OCS-APIREQUEST' => 'true',
];

$response = $client->get($fullUrl, $options);
$fieldsArray = json_decode(json_encode(simplexml_load_string($response->getBody())->data->element), 1);

$expectedFields = $fields->getRows();
$expectedFields = $this->simplifyArray($expectedFields);
Assert::assertEquals($expectedFields, $fieldsArray);
}

/**
* @Then /^search users by phone for region "([^"]*)" with$/
*
Expand Down
26 changes: 26 additions & 0 deletions build/integration/features/provisioning-v1.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@ Feature: provisioning
| brand-new-user |
| admin |

Scenario: Get editable fields
Given As an "admin"
And user "brand-new-user" exists
Then user "brand-new-user" has editable fields
| displayname |
| email |
| phone |
| address |
| website |
| twitter |
Given As an "brand-new-user"
Then user "brand-new-user" has editable fields
| displayname |
| email |
| phone |
| address |
| website |
| twitter |
Then user "self" has editable fields
| displayname |
| email |
| phone |
| address |
| website |
| twitter |

Scenario: Edit a user
Given As an "admin"
And user "brand-new-user" exists
Expand Down

0 comments on commit 3b6b4c8

Please sign in to comment.