summaryrefslogtreecommitdiffstats
path: root/build/integration/features/bootstrap
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2020-12-08 17:05:38 +0100
committerGitHub <noreply@github.com>2020-12-08 17:05:38 +0100
commit86a3b7e7bf419e2bf1acc687625d0ff8596d39dc (patch)
treee467d21a31f7e78320ee9739ba66dccd4025eb65 /build/integration/features/bootstrap
parentfda6ffc866cf8c5d3579fe95d1731ab747894002 (diff)
parent13a438b3224f3f42a0f552230f680a243e1af705 (diff)
downloadnextcloud-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.php44
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
*/