Línea 30... |
Línea 30... |
30 |
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
30 |
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
31 |
* @author Safat Shahin <safatshahin@catalyst-au.net>
|
31 |
* @author Safat Shahin <safatshahin@catalyst-au.net>
|
32 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
32 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
33 |
* @coversDefaultClass \qbank_bulkmove\helper
|
33 |
* @coversDefaultClass \qbank_bulkmove\helper
|
34 |
*/
|
34 |
*/
|
35 |
class helper_test extends \advanced_testcase {
|
35 |
final class helper_test extends \advanced_testcase {
|
Línea 36... |
Línea 36... |
36 |
|
36 |
|
37 |
/**
|
37 |
/**
|
38 |
* @var false|object|\stdClass|null $cat
|
38 |
* @var false|object|\stdClass|null $cat
|
39 |
*/
|
39 |
*/
|
Línea 84... |
Línea 84... |
84 |
/** @var \core_question_generator $questiongenerator */
|
84 |
/** @var \core_question_generator $questiongenerator */
|
85 |
$questiongenerator = $generator->get_plugin_generator('core_question');
|
85 |
$questiongenerator = $generator->get_plugin_generator('core_question');
|
Línea 86... |
Línea 86... |
86 |
|
86 |
|
87 |
// Create a course.
|
87 |
// Create a course.
|
- |
|
88 |
$this->course = $generator->create_course();
|
88 |
$this->course = $generator->create_course();
|
89 |
$qbank = self::getDataGenerator()->create_module('qbank', ['name' => 'QBANK 1', 'course' => $this->course->id]);
|
Línea 89... |
Línea 90... |
89 |
$this->context = \context_course::instance($this->course->id);
|
90 |
$this->context = \context_module::instance($qbank->cmid);
|
90 |
|
91 |
|
91 |
// Create a question in the default category.
|
92 |
// Create a question in the default category.
|
92 |
$this->contexts = new question_edit_contexts($this->context);
|
93 |
$this->contexts = new question_edit_contexts($this->context);
|
93 |
$this->cat = question_make_default_categories($this->contexts->all());
|
94 |
$this->cat = question_get_default_category($this->contexts->lowest()->id, true);
|
Línea 94... |
Línea 95... |
94 |
$this->questiondata1 = $questiongenerator->create_question('numerical', null,
|
95 |
$this->questiondata1 = $questiongenerator->create_question('numerical', null,
|
95 |
['name' => 'Example question', 'category' => $this->cat->id]);
|
96 |
['name' => 'Example question', 'category' => $this->cat->id]);
|
Línea 209... |
Línea 210... |
209 |
*
|
210 |
*
|
210 |
* @covers ::get_displaydata
|
211 |
* @covers ::get_displaydata
|
211 |
*/
|
212 |
*/
|
212 |
public function test_get_displaydata(): void {
|
213 |
public function test_get_displaydata(): void {
|
213 |
$this->helper_setup();
|
214 |
$this->helper_setup();
|
214 |
$coursecontext = \context_course::instance($this->course->id);
|
- |
|
215 |
$contexts = new question_edit_contexts($coursecontext);
|
215 |
$contexts = new question_edit_contexts($this->context);
|
216 |
$addcontexts = $contexts->having_cap('moodle/question:add');
|
216 |
$addcontexts = $contexts->having_cap('moodle/question:add');
|
217 |
$url = new \moodle_url('/question/bank/bulkmove/move.php');
|
217 |
$url = new \moodle_url('/question/bank/bulkmove/move.php');
|
218 |
$displaydata = \qbank_bulkmove\helper::get_displaydata($addcontexts, $url, $url);
|
218 |
$displaydata = \qbank_bulkmove\helper::get_displaydata($addcontexts, $url, $url);
|
- |
|
219 |
$this->assertDebuggingCalled();
|
219 |
$this->assertStringContainsString('Test question category 1', $displaydata['categorydropdown']);
|
220 |
$this->assertStringContainsString('Test question category 1', $displaydata['categorydropdown']);
|
220 |
$this->assertStringContainsString('Default for Category 1', $displaydata['categorydropdown']);
|
221 |
$this->assertStringContainsString('Default for QBANK 1', $displaydata['categorydropdown']);
|
221 |
$this->assertEquals($url, $displaydata ['moveurl']);
|
222 |
$this->assertEquals($url, $displaydata ['moveurl']);
|
222 |
$this->assertEquals($url, $displaydata ['returnurl']);
|
223 |
$this->assertEquals($url, $displaydata ['returnurl']);
|
223 |
}
|
224 |
}
|
224 |
}
|
225 |
}
|