Línea 55... |
Línea 55... |
55 |
public function setUp(): void {
|
55 |
public function setUp(): void {
|
56 |
$this->resetAfterTest();
|
56 |
$this->resetAfterTest();
|
57 |
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
|
57 |
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
|
58 |
}
|
58 |
}
|
Línea 59... |
Línea 59... |
59 |
|
59 |
|
60 |
public function test_get_contexts_for_userid() {
|
60 |
public function test_get_contexts_for_userid(): void {
|
61 |
$admin = \core_user::get_user(2);
|
61 |
$admin = \core_user::get_user(2);
|
62 |
$u1 = $this->getDataGenerator()->create_user();
|
62 |
$u1 = $this->getDataGenerator()->create_user();
|
63 |
$c1 = $this->getDataGenerator()->create_course();
|
63 |
$c1 = $this->getDataGenerator()->create_course();
|
Línea 71... |
Línea 71... |
71 |
$e = \logstore_standard\event\unittest_executed::create(['context' => $c1ctx]);
|
71 |
$e = \logstore_standard\event\unittest_executed::create(['context' => $c1ctx]);
|
72 |
$e->trigger();
|
72 |
$e->trigger();
|
73 |
$this->assertEquals($c1ctx->id, provider::get_contexts_for_userid($u1->id)->get_contextids()[0]);
|
73 |
$this->assertEquals($c1ctx->id, provider::get_contexts_for_userid($u1->id)->get_contextids()[0]);
|
74 |
}
|
74 |
}
|
Línea 75... |
Línea 75... |
75 |
|
75 |
|
76 |
public function test_delete_data_for_user() {
|
76 |
public function test_delete_data_for_user(): void {
|
77 |
global $DB;
|
77 |
global $DB;
|
78 |
$u1 = $this->getDataGenerator()->create_user();
|
78 |
$u1 = $this->getDataGenerator()->create_user();
|
79 |
$u2 = $this->getDataGenerator()->create_user();
|
79 |
$u2 = $this->getDataGenerator()->create_user();
|
80 |
$c1 = $this->getDataGenerator()->create_course();
|
80 |
$c1 = $this->getDataGenerator()->create_course();
|
Línea 105... |
Línea 105... |
105 |
$this->assertFalse($DB->record_exists('logstore_standard_log', ['userid' => $u1->id, 'contextid' => $c1ctx->id]));
|
105 |
$this->assertFalse($DB->record_exists('logstore_standard_log', ['userid' => $u1->id, 'contextid' => $c1ctx->id]));
|
106 |
$this->assertEquals(0, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
|
106 |
$this->assertEquals(0, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
|
107 |
$this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
|
107 |
$this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
|
108 |
}
|
108 |
}
|
Línea 109... |
Línea 109... |
109 |
|
109 |
|
110 |
public function test_delete_data_for_all_users_in_context() {
|
110 |
public function test_delete_data_for_all_users_in_context(): void {
|
111 |
global $DB;
|
111 |
global $DB;
|
112 |
$u1 = $this->getDataGenerator()->create_user();
|
112 |
$u1 = $this->getDataGenerator()->create_user();
|
113 |
$u2 = $this->getDataGenerator()->create_user();
|
113 |
$u2 = $this->getDataGenerator()->create_user();
|
114 |
$c1 = $this->getDataGenerator()->create_course();
|
114 |
$c1 = $this->getDataGenerator()->create_course();
|
Línea 139... |
Línea 139... |
139 |
$this->assertFalse($DB->record_exists('logstore_standard_log', ['contextid' => $c1ctx->id]));
|
139 |
$this->assertFalse($DB->record_exists('logstore_standard_log', ['contextid' => $c1ctx->id]));
|
140 |
$this->assertEquals(0, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
|
140 |
$this->assertEquals(0, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
|
141 |
$this->assertEquals(0, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
|
141 |
$this->assertEquals(0, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
|
142 |
}
|
142 |
}
|
Línea 143... |
Línea 143... |
143 |
|
143 |
|
144 |
public function test_export_data_for_user() {
|
144 |
public function test_export_data_for_user(): void {
|
145 |
$admin = \core_user::get_user(2);
|
145 |
$admin = \core_user::get_user(2);
|
146 |
$u1 = $this->getDataGenerator()->create_user();
|
146 |
$u1 = $this->getDataGenerator()->create_user();
|
147 |
$c1 = $this->getDataGenerator()->create_course();
|
147 |
$c1 = $this->getDataGenerator()->create_course();
|