mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 03:16:42 +02:00
Merge branch 'MDL-63168_35' of git://github.com/markn86/moodle into MOODLE_35_STABLE
This commit is contained in:
commit
64a588ccca
2 changed files with 32 additions and 1 deletions
|
@ -229,7 +229,7 @@ class migrate_message_data extends \core\task\adhoc_task {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we need to mark this message as deleted for the user to.
|
// Check if we need to mark this message as deleted for the user to.
|
||||||
if ($message->timeusertodeleted) {
|
if ($message->timeusertodeleted and ($message->useridfrom != $message->useridto)) {
|
||||||
$mua = new \stdClass();
|
$mua = new \stdClass();
|
||||||
$mua->userid = $message->useridto;
|
$mua->userid = $message->useridto;
|
||||||
$mua->messageid = $messageid;
|
$mua->messageid = $messageid;
|
||||||
|
|
|
@ -324,6 +324,37 @@ class core_message_migrate_message_data_task_testcase extends advanced_testcase
|
||||||
$this->assertEquals(FORMAT_MOODLE, $notification->fullmessageformat);
|
$this->assertEquals(FORMAT_MOODLE, $notification->fullmessageformat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test migrating a legacy message that a user sent to themselves then deleted.
|
||||||
|
*/
|
||||||
|
public function test_migrating_message_deleted_message_sent_to_self() {
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
// Create user to test with.
|
||||||
|
$user1 = $this->getDataGenerator()->create_user();
|
||||||
|
|
||||||
|
$m1 = $this->create_legacy_message_or_notification($user1->id, $user1->id, null, false, null, null);
|
||||||
|
|
||||||
|
// Let's delete the message for the 'user to' and 'user from' which in this case is the same user.
|
||||||
|
$messageupdate = new stdClass();
|
||||||
|
$messageupdate->id = $m1;
|
||||||
|
$messageupdate->timeuserfromdeleted = time();
|
||||||
|
$messageupdate->timeusertodeleted = time();
|
||||||
|
$DB->update_record('message', $messageupdate);
|
||||||
|
|
||||||
|
// Now, let's execute the task for the user.
|
||||||
|
$task = new \core_message\task\migrate_message_data();
|
||||||
|
$task->set_custom_data(
|
||||||
|
[
|
||||||
|
'userid' => $user1->id
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$task->execute();
|
||||||
|
|
||||||
|
$this->assertEquals(0, $DB->count_records('message'));
|
||||||
|
$this->assertEquals(1, $DB->count_records('message_user_actions'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a legacy message or notification to be used for testing.
|
* Creates a legacy message or notification to be used for testing.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue