Skip to content

Commit ea8f2eb

Browse files
added tests for adding team + teams_role (#136)
1 parent d3e6bff commit ea8f2eb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/integration/IntegrationTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ public function testUpsertUser()
217217
$this->client->deleteUser($user["id"], ["user" => "hard", "messages" => "hard"]);
218218
}
219219

220+
public function testUpsertUserWithTeam()
221+
{
222+
$user = [
223+
"id" => $this->generateGuid(),
224+
"team" => "blue",
225+
"teams_role" => ["blue" => "admin"]
226+
];
227+
$response = $this->client->upsertUser($user);
228+
$this->assertTrue(array_key_exists("users", (array)$response));
229+
$this->assertTrue(array_key_exists($user["id"], $response["users"]));
230+
$this->assertEquals("blue", $response["users"][$user["id"]]["team"]);
231+
$this->assertEquals("admin", $response["users"][$user["id"]]["teams_role"]["blue"]);
232+
$this->client->deleteUser($user["id"], ["user" => "hard", "messages" => "hard"]);
233+
}
234+
220235
public function testUpsertUsers()
221236
{
222237
$user = ["id" => $this->generateGuid()];
@@ -1188,6 +1203,31 @@ public function testPartialUpdateUsers()
11881203
$this->client->deleteUser($wally["id"], ["user" => "hard", "messages" => "hard"]);
11891204
}
11901205

1206+
public function testPartialUpdateUserWithTeam()
1207+
{
1208+
$user = ["id" => $this->generateGuid(), "name" => "Test User"];
1209+
$response = $this->client->upsertUser($user);
1210+
$this->assertTrue(array_key_exists("users", (array)$response));
1211+
$this->assertTrue(array_key_exists($user["id"], $response["users"]));
1212+
1213+
// Partially update the user with team and teams_role
1214+
$response = $this->client->partialUpdateUser([
1215+
"id" => $user["id"],
1216+
"set" => [
1217+
"team" => "blue",
1218+
"teams_role" => ["blue" => "admin"]
1219+
]
1220+
]);
1221+
1222+
// Verify the changes
1223+
$response = $this->client->queryUsers(["id" => $user["id"]]);
1224+
$this->assertEquals("blue", $response["users"][0]["team"]);
1225+
$this->assertEquals("admin", $response["users"][0]["teams_role"]["blue"]);
1226+
1227+
// Clean up
1228+
$this->client->deleteUser($user["id"], ["user" => "hard", "messages" => "hard"]);
1229+
}
1230+
11911231
public function testChannelMuteUnmute()
11921232
{
11931233
// setup

0 commit comments

Comments
 (0)