-
Bug
-
Resolution: Fixed
-
Minor
-
2.7
-
MOODLE_27_STABLE
-
MOODLE_27_STABLE
-
Reproduction steps
- Find or make an add-on that creates a custom user profile field in install.php (must be text to cause this failure). E.g.
function xmldb_local_profilevisibility_install() {
global $DB, $CFG;
require_once($CFG->dirroot.'/local/profilevisibility/lib.php');
//check or add the category
$strprofvis = get_string('profilevisibility', 'local_profilevisibility');
if (!$category = $DB->get_record('user_info_category', array('name'=>$strprofvis))) {
$sql = 'SELECT MAX(sortorder) FROM {user_info_category}';
if ($sort = $DB->get_record_sql($sql)) {
$sortorder = $sort->max;
} else {
$sortorder = 0;
}
$category = new StdClass;
$category->name = $strprofvis;
$category->sortorder = $sortorder + 1;
$category->id = $DB->insert_record('user_info_category', $category);
}
//check or add the user profile field
if (!$DB->count_records('user_info_field', array('shortname'=>'profilevisibility'))) {
$field = new StdClass;
$field->shortname = 'profilevisibility';
$field->name = $strprofvis;
$field->datatype = 'text';
$field->description = '';
$field->descriptionformat = 1;
$field->categoryid = $category->id;
$field->sortorder = 1;
$field->required = 0;
$field->locked = 0;
$field->visible = 1;
$field->forceunique = 0;
$field->signup = 0;
$field->defaultdata = 'Default';
$field->defaultdataformat = 0;
$DB->insert_record('user_info_field', $field);
}
}
- Run the unit tests.
Result
There was 1 failure:
|
|
1) availability_profile_condition_testcase::test_custom_textarea_field
|
Failed asserting that two arrays are equal.
|
--- Expected
|
+++ Actual
|
@@ @@
|
Array (
|
- 0 => 'frogtype'
|
+ 0 => 'newfield'
|
+ 1 => 'frogtype'
|
)
|
|
/home/moodle/moodles/peer_review/moodle/availability/condition/profile/tests/condition_test.php:345
|
/home/moodle/moodles/peer_review/moodle/lib/phpunit/classes/advanced_testcase.php:80
|
|
To re-run:
|
vendor/bin/phpunit availability_profile_condition_testcase availability/condition/profile/tests/condition_test.php
|
- has been marked as being related by
-
MDL-62483 Should be harder to write fragile unit tests that make unwarranted assumptions about a new Moodle install
-
- Open
-