2222 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323 */
2424
25+ namespace search_elastic ;
26+
2527defined ('MOODLE_INTERNAL ' ) || die ();
2628
2729global $ CFG ;
4042 * @package search_elastic
4143 * @copyright Matt Porritt <mattp@catalyst-au.net>
4244 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
45+ * @covers \search_elastic\engine
4346 */
44- class search_elastic_engine_testcase extends advanced_testcase {
47+ class engine_test extends \ advanced_testcase {
4548 /**
4649 * @var \core_search::manager
4750 */
@@ -89,13 +92,13 @@ public function setUp(): void {
8992 $ this ->generator ->setup ();
9093
9194 $ this ->engine = new \search_elastic \testable_engine ();
92- $ this ->search = testable_core_search::instance ($ this ->engine );
95+ $ this ->search = \ testable_core_search::instance ($ this ->engine );
9396 $ areaid = \core_search \manager::generate_areaid ('core_mocksearch ' , 'mock_search_area ' );
94- $ this ->search ->add_search_area ($ areaid , new core_mocksearch \search \mock_search_area ());
95- $ this ->area = new core_mocksearch \search \mock_search_area ();
97+ $ this ->search ->add_search_area ($ areaid , new \ core_mocksearch \search \mock_search_area ());
98+ $ this ->area = new \ core_mocksearch \search \mock_search_area ();
9699 $ areaboostid = \core_search \manager::generate_areaid ('core_mocksearch ' , 'mock_boost_area ' );
97- $ this ->search ->add_search_area ($ areaboostid , new core_mocksearch \search \mock_boost_area ());
98- $ this ->areaboost = new core_mocksearch \search \mock_boost_area ();
100+ $ this ->search ->add_search_area ($ areaboostid , new \ core_mocksearch \search \mock_boost_area ());
101+ $ this ->areaboost = new \ core_mocksearch \search \mock_boost_area ();
99102
100103 $ this ->setAdminUser ();
101104 $ this ->search ->index (true );
@@ -134,7 +137,7 @@ public function test_is_server_ready() {
134137 $ stack = HandlerStack::create ($ mock );
135138
136139 // Reflection magic as we are directly testing a private method.
137- $ method = new ReflectionMethod ('\search_elastic\engine ' , 'is_server_ready ' );
140+ $ method = new \ ReflectionMethod ('\search_elastic\engine ' , 'is_server_ready ' );
138141 $ method ->setAccessible (true ); // Allow accessing of private method.
139142 $ proxy = $ method ->invoke (new \search_elastic \engine , $ stack );
140143
@@ -155,7 +158,7 @@ public function test_is_server_ready_false() {
155158 $ stack = HandlerStack::create ($ mock );
156159
157160 // Reflection magic as we are directly testing a private method.
158- $ method = new ReflectionMethod ('\search_elastic\engine ' , 'is_server_ready ' );
161+ $ method = new \ ReflectionMethod ('\search_elastic\engine ' , 'is_server_ready ' );
159162 $ method ->setAccessible (true ); // Allow accessing of private method.
160163 $ proxy = $ method ->invoke (new \search_elastic \engine , $ stack );
161164
@@ -174,7 +177,7 @@ public function test_delete_by_areaid() {
174177 // Construct the search object and add it to the engine.
175178 $ rec = new \stdClass ();
176179 $ rec ->content = "elastic " ;
177- $ area = new core_mocksearch \search \mock_search_area ();
180+ $ area = new \ core_mocksearch \search \mock_search_area ();
178181 $ record = $ this ->generator ->create_record ($ rec );
179182 $ doc = $ area ->get_document ($ record );
180183 $ this ->engine ->add_document ($ doc );
@@ -189,7 +192,7 @@ public function test_delete_by_areaid() {
189192 sleep (1 );
190193
191194 // This is a mock of the search form submission.
192- $ querydata = new stdClass ();
195+ $ querydata = new \ stdClass ();
193196 $ querydata ->q = 'elastic ' ;
194197 $ querydata ->timestart = 0 ;
195198 $ querydata ->timeend = 0 ;
@@ -252,7 +255,7 @@ public function test_basic_search() {
252255 sleep (1 );
253256
254257 // This is a mock of the search form submission.
255- $ querydata = new stdClass ();
258+ $ querydata = new \ stdClass ();
256259 $ querydata ->q = 'elastic ' ;
257260 $ querydata ->timestart = 0 ;
258261 $ querydata ->timeend = 0 ;
@@ -284,7 +287,7 @@ public function test_multi_term_search() {
284287
285288 // This is a mock of the search form submission.
286289 // Multi term in order query.
287- $ querydata = new stdClass ();
290+ $ querydata = new \ stdClass ();
288291 $ querydata ->q = 'test quiz ' ;
289292 $ querydata ->timestart = 0 ;
290293 $ querydata ->timeend = 0 ;
@@ -295,7 +298,7 @@ public function test_multi_term_search() {
295298 'this is a @@HI_S@@test@@HI_E@@ @@HI_S@@quiz@@HI_E@@ on frogs and toads ' ); // Check the results.
296299
297300 // Multi term out of order query.
298- $ querydata = new stdClass ();
301+ $ querydata = new \ stdClass ();
299302 $ querydata ->q = 'quiz test ' ;
300303 $ querydata ->timestart = 0 ;
301304 $ querydata ->timeend = 0 ;
@@ -306,7 +309,7 @@ public function test_multi_term_search() {
306309 'this is a @@HI_S@@test@@HI_E@@ @@HI_S@@quiz@@HI_E@@ on frogs and toads ' ); // Check the results.
307310
308311 // Multi term partial words query.
309- $ querydata = new stdClass ();
312+ $ querydata = new \ stdClass ();
310313 $ querydata ->q = 'test frogs ' ;
311314 $ querydata ->timestart = 0 ;
312315 $ querydata ->timeend = 0 ;
@@ -351,7 +354,7 @@ public function test_modifier_search() {
351354
352355 // This is a mock of the search form submission.
353356 // Multi term in order query.
354- $ querydata = new stdClass ();
357+ $ querydata = new \ stdClass ();
355358 $ querydata ->q = 'assignment AND frogs ' ;
356359 $ querydata ->timestart = 0 ;
357360 $ querydata ->timeend = 0 ;
@@ -363,7 +366,7 @@ public function test_modifier_search() {
363366 $ this ->assertEquals (count ($ results ), 1 );
364367
365368 // Multi term out of order query.
366- $ querydata = new stdClass ();
369+ $ querydata = new \ stdClass ();
367370 $ querydata ->q = 'assignment OR fish ' ;
368371 $ querydata ->timestart = 0 ;
369372 $ querydata ->timeend = 0 ;
@@ -402,7 +405,7 @@ public function test_course_filter_search() {
402405 sleep (1 );
403406
404407 // This is a mock of the search form submission.
405- $ querydata = new stdClass ();
408+ $ querydata = new \ stdClass ();
406409 $ querydata ->q = 'assignment on frogs ' ;
407410 $ querydata ->timestart = 0 ;
408411 $ querydata ->timeend = 0 ;
@@ -435,7 +438,7 @@ public function test_area_filter_search() {
435438 sleep (1 );
436439
437440 // This is a mock of the search form submission.
438- $ querydata = new stdClass ();
441+ $ querydata = new \ stdClass ();
439442 $ querydata ->q = 'assignment on frogs ' ;
440443 $ querydata ->timestart = 0 ;
441444 $ querydata ->timeend = 0 ;
@@ -444,7 +447,7 @@ public function test_area_filter_search() {
444447 $ results = $ this ->search ->search ($ querydata ); // Execute the search.
445448 $ this ->assertEquals (count ($ results ), 0 );
446449
447- $ querydata = new stdClass ();
450+ $ querydata = new \ stdClass ();
448451 $ querydata ->q = 'assignment on frogs ' ;
449452 $ querydata ->timestart = 0 ;
450453 $ querydata ->timeend = 0 ;
@@ -483,7 +486,7 @@ public function test_course_area_filter_search() {
483486 sleep (1 );
484487
485488 // This is a mock of the search form submission.
486- $ querydata = new stdClass ();
489+ $ querydata = new \ stdClass ();
487490 $ querydata ->q = 'assignment on frogs ' ;
488491 $ querydata ->timestart = 0 ;
489492 $ querydata ->timeend = 0 ;
@@ -532,7 +535,7 @@ public function test_course_area_boosting() {
532535 sleep (1 );
533536
534537 // This is a mock of the search form submission.
535- $ querydata = new stdClass ();
538+ $ querydata = new \ stdClass ();
536539 $ querydata ->q = 'assignment frogs ' ;
537540 $ querydata ->timestart = 0 ;
538541 $ querydata ->timeend = 0 ;
@@ -588,7 +591,7 @@ public function test_location_boosting() {
588591 sleep (1 );
589592
590593 // This is a mock of the search form submission.
591- $ querydata = new stdClass ();
594+ $ querydata = new \ stdClass ();
592595 $ querydata ->q = 'fish and frogs ' ;
593596 $ querydata ->timestart = 0 ;
594597 $ querydata ->timeend = 0 ;
@@ -643,7 +646,7 @@ public function test_location_boosting_activity() {
643646 sleep (1 );
644647
645648 // This is a mock of the search form submission.
646- $ querydata = new stdClass ();
649+ $ querydata = new \ stdClass ();
647650 $ querydata ->q = 'fish and frogs ' ;
648651 $ querydata ->timestart = 0 ;
649652 $ querydata ->timeend = 0 ;
@@ -690,7 +693,7 @@ public function test_timestart_search() {
690693 sleep (1 );
691694
692695 // This is a mock of the search form submission.
693- $ querydata = new stdClass ();
696+ $ querydata = new \ stdClass ();
694697 $ querydata ->q = '* ' ;
695698 $ querydata ->timestart = 123457 ;
696699 $ querydata ->timeend = 0 ;
@@ -730,7 +733,7 @@ public function test_timeend_search() {
730733 sleep (1 );
731734
732735 // This is a mock of the search form submission.
733- $ querydata = new stdClass ();
736+ $ querydata = new \ stdClass ();
734737 $ querydata ->q = '* ' ;
735738 $ querydata ->timestart = 0 ;
736739 $ querydata ->timeend = 123457 ;
@@ -770,7 +773,7 @@ public function test_timestart_timeend_search() {
770773 sleep (1 );
771774
772775 // This is a mock of the search form submission.
773- $ querydata = new stdClass ();
776+ $ querydata = new \ stdClass ();
774777 $ querydata ->q = '* ' ;
775778 $ querydata ->timestart = 123457 ;
776779 $ querydata ->timeend = 123458 ;
@@ -809,7 +812,7 @@ public function test_result_timesort_asc() {
809812 sleep (1 );
810813
811814 // This is a mock of the search form submission.
812- $ querydata = new stdClass ();
815+ $ querydata = new \ stdClass ();
813816 $ querydata ->q = '* ' ;
814817 $ querydata ->timestart = 0 ;
815818 $ querydata ->timeend = 0 ;
@@ -852,7 +855,7 @@ public function test_result_timesort_desc() {
852855 sleep (1 );
853856
854857 // This is a mock of the search form submission.
855- $ querydata = new stdClass ();
858+ $ querydata = new \ stdClass ();
856859 $ querydata ->q = '* ' ;
857860 $ querydata ->timestart = 0 ;
858861 $ querydata ->timeend = 0 ;
@@ -894,7 +897,7 @@ public function test_user_filter_search() {
894897 sleep (1 );
895898
896899 // This is a mock of the search form submission.
897- $ querydata = new stdClass ();
900+ $ querydata = new \ stdClass ();
898901 $ querydata ->q = 'assignment on frogs ' ;
899902 $ querydata ->timestart = 0 ;
900903 $ querydata ->timeend = 0 ;
@@ -934,7 +937,7 @@ public function test_users_filter_search() {
934937 sleep (1 );
935938
936939 // This is a mock of the search form submission.
937- $ querydata = new stdClass ();
940+ $ querydata = new \ stdClass ();
938941 $ querydata ->q = 'assignment on frogs ' ;
939942 $ querydata ->timestart = 0 ;
940943 $ querydata ->timeend = 0 ;
@@ -964,7 +967,7 @@ public function test_search_no_implicit_wildcard() {
964967 sleep (1 );
965968
966969 // This is a mock of the search form submission.
967- $ querydata = new stdClass ();
970+ $ querydata = new \ stdClass ();
968971 $ querydata ->q = 'frog ' ;
969972 $ querydata ->timestart = 0 ;
970973 $ querydata ->timeend = 0 ;
@@ -996,7 +999,7 @@ public function test_search_wildcardstart_enabled() {
996999 sleep (1 );
9971000
9981001 // This is a mock of the search form submission.
999- $ querydata = new stdClass ();
1002+ $ querydata = new \ stdClass ();
10001003 $ querydata ->q = 'ogs ' ;
10011004 $ querydata ->timestart = 0 ;
10021005 $ querydata ->timeend = 0 ;
@@ -1029,7 +1032,7 @@ public function test_search_wildcardend_enabled() {
10291032 sleep (1 );
10301033
10311034 // This is a mock of the search form submission.
1032- $ querydata = new stdClass ();
1035+ $ querydata = new \ stdClass ();
10331036 $ querydata ->q = 'fro ' ;
10341037 $ querydata ->timestart = 0 ;
10351038 $ querydata ->timeend = 0 ;
0 commit comments