summaryrefslogtreecommitdiffstats
path: root/tests/integration/features/bootstrap/FeatureContext.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/features/bootstrap/FeatureContext.php')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index d1a65713e..319704c6c 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -59,6 +59,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
protected static ?array $nextChatRequestParameters = null;
/** @var array<string, int> */
protected static array $modifiedSince;
+ /** @var array<string, string> */
+ protected static array $createdTeams = [];
protected static array $permissionsMap = [
@@ -111,6 +113,10 @@ class FeatureContext implements Context, SnippetAcceptingContext {
return self::$identifierToToken[$identifier];
}
+ public static function getTeamIdForLabel(string $label): string {
+ return self::$createdTeams[$label] ?? throw new \RuntimeException('Unknown team: ' . $label);
+ }
+
public static function getMessageIdForText(string $text): int {
return self::$textToMessageId[$text];
}
@@ -175,6 +181,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$this->createdUsers = [];
$this->createdGroups = [];
+ self::$createdTeams = [];
$this->createdGuestAccountUsers = [];
}
@@ -197,6 +204,9 @@ class FeatureContext implements Context, SnippetAcceptingContext {
foreach ($this->createdGroups as $group) {
$this->deleteGroup($group);
}
+ foreach (self::$createdTeams as $team => $id) {
+ $this->deleteTeam($team);
+ }
foreach ($this->createdGuestAccountUsers as $user) {
$this->deleteGuestUser($user);
}
@@ -3624,6 +3634,37 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
+ * @Given /^team "([^"]*)" exists$/
+ */
+ public function assureTeamExists(string $team): void {
+ $this->runOcc(['circles:manage:create', '--type', '1', '--output', 'json', 'admin', $team]);
+ $this->theCommandWasSuccessful();
+
+ $output = $this->getLastStdOut();
+ $data = json_decode($output, true);
+
+ self::$createdTeams[$team] = $data['id'];
+ }
+
+ /**
+ * @Given /^add user "([^"]*)" to team "([^"]*)"$/
+ */
+ public function addTeamMember(string $user, string $team): void {
+ $this->runOcc(['circles:members:add', '--type', '1', self::$createdTeams[$team], $user]);
+ $this->theCommandWasSuccessful();
+ }
+
+ /**
+ * @Given /^delete team "([^"]*)"$/
+ */
+ public function deleteTeam(string $team): void {
+ $this->runOcc(['circles:manage:destroy', self::$createdTeams[$team]]);
+ $this->theCommandWasSuccessful();
+
+ unset(self::$createdTeams[$team]);
+ }
+
+ /**
* @Given /^user "([^"]*)" is a guest account user/
* @param string $email email address
*/