MDL-42602 remove incorrect snapshot from \core\event\user_loggedin
* all snapshots in events should match the DB data * the snapshot from user table will not be necessary most probably
This commit is contained in:
@@ -246,12 +246,8 @@ class auth_ldap_plugin_testcase extends advanced_testcase {
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->setAdminUser();
|
||||
|
||||
$user = clone($USER);
|
||||
|
||||
// The USER variable no longer stores the password hash, so set it here.
|
||||
$user->password = 'password';
|
||||
$this->assertFalse(isloggedin());
|
||||
$user = $DB->get_record('user', array('username'=>'admin'));
|
||||
|
||||
// Note: we are just going to trigger the function that calls the event,
|
||||
// not actually perform a LDAP login, for the sake of sanity.
|
||||
@@ -271,23 +267,6 @@ class auth_ldap_plugin_testcase extends advanced_testcase {
|
||||
$events = $sink->get_events();
|
||||
$sink->close();
|
||||
|
||||
// Unset the password now.
|
||||
unset($user->password);
|
||||
|
||||
// Get the user from the DB and set the expected variables.
|
||||
$dbuser = $DB->get_record('user', array('id' => $user->id), '*', MUST_EXIST);
|
||||
$user->firstaccess = (int) $dbuser->firstaccess;
|
||||
$user->lastaccess = (int) $dbuser->lastaccess;
|
||||
$user->currentlogin = (int) $dbuser->currentlogin;
|
||||
$user->sesskey = sesskey();
|
||||
$user->lastcourseaccess = array();
|
||||
$user->currentcourseaccess = array();
|
||||
$user->groupmember = array();
|
||||
$user->profile = array();
|
||||
$user->preference = array(
|
||||
'_lastloaded' => time()
|
||||
);
|
||||
|
||||
// Check that the event is valid.
|
||||
$this->assertCount(2, $events);
|
||||
$event = $events[0];
|
||||
@@ -297,7 +276,6 @@ class auth_ldap_plugin_testcase extends advanced_testcase {
|
||||
$this->assertEquals('user', $event->objecttable);
|
||||
$this->assertEquals('2', $event->objectid);
|
||||
$this->assertEquals(context_system::instance()->id, $event->contextid);
|
||||
$this->assertEquals($user, $event->get_record_snapshot('user', 2));
|
||||
$expectedlog = array(SITEID, 'user', 'login', 'view.php?id=' . $USER->id . '&course=' . SITEID, $user->id,
|
||||
0, $user->id);
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
|
||||
@@ -4442,7 +4442,6 @@ function complete_user_login($user) {
|
||||
'other' => array('username' => $USER->username),
|
||||
)
|
||||
);
|
||||
$event->add_record_snapshot('user', $user);
|
||||
$event->trigger();
|
||||
|
||||
if (isguestuser()) {
|
||||
|
||||
@@ -2446,14 +2446,17 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_complete_user_login() {
|
||||
global $USER;
|
||||
global $USER, $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->setUser(0);
|
||||
|
||||
$sink = $this->redirectEvents();
|
||||
@complete_user_login($user); // Hide session header errors.
|
||||
$loginuser = clone($user);
|
||||
$this->setCurrentTimeStart();
|
||||
@complete_user_login($loginuser); // Hide session header errors.
|
||||
$this->assertSame($loginuser, $USER);
|
||||
$this->assertEquals($user->id, $USER->id);
|
||||
$events = $sink->get_events();
|
||||
$sink->close();
|
||||
@@ -2466,7 +2469,21 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertEquals('user', $event->objecttable);
|
||||
$this->assertEquals($user->id, $event->objectid);
|
||||
$this->assertEquals(context_system::instance()->id, $event->contextid);
|
||||
$this->assertEquals($user, $event->get_record_snapshot('user', $user->id));
|
||||
|
||||
$user = $DB->get_record('user', array('id'=>$user->id));
|
||||
|
||||
$this->assertTimeCurrent($user->firstaccess);
|
||||
$this->assertTimeCurrent($user->lastaccess);
|
||||
$this->assertTimeCurrent($user->timemodified);
|
||||
|
||||
$this->assertTimeCurrent($USER->firstaccess);
|
||||
$this->assertTimeCurrent($USER->lastaccess);
|
||||
$this->assertTimeCurrent($USER->timemodified);
|
||||
$this->assertTimeCurrent($USER->currentlogin);
|
||||
$this->assertSame(sesskey(), $USER->sesskey);
|
||||
$this->assertTimeCurrent($USER->preference['_lastloaded']);
|
||||
$this->assertObjectNotHasAttribute('password', $USER);
|
||||
$this->assertObjectNotHasAttribute('description', $USER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user