Skip to content

Commit

Permalink
MDL-54734 user: Add tests to demonstrate multi-user issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols authored and lameze committed Jul 7, 2016
1 parent 566f5a7 commit 2245bc1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/tests/user_test.php
Expand Up @@ -209,4 +209,27 @@ public function test_get_property_definition() {
$this->assertRegExp('/Invalid property requested./', $e->getMessage());
}
}

/**
* Ensure that the noreply user is not cached.
*/
public function test_get_noreply_user() {
global $CFG;

// Create a new fake language 'xx' with the 'noreplyname'.
$langfolder = $CFG->dataroot . '/lang/xx';
check_dir_exists($langfolder);
$langconfig = "<?php\n\defined('MOODLE_INTERNAL') || die();";
file_put_contents($langfolder . '/langconfig.php', $langconfig);
$langconfig = "<?php\n\$string['noreplyname'] = 'XXX';";
file_put_contents($langfolder . '/moodle.php', $langconfig);

$CFG->lang='en';
$enuser = \core_user::get_noreply_user();

$CFG->lang='xx';
$xxuser = \core_user::get_noreply_user();

$this->assertNotEquals($enuser, $xxuser);
}
}

0 comments on commit 2245bc1

Please sign in to comment.