Skip to content

Commit f62fe75

Browse files
committed
add tests
1 parent f020c05 commit f62fe75

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

lib/GetStream/StreamChat/Channel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public function queryMembers($filterConditions, $sort = null, $options = null)
210210
$options["type"] = $this->channelType;
211211
$options["filter_conditions"] = $filterConditions;
212212
$options["sort"] = $sortFields;
213-
return $this->get("members", ["payload" => json_encode($options)]);
213+
return $this->client->get("members", ["payload" => json_encode($options)]);
214214
}
215215

216216
/**

tests/integration/IntegrationTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,52 @@ public function testQueryChannelsMembersIn()
304304
$this->assertSame(count($response["channels"][0]["members"]), 9);
305305
}
306306

307+
public function testQueryMembers()
308+
{
309+
$bob = ["id" => Uuid::uuid4()->toString(), "name" => "bob the builder"];
310+
$bobSponge = ["id" => Uuid::uuid4()->toString(), "name" => "bob the sponge"];
311+
$this->client->updateUsers([$bob, $bobSponge]);
312+
$channel = $this->client->Channel(
313+
"messaging",
314+
Uuid::uuid4()->toString(),
315+
["members" => [$bob["id"], $bobSponge["id"]]]
316+
);
317+
$channel->create($bob["id"]);
318+
319+
$response = $channel->queryMembers(["id" => $bob["id"]]);
320+
$this->assertSame(count($response["members"]), 1);
321+
$this->assertSame($response["members"][0]["user_id"], $bob["id"]);
322+
323+
$response = $channel->queryMembers(["name" => ['$autocomplete' => "bob"]], []);
324+
$this->assertSame(count($response["members"]), 2);
325+
326+
$response = $channel->queryMembers(["name" => ['$autocomplete' => "bob"]], [], ["limit" => 1]);
327+
$this->assertSame(count($response["members"]), 1);
328+
}
329+
330+
public function testQueryMembersMemberBasedChannel()
331+
{
332+
$bob = ["id" => Uuid::uuid4()->toString(), "name" => "bob the builder"];
333+
$bobSponge = ["id" => Uuid::uuid4()->toString(), "name" => "bob the sponge"];
334+
$this->client->updateUsers([$bob, $bobSponge]);
335+
$channel = $this->client->Channel(
336+
"messaging",
337+
null,
338+
["members" => [$bob["id"], $bobSponge["id"]]]
339+
);
340+
$channel->create($bob["id"]);
341+
342+
$response = $channel->queryMembers(["id" => $bob["id"]]);
343+
$this->assertSame(count($response["members"]), 1);
344+
$this->assertSame($response["members"][0]["user_id"], $bob["id"]);
345+
346+
$response = $channel->queryMembers(["name" => ['$autocomplete' => "bob"]], []);
347+
$this->assertSame(count($response["members"]), 2);
348+
349+
$response = $channel->queryMembers(["name" => ['$autocomplete' => "bob"]], [], ["limit" => 1]);
350+
$this->assertSame(count($response["members"]), 1);
351+
}
352+
307353
public function testDevices()
308354
{
309355
$user = $this->getUser();

0 commit comments

Comments
 (0)