@@ -978,10 +978,10 @@ public function test_search_no_implicit_wildcard() {
978978 }
979979
980980 /**
981- * Test the implicit wildcard search functionality.
981+ * Test the wildcard search functionality when wildcardstart is enabled .
982982 */
983- public function test_search_implicit_wildcard () {
984- set_config ('implicitwildcard ' , 1 , 'search_elastic ' );
983+ public function test_search_wildcardstart_enabled () {
984+ set_config ('wildcardstart ' , 1 , 'search_elastic ' );
985985
986986 // Construct the search object and add it to the engine.
987987 $ rec = new \stdClass ();
@@ -997,7 +997,41 @@ public function test_search_implicit_wildcard() {
997997
998998 // This is a mock of the search form submission.
999999 $ querydata = new stdClass ();
1000- $ querydata ->q = 'frog ' ;
1000+ $ querydata ->q = 'ogs ' ;
1001+ $ querydata ->timestart = 0 ;
1002+ $ querydata ->timeend = 0 ;
1003+
1004+ // Execute the search.
1005+ $ results = $ this ->search ->search ($ querydata );
1006+
1007+ // Check the results.
1008+ $ this ->assertEquals (count ($ results ), 1 );
1009+ $ this ->assertEquals ($ results [0 ]->get ('content ' ), 'this is an assignment on @@HI_S@@frogs@@HI_E@@ and toads ' );
1010+
1011+ }
1012+
1013+
1014+ /**
1015+ * Test the wildcard search functionality when wildcardend is enabled.
1016+ */
1017+ public function test_search_wildcardend_enabled () {
1018+ set_config ('wildcardend ' , 1 , 'search_elastic ' );
1019+
1020+ // Construct the search object and add it to the engine.
1021+ $ rec = new \stdClass ();
1022+ $ rec ->content = "this is an assignment on frogs and toads " ;
1023+ $ area = $ this ->area ;
1024+ $ record = $ this ->generator ->create_record ($ rec );
1025+ $ doc = $ area ->get_document ($ record );
1026+ $ this ->engine ->add_document ($ doc );
1027+
1028+ // We need to wait for Elastic search to update its index
1029+ // this happens in near realtime, not immediately.
1030+ sleep (1 );
1031+
1032+ // This is a mock of the search form submission.
1033+ $ querydata = new stdClass ();
1034+ $ querydata ->q = 'fro ' ;
10011035 $ querydata ->timestart = 0 ;
10021036 $ querydata ->timeend = 0 ;
10031037
0 commit comments