@@ -1534,9 +1534,17 @@ public function testExportUsers()
15341534
15351535 public function testQueryThreadsWithFilter ()
15361536 {
1537+ // Create a fresh channel with both users as members
1538+ $ testChannel = $ this ->client ->Channel (
1539+ "messaging " ,
1540+ $ this ->generateGuid (),
1541+ ["test " => true , "language " => "php " ]
1542+ );
1543+ $ testChannel ->create ($ this ->user1 ["id " ], [$ this ->user1 ["id " ], $ this ->user2 ["id " ]]);
1544+
15371545 // Create a thread by sending a message with a parent_id
1538- $ parentMessage = $ this -> channel ->sendMessage (["text " => "Parent message " ], $ this ->user1 ["id " ]);
1539- $ threadMessage = $ this -> channel ->sendMessage (
1546+ $ parentMessage = $ testChannel ->sendMessage (["text " => "Parent message " ], $ this ->user1 ["id " ]);
1547+ $ threadMessage = $ testChannel ->sendMessage (
15401548 ["text " => "Thread message " , "parent_id " => $ parentMessage ["message " ]["id " ]],
15411549 $ this ->user2 ["id " ]
15421550 );
@@ -1551,19 +1559,30 @@ public function testQueryThreadsWithFilter()
15511559 // Verify the response
15521560 $ this ->assertTrue (array_key_exists ("threads " , (array )$ response ));
15531561 $ this ->assertGreaterThanOrEqual (1 , count ($ response ["threads " ]));
1562+
1563+ // Cleanup
1564+ $ testChannel ->delete ();
15541565 }
15551566
15561567 public function testQueryThreadsWithSort ()
15571568 {
1569+ // Create a fresh channel with both users as members
1570+ $ testChannel = $ this ->client ->Channel (
1571+ "messaging " ,
1572+ $ this ->generateGuid (),
1573+ ["test " => true , "language " => "php " ]
1574+ );
1575+ $ testChannel ->create ($ this ->user1 ["id " ], [$ this ->user1 ["id " ], $ this ->user2 ["id " ]]);
1576+
15581577 // Create multiple threads
1559- $ parentMessage1 = $ this -> channel ->sendMessage (["text " => "Parent message 1 " ], $ this ->user1 ["id " ]);
1560- $ threadMessage1 = $ this -> channel ->sendMessage (
1578+ $ parentMessage1 = $ testChannel ->sendMessage (["text " => "Parent message 1 " ], $ this ->user1 ["id " ]);
1579+ $ threadMessage1 = $ testChannel ->sendMessage (
15611580 ["text " => "Thread message 1 " , "parent_id " => $ parentMessage1 ["message " ]["id " ]],
15621581 $ this ->user2 ["id " ]
15631582 );
15641583
1565- $ parentMessage2 = $ this -> channel ->sendMessage (["text " => "Parent message 2 " ], $ this ->user1 ["id " ]);
1566- $ threadMessage2 = $ this -> channel ->sendMessage (
1584+ $ parentMessage2 = $ testChannel ->sendMessage (["text " => "Parent message 2 " ], $ this ->user1 ["id " ]);
1585+ $ threadMessage2 = $ testChannel ->sendMessage (
15671586 ["text " => "Thread message 2 " , "parent_id " => $ parentMessage2 ["message " ]["id " ]],
15681587 $ this ->user2 ["id " ]
15691588 );
@@ -1578,19 +1597,30 @@ public function testQueryThreadsWithSort()
15781597 // Verify the response
15791598 $ this ->assertTrue (array_key_exists ("threads " , (array )$ response ));
15801599 $ this ->assertGreaterThanOrEqual (2 , count ($ response ["threads " ]));
1600+
1601+ // Cleanup
1602+ $ testChannel ->delete ();
15811603 }
15821604
15831605 public function testQueryThreadsWithFilterAndSort ()
15841606 {
1607+ // Create a fresh channel with both users as members
1608+ $ testChannel = $ this ->client ->Channel (
1609+ "messaging " ,
1610+ $ this ->generateGuid (),
1611+ ["test " => true , "language " => "php " ]
1612+ );
1613+ $ testChannel ->create ($ this ->user1 ["id " ], [$ this ->user1 ["id " ], $ this ->user2 ["id " ]]);
1614+
15851615 // Create multiple threads
1586- $ parentMessage1 = $ this -> channel ->sendMessage (["text " => "Parent message 1 " ], $ this ->user1 ["id " ]);
1587- $ threadMessage1 = $ this -> channel ->sendMessage (
1616+ $ parentMessage1 = $ testChannel ->sendMessage (["text " => "Parent message 1 " ], $ this ->user1 ["id " ]);
1617+ $ threadMessage1 = $ testChannel ->sendMessage (
15881618 ["text " => "Thread message 1 " , "parent_id " => $ parentMessage1 ["message " ]["id " ]],
15891619 $ this ->user2 ["id " ]
15901620 );
15911621
1592- $ parentMessage2 = $ this -> channel ->sendMessage (["text " => "Parent message 2 " ], $ this ->user1 ["id " ]);
1593- $ threadMessage2 = $ this -> channel ->sendMessage (
1622+ $ parentMessage2 = $ testChannel ->sendMessage (["text " => "Parent message 2 " ], $ this ->user1 ["id " ]);
1623+ $ threadMessage2 = $ testChannel ->sendMessage (
15941624 ["text " => "Thread message 2 " , "parent_id " => $ parentMessage2 ["message " ]["id " ]],
15951625 $ this ->user2 ["id " ]
15961626 );
@@ -1605,13 +1635,24 @@ public function testQueryThreadsWithFilterAndSort()
16051635 // Verify the response
16061636 $ this ->assertTrue (array_key_exists ("threads " , (array )$ response ));
16071637 $ this ->assertGreaterThanOrEqual (2 , count ($ response ["threads " ]));
1638+
1639+ // Cleanup
1640+ $ testChannel ->delete ();
16081641 }
16091642
16101643 public function testQueryThreadsWithoutFilterAndSort ()
16111644 {
1645+ // Create a fresh channel with both users as members
1646+ $ testChannel = $ this ->client ->Channel (
1647+ "messaging " ,
1648+ $ this ->generateGuid (),
1649+ ["test " => true , "language " => "php " ]
1650+ );
1651+ $ testChannel ->create ($ this ->user1 ["id " ], [$ this ->user1 ["id " ], $ this ->user2 ["id " ]]);
1652+
16121653 // Create a thread by sending a message with a parent_id
1613- $ parentMessage = $ this -> channel ->sendMessage (["text " => "Parent message for no filter test " ], $ this ->user1 ["id " ]);
1614- $ threadMessage = $ this -> channel ->sendMessage (
1654+ $ parentMessage = $ testChannel ->sendMessage (["text " => "Parent message for no filter test " ], $ this ->user1 ["id " ]);
1655+ $ threadMessage = $ testChannel ->sendMessage (
16151656 ["text " => "Thread message for no filter test " , "parent_id " => $ parentMessage ["message " ]["id " ]],
16161657 $ this ->user2 ["id " ]
16171658 );
@@ -1626,6 +1667,9 @@ public function testQueryThreadsWithoutFilterAndSort()
16261667 // Verify the response
16271668 $ this ->assertTrue (array_key_exists ("threads " , (array )$ response ));
16281669 $ this ->assertGreaterThanOrEqual (1 , count ($ response ["threads " ]));
1670+
1671+ // Cleanup
1672+ $ testChannel ->delete ();
16291673 }
16301674
16311675 public function testCreateDraft ()
0 commit comments