Skip to content

Commit

Permalink
added dataset to simulate "filter_hierarchicalfilter" (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
semteacher committed Jan 31, 2025
1 parent 9d5248e commit 36e209b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/base_dataprovider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use local_wunderbyte_table\filters\types\callback;
use local_wunderbyte_table\filters\types\datepicker;
use local_wunderbyte_table\filters\types\standardfilter;
use local_wunderbyte_table\filters\types\hierarchicalfilter;
use local_wunderbyte_table\local\sortables\types\standardsortable;
use moodle_exception;

Expand Down Expand Up @@ -284,6 +285,22 @@ public function create_demo2_table() {

$table->add_sortable($standardsortable);

$hierarchicalfilter = new hierarchicalfilter('shortname', get_string('shortname'));
$hierarchicalfilter->add_options(
[
'short-ended1' => [
'parent' => 'e',
],
'short-future1' => [
'parent' => 'f',
],
'other' => [
'localizedname' => get_string('other', 'local_wunderbyte_table'),
],
]
);
$table->add_filter($hierarchicalfilter);

$standardfilter = new standardfilter('fullname', 'fullname');
$table->add_filter($standardfilter);

Expand Down Expand Up @@ -514,20 +531,23 @@ public static function wb_table_common_settings_provider(): array {
[
'coursestocreate' => 1,
'fullname' => 'ended1',
'shortname' => 'short-ended1',
'startdate' => strtotime('2 May 2010 13:00'),
'enddate' => strtotime('20 May 2010 14:20'),
'users' => $standardusers,
],
[
'coursestocreate' => 1,
'fullname' => 'ended2',
'shortname' => 'short-ended2',
'startdate' => strtotime('5 Jun 2020 14:00'),
'enddate' => strtotime('15 Jun 2020 15:00'),
'users' => $standardusers,
],
[
'coursestocreate' => 1,
'fullname' => 'future1',
'shortname' => 'short-future1',
'startdate' => $plusfifftymonth,
'enddate' => $plussixtymonth,
'users' => $standardusers,
Expand Down Expand Up @@ -573,6 +593,32 @@ public static function wb_table_common_settings_provider(): array {
// Array of tests.
$returnarray = [
// Test name (description).
'filter_hierarchicalfilter' => [
'courses' => $standardcourses,
'expected' => [
'getrowscount' => [
[
'assert' => 16,
],
[
'filterobjects' => '{"shortname":["short-future1"]}',
'assert' => 1,
],
[
'filterobjects' => '{"shortname":["short-ended1"]}',
'assert' => 1,
],
[
'filterobjects' => '{"shortname":["short-ended%"]}',
'assert' => 2,
],
[
'filterobjects' => '{"shortname":["filtercourse","tc_%"]}',
'assert' => 13,
],
],
],
],
'filter_callback' => [
'courses' => $standardcourses,
'expected' => [
Expand Down

0 comments on commit 36e209b

Please sign in to comment.