@@ -1550,9 +1550,17 @@ public function testExportUsers()
15501550
15511551 public function testQueryThreadsWithFilter ()
15521552 {
1553+ // Create a fresh channel with both users as members
1554+ $ testChannel = $ this ->client ->Channel (
1555+ "messaging " ,
1556+ $ this ->generateGuid (),
1557+ ["test " => true , "language " => "php " ]
1558+ );
1559+ $ testChannel ->create ($ this ->user1 ["id " ], [$ this ->user1 ["id " ], $ this ->user2 ["id " ]]);
1560+
15531561 // Create a thread by sending a message with a parent_id
1554- $ parentMessage = $ this -> channel ->sendMessage (["text " => "Parent message " ], $ this ->user1 ["id " ]);
1555- $ threadMessage = $ this -> channel ->sendMessage (
1562+ $ parentMessage = $ testChannel ->sendMessage (["text " => "Parent message " ], $ this ->user1 ["id " ]);
1563+ $ threadMessage = $ testChannel ->sendMessage (
15561564 ["text " => "Thread message " , "parent_id " => $ parentMessage ["message " ]["id " ]],
15571565 $ this ->user2 ["id " ]
15581566 );
@@ -1567,19 +1575,30 @@ public function testQueryThreadsWithFilter()
15671575 // Verify the response
15681576 $ this ->assertTrue (array_key_exists ("threads " , (array )$ response ));
15691577 $ this ->assertGreaterThanOrEqual (1 , count ($ response ["threads " ]));
1578+
1579+ // Cleanup
1580+ $ testChannel ->delete ();
15701581 }
15711582
15721583 public function testQueryThreadsWithSort ()
15731584 {
1585+ // Create a fresh channel with both users as members
1586+ $ testChannel = $ this ->client ->Channel (
1587+ "messaging " ,
1588+ $ this ->generateGuid (),
1589+ ["test " => true , "language " => "php " ]
1590+ );
1591+ $ testChannel ->create ($ this ->user1 ["id " ], [$ this ->user1 ["id " ], $ this ->user2 ["id " ]]);
1592+
15741593 // Create multiple threads
1575- $ parentMessage1 = $ this -> channel ->sendMessage (["text " => "Parent message 1 " ], $ this ->user1 ["id " ]);
1576- $ threadMessage1 = $ this -> channel ->sendMessage (
1594+ $ parentMessage1 = $ testChannel ->sendMessage (["text " => "Parent message 1 " ], $ this ->user1 ["id " ]);
1595+ $ threadMessage1 = $ testChannel ->sendMessage (
15771596 ["text " => "Thread message 1 " , "parent_id " => $ parentMessage1 ["message " ]["id " ]],
15781597 $ this ->user2 ["id " ]
15791598 );
15801599
1581- $ parentMessage2 = $ this -> channel ->sendMessage (["text " => "Parent message 2 " ], $ this ->user1 ["id " ]);
1582- $ threadMessage2 = $ this -> channel ->sendMessage (
1600+ $ parentMessage2 = $ testChannel ->sendMessage (["text " => "Parent message 2 " ], $ this ->user1 ["id " ]);
1601+ $ threadMessage2 = $ testChannel ->sendMessage (
15831602 ["text " => "Thread message 2 " , "parent_id " => $ parentMessage2 ["message " ]["id " ]],
15841603 $ this ->user2 ["id " ]
15851604 );
@@ -1594,19 +1613,30 @@ public function testQueryThreadsWithSort()
15941613 // Verify the response
15951614 $ this ->assertTrue (array_key_exists ("threads " , (array )$ response ));
15961615 $ this ->assertGreaterThanOrEqual (2 , count ($ response ["threads " ]));
1616+
1617+ // Cleanup
1618+ $ testChannel ->delete ();
15971619 }
15981620
15991621 public function testQueryThreadsWithFilterAndSort ()
16001622 {
1623+ // Create a fresh channel with both users as members
1624+ $ testChannel = $ this ->client ->Channel (
1625+ "messaging " ,
1626+ $ this ->generateGuid (),
1627+ ["test " => true , "language " => "php " ]
1628+ );
1629+ $ testChannel ->create ($ this ->user1 ["id " ], [$ this ->user1 ["id " ], $ this ->user2 ["id " ]]);
1630+
16011631 // Create multiple threads
1602- $ parentMessage1 = $ this -> channel ->sendMessage (["text " => "Parent message 1 " ], $ this ->user1 ["id " ]);
1603- $ threadMessage1 = $ this -> channel ->sendMessage (
1632+ $ parentMessage1 = $ testChannel ->sendMessage (["text " => "Parent message 1 " ], $ this ->user1 ["id " ]);
1633+ $ threadMessage1 = $ testChannel ->sendMessage (
16041634 ["text " => "Thread message 1 " , "parent_id " => $ parentMessage1 ["message " ]["id " ]],
16051635 $ this ->user2 ["id " ]
16061636 );
16071637
1608- $ parentMessage2 = $ this -> channel ->sendMessage (["text " => "Parent message 2 " ], $ this ->user1 ["id " ]);
1609- $ threadMessage2 = $ this -> channel ->sendMessage (
1638+ $ parentMessage2 = $ testChannel ->sendMessage (["text " => "Parent message 2 " ], $ this ->user1 ["id " ]);
1639+ $ threadMessage2 = $ testChannel ->sendMessage (
16101640 ["text " => "Thread message 2 " , "parent_id " => $ parentMessage2 ["message " ]["id " ]],
16111641 $ this ->user2 ["id " ]
16121642 );
@@ -1621,13 +1651,24 @@ public function testQueryThreadsWithFilterAndSort()
16211651 // Verify the response
16221652 $ this ->assertTrue (array_key_exists ("threads " , (array )$ response ));
16231653 $ this ->assertGreaterThanOrEqual (2 , count ($ response ["threads " ]));
1654+
1655+ // Cleanup
1656+ $ testChannel ->delete ();
16241657 }
16251658
16261659 public function testQueryThreadsWithoutFilterAndSort ()
16271660 {
1661+ // Create a fresh channel with both users as members
1662+ $ testChannel = $ this ->client ->Channel (
1663+ "messaging " ,
1664+ $ this ->generateGuid (),
1665+ ["test " => true , "language " => "php " ]
1666+ );
1667+ $ testChannel ->create ($ this ->user1 ["id " ], [$ this ->user1 ["id " ], $ this ->user2 ["id " ]]);
1668+
16281669 // Create a thread by sending a message with a parent_id
1629- $ parentMessage = $ this -> channel ->sendMessage (["text " => "Parent message for no filter test " ], $ this ->user1 ["id " ]);
1630- $ threadMessage = $ this -> channel ->sendMessage (
1670+ $ parentMessage = $ testChannel ->sendMessage (["text " => "Parent message for no filter test " ], $ this ->user1 ["id " ]);
1671+ $ threadMessage = $ testChannel ->sendMessage (
16311672 ["text " => "Thread message for no filter test " , "parent_id " => $ parentMessage ["message " ]["id " ]],
16321673 $ this ->user2 ["id " ]
16331674 );
@@ -1642,6 +1683,9 @@ public function testQueryThreadsWithoutFilterAndSort()
16421683 // Verify the response
16431684 $ this ->assertTrue (array_key_exists ("threads " , (array )$ response ));
16441685 $ this ->assertGreaterThanOrEqual (1 , count ($ response ["threads " ]));
1686+
1687+ // Cleanup
1688+ $ testChannel ->delete ();
16451689 }
16461690
16471691 public function testCreateDraft ()
0 commit comments