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/>.
18 * This file contains tests for the question bank column class.
20 * @package core_question
21 * @copyright 2018 Huong Nguyen <huongnv13@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
28 require_once($CFG->dirroot
. '/question/editlib.php');
29 require_once($CFG->dirroot
. '/question/tests/fixtures/testable_core_question_column.php');
32 * Unit tests for the question bank column class.
34 * @package core_question
35 * @copyright 2018 Huong Nguyen <huongnv13@gmail.com>
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class question_bank_column_testcase
extends advanced_testcase
{
41 * Test function display_header multiple sorts with no custom tooltips.
44 public function test_column_header_multi_sort_no_tooltips() {
45 $this->resetAfterTest();
46 $course = $this->getDataGenerator()->create_course();
47 $questionbank = new core_question\bank\view
(
48 new question_edit_contexts(context_course
::instance($course->id
)),
52 $columnbase = new testable_core_question_column($questionbank);
64 $columnbase->set_sortable($sortable);
67 $columnbase->display_header();
68 $output = ob_get_clean();
70 $this->assertContains(' title="Sort by Apple ascending">Apple</a>', $output);
71 $this->assertContains(' title="Sort by Banana ascending">Banana</a>', $output);
75 * Test function display_header multiple sorts with custom tooltips.
78 public function test_column_header_multi_sort_with_tooltips() {
79 $this->resetAfterTest();
80 $course = $this->getDataGenerator()->create_course();
81 $questionbank = new core_question\bank\view
(
82 new question_edit_contexts(context_course
::instance($course->id
)),
86 $columnbase = new testable_core_question_column($questionbank);
92 'tip' => 'Apple Tooltips'
97 'tip' => 'Banana Tooltips'
100 $columnbase->set_sortable($sortable);
103 $columnbase->display_header();
104 $output = ob_get_clean();
106 $this->assertContains(' title="Sort by Apple Tooltips ascending">Apple</a>', $output);
107 $this->assertContains(' title="Sort by Banana Tooltips ascending">Banana</a>', $output);