2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 namespace core_question
;
19 use core_question\local\bank\question_edit_contexts
;
20 use core_question\local\bank\view
;
21 use testable_core_question_column
;
23 defined('MOODLE_INTERNAL') ||
die();
26 require_once($CFG->dirroot
. '/question/editlib.php');
27 require_once($CFG->dirroot
. '/question/tests/fixtures/testable_core_question_column.php');
30 * Unit tests for the question bank column class.
32 * @package core_question
33 * @copyright 2018 Huong Nguyen <huongnv13@gmail.com>
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 class question_bank_column_test
extends \advanced_testcase
{
39 * Test function display_header multiple sorts with no custom tooltips.
42 public function test_column_header_multi_sort_no_tooltips() {
43 $this->resetAfterTest();
44 $course = $this->getDataGenerator()->create_course();
45 $questionbank = new view(
46 new question_edit_contexts(\context_course
::instance($course->id
)),
50 $columnbase = new testable_core_question_column($questionbank);
62 $columnbase->set_sortable($sortable);
65 $columnbase->display_header();
66 $output = ob_get_clean();
68 $this->assertStringContainsString(' title="Sort by Apple ascending">', $output);
69 $this->assertStringContainsString(' title="Sort by Banana ascending">', $output);
73 * Test function display_header multiple sorts with custom tooltips.
76 public function test_column_header_multi_sort_with_tooltips() {
77 $this->resetAfterTest();
78 $course = $this->getDataGenerator()->create_course();
79 $questionbank = new view(
80 new question_edit_contexts(\context_course
::instance($course->id
)),
84 $columnbase = new testable_core_question_column($questionbank);
90 'tip' => 'Apple Tooltips'
95 'tip' => 'Banana Tooltips'
98 $columnbase->set_sortable($sortable);
101 $columnbase->display_header();
102 $output = ob_get_clean();
104 $this->assertStringContainsString(' title="Sort by Apple Tooltips ascending">', $output);
105 $this->assertStringContainsString(' title="Sort by Banana Tooltips ascending">', $output);