@@ -1300,4 +1300,87 @@ public function testUnreadCountsBatch()
13001300 $ this ->assertNotEmpty ($ resp ["counts_by_user " ][$ this ->user1 ["id " ]]["total_unread_threads_count " ]);
13011301 $ this ->assertEquals (1 , $ resp ["counts_by_user " ][$ this ->user1 ["id " ]]["total_unread_threads_count " ]);
13021302 }
1303+
1304+ public function testChannelPin ()
1305+ {
1306+ $ this ->channel ->addMembers ([$ this ->user1 ["id " ]]);
1307+ $ this ->channel ->addMembers ([$ this ->user2 ["id " ]]);
1308+
1309+ // Pin the channel
1310+ $ now = new \DateTime ();
1311+ $ response = $ this ->channel ->pin ($ this ->user1 ["id " ]);
1312+ $ this ->assertNotNull ($ response ["channel_member " ]["pinned_at " ]);
1313+ $ this ->assertGreaterThanOrEqual ($ now ->getTimestamp (), strtotime ($ response ["channel_member " ]["pinned_at " ]));
1314+
1315+ // Query for pinned channel
1316+ $ response = $ this ->client ->queryChannels ([
1317+ "pinned " => true ,
1318+ "cid " => $ this ->channel ->getCID (),
1319+ ], null , [
1320+ "user_id " => $ this ->user1 ["id " ]
1321+ ]);
1322+ $ this ->assertCount (1 , $ response ["channels " ]);
1323+ $ this ->assertEquals ($ this ->channel ->getCID (), $ response ["channels " ][0 ]["channel " ]["cid " ]);
1324+
1325+ // Unpin the channel
1326+ $ response = $ this ->channel ->unpin ($ this ->user1 ["id " ]);
1327+ $ this ->assertArrayNotHasKey ("pinned_at " , $ response ["channel_member " ]);
1328+
1329+ // Query for unpinned channel
1330+ $ response = $ this ->client ->queryChannels ([
1331+ "pinned " => false ,
1332+ "cid " => $ this ->channel ->getCID (),
1333+ ], null , [
1334+ "user_id " => $ this ->user1 ["id " ]
1335+ ]);
1336+ $ this ->assertCount (1 , $ response ["channels " ]);
1337+ $ this ->assertEquals ($ this ->channel ->getCID (), $ response ["channels " ][0 ]["channel " ]["cid " ]);
1338+ }
1339+
1340+ public function testChannelArchive ()
1341+ {
1342+ $ this ->channel ->addMembers ([$ this ->user1 ["id " ]]);
1343+ $ this ->channel ->addMembers ([$ this ->user2 ["id " ]]);
1344+
1345+ // Archive the channel
1346+ $ now = new \DateTime ();
1347+ $ response = $ this ->channel ->archive ($ this ->user1 ["id " ]);
1348+ $ this ->assertNotNull ($ response ["channel_member " ]["archived_at " ]);
1349+ $ this ->assertGreaterThanOrEqual ($ now ->getTimestamp (), strtotime ($ response ["channel_member " ]["archived_at " ]));
1350+
1351+ // Query for archived channel
1352+ $ response = $ this ->client ->queryChannels ([
1353+ "archived " => true ,
1354+ "cid " => $ this ->channel ->getCID (),
1355+ ], null , [
1356+ "user_id " => $ this ->user1 ["id " ]
1357+ ]);
1358+ $ this ->assertCount (1 , $ response ["channels " ]);
1359+ $ this ->assertEquals ($ this ->channel ->getCID (), $ response ["channels " ][0 ]["channel " ]["cid " ]);
1360+
1361+ // Unarchive the channel
1362+ $ response = $ this ->channel ->unarchive ($ this ->user1 ["id " ]);
1363+ $ this ->assertArrayNotHasKey ("archived_at " , $ response ["channel_member " ]);
1364+
1365+ // Query for unarchived channel
1366+ $ response = $ this ->client ->queryChannels ([
1367+ "archived " => false ,
1368+ "cid " => $ this ->channel ->getCID (),
1369+ ], null , [
1370+ "user_id " => $ this ->user1 ["id " ]
1371+ ]);
1372+ $ this ->assertCount (1 , $ response ["channels " ]);
1373+ $ this ->assertEquals ($ this ->channel ->getCID (), $ response ["channels " ][0 ]["channel " ]["cid " ]);
1374+ }
1375+
1376+ public function testChannelUpdateMemberPartial ()
1377+ {
1378+ $ this ->channel ->addMembers ([$ this ->user1 ["id " ]]);
1379+ $ response = $ this ->channel ->updateMemberPartial ($ this ->user1 ["id " ], ["hat " => "blue " ]);
1380+ $ this ->assertEquals ("blue " , $ response ["channel_member " ]["hat " ]);
1381+
1382+ $ response = $ this ->channel ->updateMemberPartial ($ this ->user1 ["id " ], ["color " => "red " ], ["hat " ]);
1383+ $ this ->assertEquals ("red " , $ response ["channel_member " ]["color " ]);
1384+ $ this ->assertArrayNotHasKey ("hat " , $ response ["channel_member " ]);
1385+ }
13031386}
0 commit comments