mirror of
https://github.com/moodle/moodle.git
synced 2025-03-24 17:40:26 +01:00
Merge branch 'MDL-77462_401' of https://github.com/timhunt/moodle into MOODLE_401_STABLE
This commit is contained in:
commit
91ae0abd0a
@ -1982,7 +1982,7 @@ function core_question_find_next_unused_idnumber(?string $oldidnumber, int $cate
|
||||
global $DB;
|
||||
|
||||
// The the old idnumber is not of the right form, bail now.
|
||||
if (!preg_match('~\d+$~', $oldidnumber, $matches)) {
|
||||
if ($oldidnumber === null || !preg_match('~\d+$~', $oldidnumber, $matches)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1998,6 +1998,7 @@ class questionlib_test extends \advanced_testcase {
|
||||
*/
|
||||
public function find_next_unused_idnumber_cases(): array {
|
||||
return [
|
||||
[null, null],
|
||||
['id', null],
|
||||
['id1a', null],
|
||||
['id001', 'id002'],
|
||||
@ -2020,10 +2021,10 @@ class questionlib_test extends \advanced_testcase {
|
||||
* Test core_question_find_next_unused_idnumber in the case when there are no other questions.
|
||||
*
|
||||
* @dataProvider find_next_unused_idnumber_cases
|
||||
* @param string $oldidnumber value to pass to core_question_find_next_unused_idnumber.
|
||||
* @param string|null $oldidnumber value to pass to core_question_find_next_unused_idnumber.
|
||||
* @param string|null $expectednewidnumber expected result.
|
||||
*/
|
||||
public function test_core_question_find_next_unused_idnumber(string $oldidnumber, ?string $expectednewidnumber) {
|
||||
public function test_core_question_find_next_unused_idnumber(?string $oldidnumber, ?string $expectednewidnumber) {
|
||||
$this->assertSame($expectednewidnumber, core_question_find_next_unused_idnumber($oldidnumber, 0));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user