Skip to content

Commit d244448

Browse files
slavabobikSlava Bobik
andauthored
added restricted visibility tests (#131)
Co-authored-by: Slava Bobik <[email protected]>
1 parent 1f0688c commit d244448

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

tests/integration/IntegrationTest.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,4 +1392,72 @@ public function testChannelUpdateMemberPartial()
13921392
$this->assertEquals("red", $response["channel_member"]["color"]);
13931393
$this->assertArrayNotHasKey("hat", $response["channel_member"]);
13941394
}
1395+
1396+
public function testSendMessageWithRestrictedVisibility()
1397+
{
1398+
$this->channel->addMembers([$this->user1["id"], $this->user2["id"]]);
1399+
$msg = [
1400+
"text" => "secret message",
1401+
"restricted_visibility" => [$this->user1["id"]]
1402+
];
1403+
1404+
1405+
$response = $this->channel->sendMessage($msg, $this->user1["id"]);
1406+
$this->assertNotNull($response["message"]["restricted_visibility"]);
1407+
$this->assertEquals([$this->user1["id"]], $response["message"]["restricted_visibility"]);
1408+
1409+
}
1410+
1411+
public function testUpdateMessageWithRestrictedVisibility()
1412+
{
1413+
$this->channel->addMembers([$this->user1["id"], $this->user2["id"]]);
1414+
1415+
// First send a regular message
1416+
$msgId = $this->generateGuid();
1417+
$msg = [
1418+
"id" => $msgId,
1419+
"text" => "original message"
1420+
];
1421+
$response = $this->channel->sendMessage($msg, $this->user1["id"]);
1422+
1423+
// Then update it with restricted visibility
1424+
$updatedMsg = [
1425+
"id" => $msgId,
1426+
"text" => "updated secret message",
1427+
"restricted_visibility" => [$this->user1["id"]],
1428+
"user" => ["id" => $this->user1["id"]]
1429+
];
1430+
1431+
$response = $this->client->updateMessage($updatedMsg);
1432+
$this->assertNotNull($response["message"]["restricted_visibility"]);
1433+
$this->assertEquals([$this->user1["id"]], $response["message"]["restricted_visibility"]);
1434+
}
1435+
1436+
public function testUpdateMessagePartialWithRestrictedVisibility()
1437+
{
1438+
$this->channel->addMembers([$this->user1["id"], $this->user2["id"]]);
1439+
1440+
// First send a regular message
1441+
$msgId = $this->generateGuid();
1442+
$msg = [
1443+
"id" => $msgId,
1444+
"text" => "original message"
1445+
];
1446+
$response = $this->channel->sendMessage($msg, $this->user1["id"]);
1447+
1448+
// Then do a partial update with restricted visibility
1449+
$response = $this->client->partialUpdateMessage(
1450+
$msgId,
1451+
[
1452+
"set" => [
1453+
"text" => "partially updated secret message",
1454+
"restricted_visibility" => [$this->user1["id"]]
1455+
]
1456+
],
1457+
$this->user1["id"]
1458+
);
1459+
1460+
$this->assertNotNull($response["message"]["restricted_visibility"]);
1461+
$this->assertEquals([$this->user1["id"]], $response["message"]["restricted_visibility"]);
1462+
}
13951463
}

0 commit comments

Comments
 (0)