Skip to content

Commit

Permalink
Merge pull request #37839 from owncloud/test-create-user-occCommand
Browse files Browse the repository at this point in the history
[Tests-Only] Assert created user
  • Loading branch information
phil-davis authored Aug 25, 2020
2 parents d65b8b5 + e47d633 commit a992db8
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 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 @@ -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);
}

/**
Expand Down

0 comments on commit a992db8

Please sign in to comment.