[tests-only][full-ci]Refactor test function for handeling errors (#5745)
* Refactor test function for handeling errors * fix return types * clean up code * address reviews
This commit is contained in:
1 parent
950f17543b
commit
da94701dca
4 files changed
+9
-19
No files matched your search
@@ -198,7 +198,7 @@ Feature: add users to group
|
|||||||
| username |
|
| username |
|
||||||
| Brian |
|
| Brian |
|
||||||
And user "Alice" has created a group "grp1" using the Graph API
|
And user "Alice" has created a group "grp1" using the Graph API
|
||||||
When the administrator "Alice" tries to add the following users to a group "grp1" at once using the Graph API
|
When the administrator "Alice" tries to add the following existent and nonexistent users to a group "grp1" at once using the Graph API
|
||||||
| username |
|
| username |
|
||||||
| Brian |
|
| Brian |
|
||||||
| Carol |
|
| Carol |
|
||||||
|
|||||||
@@ -4627,7 +4627,7 @@ class FeatureContext extends BehatVariablesContext {
|
|||||||
* @return string
|
* @return string
|
||||||
* @throws Exception|GuzzleException
|
* @throws Exception|GuzzleException
|
||||||
*/
|
*/
|
||||||
public function getGroupIdByGroupName(string $groupName): string {
|
public function getGroupIdByGroupName(string $groupName):string {
|
||||||
$response = GraphHelper::getGroup(
|
$response = GraphHelper::getGroup(
|
||||||
$this->getBaseUrl(),
|
$this->getBaseUrl(),
|
||||||
$this->getStepLineRef(),
|
$this->getStepLineRef(),
|
||||||
|
|||||||
@@ -241,12 +241,8 @@ class GraphContext implements Context {
|
|||||||
*/
|
*/
|
||||||
public function adminHasRetrievedUserUsingTheGraphApi(string $user): void {
|
public function adminHasRetrievedUserUsingTheGraphApi(string $user): void {
|
||||||
$user = $this->featureContext->getActualUsername($user);
|
$user = $this->featureContext->getActualUsername($user);
|
||||||
try {
|
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
|
||||||
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
|
$userId = $userId ? $userId : $user;
|
||||||
$userId = $userId ?? $user;
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$userId = $user;
|
|
||||||
}
|
|
||||||
$result = GraphHelper::getUser(
|
$result = GraphHelper::getUser(
|
||||||
$this->featureContext->getBaseUrl(),
|
$this->featureContext->getBaseUrl(),
|
||||||
$this->featureContext->getStepLineRef(),
|
$this->featureContext->getStepLineRef(),
|
||||||
@@ -1747,6 +1743,7 @@ class GraphContext implements Context {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @When /^the administrator "([^"]*)" tries to add the following users to a group "([^"]*)" at once using the Graph API$/
|
* @When /^the administrator "([^"]*)" tries to add the following users to a group "([^"]*)" at once using the Graph API$/
|
||||||
|
* @When /^the administrator "([^"]*)" tries to add the following existent and nonexistent users to a group "([^"]*)" at once using the Graph API$/
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $group
|
* @param string $group
|
||||||
@@ -1760,11 +1757,8 @@ class GraphContext implements Context {
|
|||||||
$userIds = [];
|
$userIds = [];
|
||||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||||
foreach ($table->getHash() as $row) {
|
foreach ($table->getHash() as $row) {
|
||||||
try {
|
$userId = $this->featureContext->getAttributeOfCreatedUser($row['username'], "id");
|
||||||
$userIds[] = $this->featureContext->getAttributeOfCreatedUser($row['username'], "id");
|
$userIds[] = $userId ? $userId : WebDavHelper::generateUUIDv4();
|
||||||
} catch (Exception $e) {
|
|
||||||
$userIds[] = WebDavHelper::generateUUIDv4();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->addMultipleUsersToGroup($user, $userIds, $groupId, $table);
|
$this->addMultipleUsersToGroup($user, $userIds, $groupId, $table);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,9 +265,7 @@ trait Provisioning {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(
|
return false;
|
||||||
__METHOD__ . ": User '$user' does not exist in the created list."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,9 +294,7 @@ trait Provisioning {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception(
|
return false;
|
||||||
__METHOD__ . ": Group '$group' does not exist in the created list."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user