Merge branch 'MDL-71048' of https://github.com/paulholden/moodle
This commit is contained in:
+1
-1
@@ -10426,7 +10426,7 @@ class lang_string {
|
||||
// changes are not carried across.
|
||||
// To do this we always ensure $a or its properties/values are strings
|
||||
// and that any properties/values that arn't convertable are forgotten.
|
||||
if (!empty($a)) {
|
||||
if ($a !== null) {
|
||||
if (is_scalar($a)) {
|
||||
$this->a = $a;
|
||||
} else if ($a instanceof lang_string) {
|
||||
|
||||
@@ -2168,6 +2168,11 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('lang_string', $yes);
|
||||
$this->assertSame($yesexpected, (string)$yes);
|
||||
|
||||
// Test lazy loading (returning lang_string) correctly interpolates 0 being used as args.
|
||||
$numdays = get_string('numdays', 'moodle', 0, true);
|
||||
$this->assertInstanceOf(lang_string::class, $numdays);
|
||||
$this->assertSame('0 days', (string) $numdays);
|
||||
|
||||
// Test using a lang_string object as the $a argument for a normal
|
||||
// get_string call (returning string).
|
||||
$test = new lang_string('yes', null, null, true);
|
||||
|
||||
Reference in New Issue
Block a user