mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-82499 question: test for invalid question in capability check.
This commit is contained in:
parent
43b3bda115
commit
b99a81af8e
@ -2008,6 +2008,21 @@ class questionlib_test extends \advanced_testcase {
|
||||
question_has_capability_on('one', 'tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test question_has_capability_on with an invalid question ID
|
||||
*/
|
||||
public function test_question_has_capability_on_invalid_question(): void {
|
||||
try {
|
||||
question_has_capability_on(42, 'tag');
|
||||
$this->fail('Expected exception');
|
||||
} catch (\moodle_exception $exception) {
|
||||
$this->assertInstanceOf(\dml_missing_record_exception::class, $exception);
|
||||
|
||||
// We also get debugging from initial attempt to load question data.
|
||||
$this->assertDebuggingCalled();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of question_categorylist function.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user