diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2020-12-08 17:05:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 17:05:38 +0100 |
commit | 86a3b7e7bf419e2bf1acc687625d0ff8596d39dc (patch) | |
tree | e467d21a31f7e78320ee9739ba66dccd4025eb65 /build/integration/features/bootstrap | |
parent | fda6ffc866cf8c5d3579fe95d1731ab747894002 (diff) | |
parent | 13a438b3224f3f42a0f552230f680a243e1af705 (diff) | |
download | nextcloud-server-86a3b7e7bf419e2bf1acc687625d0ff8596d39dc.tar.gz nextcloud-server-86a3b7e7bf419e2bf1acc687625d0ff8596d39dc.zip |
Merge pull request #24486 from nextcloud/feature/noid/phone-number-validation
Phone number validation and search
Diffstat (limited to 'build/integration/features/bootstrap')
-rw-r--r-- | build/integration/features/bootstrap/Provisioning.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index 56d75c058aa..a856e47ef2b 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -173,6 +173,37 @@ trait Provisioning { } } + /** + * @Then /^search users by phone for region "([^"]*)" with$/ + * + * @param string $user + * @param \Behat\Gherkin\Node\TableNode|null $settings + */ + public function searchUserByPhone($region, \Behat\Gherkin\Node\TableNode $searchTable) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/search/by-phone"; + $client = new Client(); + $options = []; + $options['auth'] = $this->adminUser; + $options['headers'] = [ + 'OCS-APIREQUEST' => 'true', + ]; + + $search = []; + foreach ($searchTable->getRows() as $row) { + if (!isset($search[$row[0]])) { + $search[$row[0]] = []; + } + $search[$row[0]][] = $row[1]; + } + + $options['form_params'] = [ + 'location' => $region, + 'search' => $search, + ]; + + $this->response = $client->post($fullUrl, $options); + } + public function createUser($user) { $previous_user = $this->currentUser; $this->currentUser = "admin"; @@ -561,6 +592,19 @@ trait Provisioning { } /** + * @Then /^phone matches returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $usersList + */ + public function thePhoneUsersShouldBe($usersList) { + if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { + $users = $usersList->getRowsHash(); + $listCheckedElements = simplexml_load_string($this->response->getBody())->data; + $respondedArray = json_decode(json_encode($listCheckedElements), true); + Assert::assertEquals($users, $respondedArray); + } + } + + /** * @Then /^detailed users returned are$/ * @param \Behat\Gherkin\Node\TableNode|null $usersList */ |