Skip to content

Commit

Permalink
get user from server side and assert with createdUsersList
Browse files Browse the repository at this point in the history
  • Loading branch information
swoichha committed Aug 25, 2020
1 parent 16a9f07 commit aa04247
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tests/acceptance/features/bootstrap/OccUsersGroupsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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"
);
}
}
Expand Down

0 comments on commit aa04247

Please sign in to comment.