@@ -65,6 +65,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
65
65
protected static array $ modifiedSince ;
66
66
/** @var array */
67
67
protected static array $ createdTeams = [];
68
+ /** @var array */
69
+ protected static array $ renamedTeams = [];
68
70
/** @var array<string, int> */
69
71
protected static array $ userToBanId ;
70
72
@@ -128,7 +130,7 @@ public static function getTokenForIdentifier(string $identifier) {
128
130
}
129
131
130
132
public static function getTeamIdForLabel (string $ server , string $ label ): string {
131
- return self ::$ createdTeams [$ server ][$ label ] ?? throw new \RuntimeException ('Unknown team: ' . $ label );
133
+ return self ::$ createdTeams [$ server ][$ label ] ?? self :: $ renamedTeams [ $ server ][ $ label ] ?? throw new \RuntimeException ('Unknown team: ' . $ label );
132
134
}
133
135
134
136
public static function getMessageIdForText (string $ text ): int {
@@ -220,6 +222,7 @@ public function setUp(BeforeScenarioScope $scope) {
220
222
$ this ->createdUsers [$ server ] = [];
221
223
$ this ->createdGroups [$ server ] = [];
222
224
self ::$ createdTeams [$ server ] = [];
225
+ self ::$ renamedTeams [$ server ] = [];
223
226
$ this ->createdGuestAccountUsers [$ server ] = [];
224
227
}
225
228
@@ -246,15 +249,15 @@ public function tearDown() {
246
249
foreach (['LOCAL ' , 'REMOTE ' ] as $ server ) {
247
250
$ this ->usingServer ($ server );
248
251
252
+ foreach (self ::$ createdTeams [$ server ] as $ team => $ id ) {
253
+ $ this ->deleteTeam ($ team );
254
+ }
249
255
foreach ($ this ->createdUsers [$ server ] as $ user ) {
250
256
$ this ->deleteUser ($ user );
251
257
}
252
258
foreach ($ this ->createdGroups [$ server ] as $ group ) {
253
259
$ this ->deleteGroup ($ group );
254
260
}
255
- foreach (self ::$ createdTeams [$ server ] as $ team => $ id ) {
256
- $ this ->deleteTeam ($ team );
257
- }
258
261
foreach ($ this ->createdGuestAccountUsers [$ server ] as $ user ) {
259
262
$ this ->deleteGuestUser ($ user );
260
263
}
@@ -914,6 +917,10 @@ protected function assertAttendeeList(string $identifier, ?TableNode $formData,
914
917
$ attendee ['actorId ' ] .= '@ ' . rtrim ($ this ->localRemoteServerUrl , '/ ' );
915
918
}
916
919
920
+ if (isset ($ attendee ['actorId ' ]) && preg_match ('/TEAM_ID\(([^)]+)\)/ ' , $ attendee ['actorId ' ], $ matches )) {
921
+ $ attendee ['actorId ' ] = self ::getTeamIdForLabel ($ this ->currentServer , $ matches [1 ]);
922
+ }
923
+
917
924
if (isset ($ attendee ['sessionIds ' ]) && str_contains ($ attendee ['sessionIds ' ], '@{$LOCAL_URL} ' )) {
918
925
$ attendee ['sessionIds ' ] = str_replace ('{$LOCAL_URL} ' , rtrim ($ this ->localServerUrl , '/ ' ), $ attendee ['sessionIds ' ]);
919
926
}
@@ -1973,7 +1980,7 @@ public function userChangesListableScopeOfTheRoom(string $user, string $identifi
1973
1980
}
1974
1981
1975
1982
/**
1976
- * @Then /^user "([^"]*)" adds (user|group|email|circle| federated_user|phone|team) "([^"]*)" to room "([^"]*)" with (\d+) \((v4)\)$/
1983
+ * @Then /^user "([^"]*)" adds (user|group|email|federated_user|phone|team) "([^"]*)" to room "([^"]*)" with (\d+) \((v4)\)$/
1977
1984
*
1978
1985
* @param string $user
1979
1986
* @param string $newType
@@ -1993,8 +2000,8 @@ public function userAddAttendeeToRoom(string $user, string $newType, string $new
1993
2000
}
1994
2001
}
1995
2002
1996
- if ($ newType === 'circle ' || $ newType === ' team ' ) {
1997
- $ newId = self ::$ createdTeams [ $ this ->currentServer ][ $ newId] ;
2003
+ if ($ newType === 'team ' ) {
2004
+ $ newId = self ::getTeamIdForLabel ( $ this ->currentServer , $ newId) ;
1998
2005
}
1999
2006
2000
2007
$ this ->sendRequest (
@@ -2319,7 +2326,7 @@ public function userSendsMessageToRoom(string $user, string $sendingMode, string
2319
2326
if (str_contains ($ message , '@"TEAM_ID( ' )) {
2320
2327
$ result = preg_match ('/TEAM_ID\(([^)]+)\)/ ' , $ message , $ matches );
2321
2328
if ($ result ) {
2322
- $ message = str_replace ($ matches [0 ], 'team/ ' . self ::$ createdTeams [ $ this ->currentServer ][ $ matches [1 ]] , $ message );
2329
+ $ message = str_replace ($ matches [0 ], 'team/ ' . self ::getTeamIdForLabel ( $ this ->currentServer , $ matches [1 ]) , $ message );
2323
2330
}
2324
2331
}
2325
2332
@@ -3570,7 +3577,7 @@ public function userGetsTheFollowingCollaboratorSuggestions($user, $identifier,
3570
3577
$ expected = array_map (function (array $ mention ): array {
3571
3578
$ result = preg_match ('/TEAM_ID\(([^)]+)\)/ ' , $ mention ['id ' ], $ matches );
3572
3579
if ($ result ) {
3573
- $ mention ['id ' ] = self ::$ createdTeams [ $ this ->currentServer ][ $ matches [1 ]] ;
3580
+ $ mention ['id ' ] = self ::getTeamIdForLabel ( $ this ->currentServer , $ matches [1 ]) ;
3574
3581
}
3575
3582
return $ mention ;
3576
3583
}, $ formData ->getHash ());
@@ -3978,7 +3985,7 @@ private function assertNotifications($notifications, TableNode $formData) {
3978
3985
[$ roomToken , $ message ] = explode ('/ ' , $ expectedNotification ['object_id ' ], 2 );
3979
3986
$ result = preg_match ('/TEAM_ID\(([^)]+)\)/ ' , $ message , $ matches );
3980
3987
if ($ result ) {
3981
- $ message = str_replace ($ matches [0 ], 'team/ ' . self ::$ createdTeams [ $ this ->currentServer ][ $ matches [1 ]] , $ message );
3988
+ $ message = str_replace ($ matches [0 ], 'team/ ' . self ::getTeamIdForLabel ( $ this ->currentServer , $ matches [1 ]) , $ message );
3982
3989
}
3983
3990
$ expectedNotification ['object_id ' ] = $ roomToken . '/ ' . $ message ;
3984
3991
}
@@ -4015,7 +4022,7 @@ private function assertNotifications($notifications, TableNode $formData) {
4015
4022
}
4016
4023
$ result = preg_match ('/TEAM_ID\(([^)]+)\)/ ' , $ expectedNotification ['message ' ], $ matches );
4017
4024
if ($ result ) {
4018
- $ data ['message ' ] = str_replace ($ matches [0 ], self ::$ createdTeams [ $ this ->currentServer ][ $ matches [1 ]] , $ data ['message ' ]);
4025
+ $ data ['message ' ] = str_replace ($ matches [0 ], self ::getTeamIdForLabel ( $ this ->currentServer , $ matches [1 ]) , $ data ['message ' ]);
4019
4026
}
4020
4027
}
4021
4028
if (isset ($ expectedNotification ['object_type ' ])) {
@@ -4289,6 +4296,29 @@ public function assureTeamExists(string $team): void {
4289
4296
self ::$ createdTeams [$ this ->currentServer ][$ team ] = $ data ['id ' ];
4290
4297
}
4291
4298
4299
+ /**
4300
+ * @Given /^User "([^"]*)" creates team "([^"]*)"$/
4301
+ */
4302
+ public function createTeamAsUser (string $ owner , string $ team ): void {
4303
+ $ this ->runOcc (['circles:manage:create ' , '--type ' , '1 ' , '--output ' , 'json ' , $ owner , $ team ]);
4304
+ $ this ->theCommandWasSuccessful ();
4305
+
4306
+ $ output = $ this ->getLastStdOut ();
4307
+ $ data = json_decode ($ output , true );
4308
+
4309
+ self ::$ createdTeams [$ this ->currentServer ][$ team ] = $ data ['id ' ];
4310
+ }
4311
+
4312
+ /**
4313
+ * @Given /^team "([^"]*)" is renamed to "([^"]*)"$/
4314
+ */
4315
+ public function assureTeamRenamed (string $ team , string $ newName ): void {
4316
+ $ id = self ::$ createdTeams [$ this ->currentServer ][$ team ];
4317
+ $ this ->runOcc (['circles:manage:edit ' , $ id , 'displayName ' , $ newName ]);
4318
+ $ this ->theCommandWasSuccessful ();
4319
+ self ::$ renamedTeams [$ this ->currentServer ][$ newName ] = $ id ;
4320
+ }
4321
+
4292
4322
/**
4293
4323
* @Given /^add user "([^"]*)" to team "([^"]*)"$/
4294
4324
*/
0 commit comments