From aa0424778d2a78dfafe70d66822b6d8290986d19 Mon Sep 17 00:00:00 2001 From: swoichha Date: Tue, 25 Aug 2020 09:58:32 +0545 Subject: [PATCH] get user from server side and assert with createdUsersList --- .../bootstrap/OccUsersGroupsContext.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/features/bootstrap/OccUsersGroupsContext.php b/tests/acceptance/features/bootstrap/OccUsersGroupsContext.php index 7ecc150fde62..13e39c61661a 100644 --- a/tests/acceptance/features/bootstrap/OccUsersGroupsContext.php +++ b/tests/acceptance/features/bootstrap/OccUsersGroupsContext.php @@ -24,6 +24,7 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope; use Behat\Gherkin\Node\TableNode; use PHPUnit\Framework\Assert; +use TestHelpers\OcsApiHelper; require_once 'bootstrap.php'; @@ -131,10 +132,22 @@ public function theseUsersHaveBeenCreatedUsingTheOccCommand(TableNode $table) { $this->occContext->theCommandShouldHaveBeenSuccessful(); $createdUsersList = $this->featureContext->getCreatedUsers(); $usernameArray = \array_keys($createdUsersList); - foreach ($table as $row) { + + $url = "/cloud/users/%s"; + foreach ($table as $users) { + $user = $this->featureContext->getActualUsername($users['username']); + $response = OcsApiHelper::sendRequest( + $this->featureContext->getBaseUrl(), + $user, + $this->featureContext->getPasswordForUser($user), + 'GET', + \sprintf($url, $user) + ); + $this->featureContext->setResponse($response); + $username = \explode("data/", (string)$this->featureContext->getResponseXml()->data[0]->home); Assert::assertTrue( - \in_array($row['username'], $usernameArray), - "User: " . $row['username'] . " was not created" + \in_array($username[1], $usernameArray, true), + "User: " . \implode($username) . " was not created" ); } }