Merge branch 'MDL-85743-405' of https://github.com/paulholden/moodle into MOODLE_405_STABLE

This commit is contained in:
Huong Nguyen
2025-08-29 11:00:49 +07:00
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -106,7 +106,7 @@ class user_picture implements renderable {
if (!property_exists($user, $field)) {
$needrec = true;
debugging(
"Missing {$field} property in {$user} object, "
"Missing '{$field}' property in \$user object, "
. "this is a performance problem that needs to be fixed by a developer. "
. 'Please use the \core_user\fields API to get the full list of required fields.',
DEBUG_DEVELOPER,
+14
View File
@@ -25,6 +25,20 @@ namespace core\output;
* @covers \core\output\user_picture
*/
final class user_picture_test extends \advanced_testcase {
/**
* Assert appropriate debugging is emitted if required user fields are absent
*/
public function test_constructor_missing_fields(): void {
$user = get_admin();
unset($user->picture);
// Assert debugging notice when required field isn't present.
$userpicture = new user_picture($user);
$this->assertDebuggingCalled('Missing \'picture\' property in $user object, this is a performance problem that needs ' .
'to be fixed by a developer. Please use the \core_user\fields API to get the full list of required fields.');
}
/**
* Tests {@see user_picture::allow_view()} for a not-logged-in request.
*/