mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-50839 user_menu: Allow themes to set User menu avatar size.
Added an @array "options" parameter to user_get_user_navigation_info(), for passing in avatarsize, and possibly other options in future. Also removed an errant parameter in the /lib/outputrenderers.php user_get_user_navigation_info() call, as there was no corresponding parameter in the function definition. (Test written by Jetha Chan.)
This commit is contained in:
parent
9325cd963f
commit
9dcd50358a
3 changed files with 32 additions and 7 deletions
|
@ -377,4 +377,25 @@ class core_userliblib_testcase extends advanced_testcase {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test setting the user menu avatar size.
|
||||
*/
|
||||
public function test_user_menu_custom_avatar_size() {
|
||||
global $PAGE;
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$testsize = 100;
|
||||
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$opts = user_get_user_navigation_info($user, $PAGE, array('avatarsize' => $testsize));
|
||||
$avatarhtml = $opts->metadata['useravatar'];
|
||||
|
||||
$matches = [];
|
||||
preg_match('/(?:.*width=")(\d*)(?:" height=")(\d*)(?:".*\/>)/', $avatarhtml, $matches);
|
||||
$this->assertCount(3, $matches);
|
||||
|
||||
$this->assertEquals(intval($matches[1]), $testsize);
|
||||
$this->assertEquals(intval($matches[2]), $testsize);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue