@@ -690,6 +690,55 @@ public function testSearch()
690690 $ this ->assertSame (count ($ response ['results ' ]), 1 );
691691 }
692692
693+ public function testSearchOffsetAndSortFails ()
694+ {
695+ $ this ->expectException (\GetStream \StreamChat \StreamException::class);
696+ $ query = "supercalifragilisticexpialidocious " ;
697+ $ this ->client ->search (
698+ ["type " => "messaging " ],
699+ $ query ,
700+ ["sort " => [["created_at " =>-1 ]], "offset " => 1 ]
701+ );
702+ }
703+
704+ public function testSearchOffsetAndNextFails ()
705+ {
706+ $ this ->expectException (\GetStream \StreamChat \StreamException::class);
707+ $ query = "supercalifragilisticexpialidocious " ;
708+ $ this ->client ->search (
709+ ["type " => "messaging " ],
710+ $ query ,
711+ ["next " => $ query , "offset " => 1 ]
712+ );
713+ }
714+
715+
716+ public function testSearchWithSort ()
717+ {
718+ $ this ->markTestSkipped ();
719+ $ user = $ this ->getUser ();
720+ $ channel = $ this ->getChannel ();
721+ $ query = "supercalifragilisticexpialidocious " ;
722+ $ channel ->sendMessage (["text " => "How many syllables are there in " . $ query . "? " ], $ user ["id " ]);
723+ $ channel ->sendMessage (["text " => "Does " . $ query . " count as one or two? " ], $ user ["id " ]);
724+ $ response = $ this ->client ->search (
725+ ["type " => "messaging " ],
726+ $ query ,
727+ ["sort " => [["created_at " => -1 ]], "limit " => 1 ]
728+ );
729+ // searches all channels so make sure at least one is found
730+ $ this ->assertTrue (count ($ response ['results ' ]) >= 1 );
731+ $ this ->assertTrue (strpos ($ response ['results ' ][0 ]['message ' ]['text ' ], $ query )!==false );
732+ $ response = $ this ->client ->search (
733+ ["type " => "messaging " ],
734+ $ query ,
735+ ["limit " => 1 , "next " => $ response ['next ' ]]
736+ );
737+ $ this ->assertTrue (count ($ response ['results ' ]) >= 1 );
738+ $ this ->assertTrue (strpos ($ response ['results ' ][0 ]['message ' ]['text ' ], $ query )!==false );
739+ }
740+
741+
693742 public function testGetMessage ()
694743 {
695744 $ user = $ this ->getUser ();
0 commit comments