From e47d6339fd3b4c2038ad13a765cd74883732f731 Mon Sep 17 00:00:00 2001 From: swoichha Date: Mon, 24 Aug 2020 10:53:47 +0545 Subject: [PATCH] [Tests-Only] check that users have been created after creating with occ command --- .../bootstrap/OccUsersGroupsContext.php | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/features/bootstrap/OccUsersGroupsContext.php b/tests/acceptance/features/bootstrap/OccUsersGroupsContext.php index ce6a41b7fa2c..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'; @@ -130,13 +131,25 @@ public function theseUsersHaveBeenCreatedUsingTheOccCommand(TableNode $table) { $this->createUsersUsingOccCommand($table); $this->occContext->theCommandShouldHaveBeenSuccessful(); $createdUsersList = $this->featureContext->getCreatedUsers(); - $tableUsername = []; - $displayName = []; $usernameArray = \array_keys($createdUsersList); - foreach ($table as $row) { - \array_push($tableUsername, $row['username']); + + $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($username[1], $usernameArray, true), + "User: " . \implode($username) . " was not created" + ); } - \in_array($tableUsername, $usernameArray, true); } /**