@@ -125,6 +125,8 @@ public function test_query_db_cached(): void {
125
125
* Test wb filter functionality via webservice external class.
126
126
*
127
127
* @covers \wunderbyte_table::query_db_cached
128
+ * @covers \wunderbyte_table::define_sortablecolumns
129
+ * @covers \local_wunderbyte_table\local\sortables\types\standardsortable
128
130
*
129
131
* @throws \coding_exception
130
132
* @throws \dml_exception
@@ -198,7 +200,7 @@ public function test_sortable(): void {
198
200
/**
199
201
* Test wb filter functionality via webservice external class.
200
202
*
201
- * @covers \wunderbyte_table \filters\types\callback
203
+ * @covers \local_wunderbyte_table \filters\types\callback
202
204
*
203
205
* @throws \coding_exception
204
206
* @throws \dml_exception
@@ -264,7 +266,7 @@ public function test_filter_callback(): void {
264
266
/**
265
267
* Test wb datepicker filter functionality via webservice external class.
266
268
*
267
- * @covers \wunderbyte_table \filters\types\datepicker
269
+ * @covers \local_wunderbyte_table \filters\types\datepicker
268
270
*
269
271
* @throws \coding_exception
270
272
* @throws \dml_exception
@@ -297,6 +299,7 @@ public function test_filter_datepicker(): void {
297
299
$ this ->setUser ($ user );
298
300
299
301
$ table = $ this ->create_demo2_table ();
302
+ $ table ->pagesize = 20 ;
300
303
301
304
$ nrofrows = $ this ->get_rowscount_for_table (
302
305
$ table ,
@@ -336,38 +339,88 @@ public function test_filter_datepicker(): void {
336
339
}
337
340
338
341
/**
339
- * Test wb base search and filtering functionality via webservice external class.
342
+ * Test wb base full text search.
343
+ *
344
+ * @covers \local_wunderbyte_table\filters\types\standardfilter
345
+ *
346
+ * @throws \coding_exception
347
+ * @throws \dml_exception
348
+ *
349
+ */
350
+ public function test_filter_standardfilter (): void {
351
+ // First, we create ten courses.
352
+ $ this ->create_test_courses (10 );
353
+ // Now we create another six courses for basic searching and filtering.
354
+ $ this ->create_test_courses (3 , ['fullname ' => 'filtercourse ' ]);
355
+ $ this ->create_test_courses (1 , ['fullname ' => 'ended1 ' ]);
356
+ $ this ->create_test_courses (1 , ['fullname ' => 'ended2 ' ]);
357
+ $ this ->create_test_courses (1 , ['fullname ' => 'future1 ' ]);
358
+
359
+ $ user = $ this ->getDataGenerator ()->create_user ();
360
+ $ this ->setUser ($ user );
361
+
362
+ $ table = $ this ->create_demo2_table ();
363
+ $ table ->pagesize = 20 ;
364
+
365
+ $ nrofrows = $ this ->get_rowscount_for_table ($ table );
366
+ $ this ->assertEquals (16 , $ nrofrows );
367
+
368
+ // Validate basic filtering by course fullname.
369
+ $ nrofrows = $ this ->get_rowscount_for_table (
370
+ $ table ,
371
+ 0 ,
372
+ null ,
373
+ null ,
374
+ null ,
375
+ null ,
376
+ null ,
377
+ '{"fullname":["filtercourse"]} '
378
+ );
379
+ $ this ->assertEquals (3 , $ nrofrows );
380
+
381
+ $ nrofrows = $ this ->get_rowscount_for_table (
382
+ $ table ,
383
+ 0 ,
384
+ null ,
385
+ null ,
386
+ null ,
387
+ null ,
388
+ null ,
389
+ '{"fullname":["ended2"]} '
390
+ );
391
+ $ this ->assertEquals (1 , $ nrofrows );
392
+
393
+ $ nrofrows = $ this ->get_rowscount_for_table (
394
+ $ table ,
395
+ 0 ,
396
+ null ,
397
+ null ,
398
+ null ,
399
+ null ,
400
+ null ,
401
+ '{"fullname":["ended%"]} '
402
+ );
403
+ $ this ->assertEquals (2 , $ nrofrows );
404
+ }
405
+
406
+ /**
407
+ * Test wb base full text search.
340
408
*
341
409
* @covers \wunderbyte_table::query_db_cached
342
- * // @runInSeparateProcess
410
+ * @covers \wunderbyte_table::define_fulltextsearchcolumns
343
411
*
344
412
* @throws \coding_exception
345
413
* @throws \dml_exception
346
414
*
347
415
*/
348
- public function test_basic_search_filtering_cached (): void {
416
+ public function test_fulltextsearchcolumns (): void {
349
417
// First, we create ten courses.
350
418
$ this ->create_test_courses (10 );
351
- // Now we create another three courses for basic searching and filtering.
419
+ // Now we create another six courses for basic searching and filtering.
352
420
$ this ->create_test_courses (3 , ['fullname ' => 'filtercourse ' ]);
353
- // Create 2 courses for end date filtering.
354
- $ this ->create_test_courses (1 , [
355
- 'fullname ' => 'ended1 ' ,
356
- 'startdate ' => strtotime ('2 May 2010 ' ),
357
- 'enddate ' => strtotime ('20 May 2010 ' ),
358
- ]);
359
- $ this ->create_test_courses (1 , [
360
- 'fullname ' => 'ended2 ' ,
361
- 'startdate ' => strtotime ('5 Jun 2020 14:00 ' ),
362
- 'enddate ' => strtotime ('15 Jun 2020 15:00 ' ),
363
- ]);
364
- $ plusfifftymonth = strtotime ('+50 month ' );
365
- $ plussixtymonth = strtotime ('+60 month ' );
366
- $ this ->create_test_courses (1 , [
367
- 'fullname ' => 'future1 ' ,
368
- 'startdate ' => $ plusfifftymonth ,
369
- 'enddate ' => $ plussixtymonth ,
370
- ]);
421
+ $ this ->create_test_courses (1 , ['fullname ' => 'ended1 ' ]);
422
+ $ this ->create_test_courses (1 , ['fullname ' => 'ended2 ' ]);
423
+ $ this ->create_test_courses (1 , ['fullname ' => 'future1 ' ]);
371
424
372
425
$ user = $ this ->getDataGenerator ()->create_user ();
373
426
$ this ->setUser ($ user );
0 commit comments