Línea 51... |
Línea 51... |
51 |
public function setUp(): void {
|
51 |
public function setUp(): void {
|
52 |
$this->resetAfterTest();
|
52 |
$this->resetAfterTest();
|
53 |
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
|
53 |
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
|
54 |
}
|
54 |
}
|
Línea 55... |
Línea 55... |
55 |
|
55 |
|
56 |
public function test_get_contexts_for_userid() {
|
56 |
public function test_get_contexts_for_userid(): void {
|
57 |
$admin = \core_user::get_user(2);
|
57 |
$admin = \core_user::get_user(2);
|
58 |
$u1 = $this->getDataGenerator()->create_user();
|
58 |
$u1 = $this->getDataGenerator()->create_user();
|
59 |
$u2 = $this->getDataGenerator()->create_user();
|
59 |
$u2 = $this->getDataGenerator()->create_user();
|
Línea 108... |
Línea 108... |
108 |
$this->assert_contextlist_equals($this->get_contextlist_for_user($u1), [$sysctx, $cm1ctx, $c2ctx]);
|
108 |
$this->assert_contextlist_equals($this->get_contextlist_for_user($u1), [$sysctx, $cm1ctx, $c2ctx]);
|
109 |
$this->assert_contextlist_equals($this->get_contextlist_for_user($u3), [$sysctx, $c1ctx, $c2ctx]);
|
109 |
$this->assert_contextlist_equals($this->get_contextlist_for_user($u3), [$sysctx, $c1ctx, $c2ctx]);
|
110 |
$this->assert_contextlist_equals($this->get_contextlist_for_user($admin), [$sysctx, $c1ctx, $c2ctx]);
|
110 |
$this->assert_contextlist_equals($this->get_contextlist_for_user($admin), [$sysctx, $c1ctx, $c2ctx]);
|
111 |
}
|
111 |
}
|
Línea 112... |
Línea 112... |
112 |
|
112 |
|
113 |
public function test_add_userids_for_context() {
|
113 |
public function test_add_userids_for_context(): void {
|
114 |
$admin = \core_user::get_user(2);
|
114 |
$admin = \core_user::get_user(2);
|
115 |
$u1 = $this->getDataGenerator()->create_user();
|
115 |
$u1 = $this->getDataGenerator()->create_user();
|
116 |
$u2 = $this->getDataGenerator()->create_user();
|
116 |
$u2 = $this->getDataGenerator()->create_user();
|
117 |
$u3 = $this->getDataGenerator()->create_user();
|
117 |
$u3 = $this->getDataGenerator()->create_user();
|
Línea 154... |
Línea 154... |
154 |
$this->assertCount(4, $userids);
|
154 |
$this->assertCount(4, $userids);
|
155 |
$expectedresult = [$admin->id, $u1->id, $u2->id, $u3->id];
|
155 |
$expectedresult = [$admin->id, $u1->id, $u2->id, $u3->id];
|
156 |
$this->assertEmpty(array_diff($expectedresult, $userids));
|
156 |
$this->assertEmpty(array_diff($expectedresult, $userids));
|
157 |
}
|
157 |
}
|
Línea 158... |
Línea 158... |
158 |
|
158 |
|
159 |
public function test_delete_data_for_user() {
|
159 |
public function test_delete_data_for_user(): void {
|
160 |
global $DB;
|
160 |
global $DB;
|
161 |
$u1 = $this->getDataGenerator()->create_user();
|
161 |
$u1 = $this->getDataGenerator()->create_user();
|
162 |
$u2 = $this->getDataGenerator()->create_user();
|
162 |
$u2 = $this->getDataGenerator()->create_user();
|
163 |
$c1 = $this->getDataGenerator()->create_course();
|
163 |
$c1 = $this->getDataGenerator()->create_course();
|
Línea 195... |
Línea 195... |
195 |
$this->assertFalse($DB->record_exists('logstore_standard_log', ['userid' => $u1->id, 'contextid' => $c1ctx->id]));
|
195 |
$this->assertFalse($DB->record_exists('logstore_standard_log', ['userid' => $u1->id, 'contextid' => $c1ctx->id]));
|
196 |
$this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
|
196 |
$this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
|
197 |
$this->assertEquals(2, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
|
197 |
$this->assertEquals(2, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
|
198 |
}
|
198 |
}
|
Línea 199... |
Línea 199... |
199 |
|
199 |
|
200 |
public function test_delete_data_for_all_users_in_context() {
|
200 |
public function test_delete_data_for_all_users_in_context(): void {
|
201 |
global $DB;
|
201 |
global $DB;
|
202 |
$u1 = $this->getDataGenerator()->create_user();
|
202 |
$u1 = $this->getDataGenerator()->create_user();
|
203 |
$u2 = $this->getDataGenerator()->create_user();
|
203 |
$u2 = $this->getDataGenerator()->create_user();
|
204 |
$c1 = $this->getDataGenerator()->create_course();
|
204 |
$c1 = $this->getDataGenerator()->create_course();
|
Línea 236... |
Línea 236... |
236 |
$this->assertFalse($DB->record_exists('logstore_standard_log', ['contextid' => $c1ctx->id]));
|
236 |
$this->assertFalse($DB->record_exists('logstore_standard_log', ['contextid' => $c1ctx->id]));
|
237 |
$this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
|
237 |
$this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
|
238 |
$this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
|
238 |
$this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
|
239 |
}
|
239 |
}
|
Línea 240... |
Línea 240... |
240 |
|
240 |
|
241 |
public function test_delete_data_for_userlist() {
|
241 |
public function test_delete_data_for_userlist(): void {
|
Línea 242... |
Línea 242... |
242 |
global $DB;
|
242 |
global $DB;
|
243 |
|
243 |
|
244 |
$u1 = $this->getDataGenerator()->create_user();
|
244 |
$u1 = $this->getDataGenerator()->create_user();
|
Línea 278... |
Línea 278... |
278 |
$this->assertCount(1, $records);
|
278 |
$this->assertCount(1, $records);
|
279 |
$currentrecord = array_shift($records);
|
279 |
$currentrecord = array_shift($records);
|
280 |
$this->assertEquals($u2->id, $currentrecord->userid);
|
280 |
$this->assertEquals($u2->id, $currentrecord->userid);
|
281 |
}
|
281 |
}
|
Línea 282... |
Línea 282... |
282 |
|
282 |
|
283 |
public function test_export_data_for_user() {
|
283 |
public function test_export_data_for_user(): void {
|
284 |
$admin = \core_user::get_user(2);
|
284 |
$admin = \core_user::get_user(2);
|
285 |
$u1 = $this->getDataGenerator()->create_user();
|
285 |
$u1 = $this->getDataGenerator()->create_user();
|
286 |
$u2 = $this->getDataGenerator()->create_user();
|
286 |
$u2 = $this->getDataGenerator()->create_user();
|
287 |
$u3 = $this->getDataGenerator()->create_user();
|
287 |
$u3 = $this->getDataGenerator()->create_user();
|