Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 93... Línea 93...
93
        } else {
93
        } else {
94
            set_config('dbhandlesoptions', false, 'logstore_database');
94
            set_config('dbhandlesoptions', false, 'logstore_database');
95
        }
95
        }
96
    }
96
    }
Línea 97... Línea 97...
97
 
97
 
98
    public function test_get_contexts_for_userid() {
98
    public function test_get_contexts_for_userid(): void {
99
        $admin = \core_user::get_user(2);
99
        $admin = \core_user::get_user(2);
100
        $u1 = $this->getDataGenerator()->create_user();
100
        $u1 = $this->getDataGenerator()->create_user();
101
        $u2 = $this->getDataGenerator()->create_user();
101
        $u2 = $this->getDataGenerator()->create_user();
Línea 153... Línea 153...
153
    }
153
    }
Línea 154... Línea 154...
154
 
154
 
155
    /**
155
    /**
156
     * Check that user IDs are returned for a given context.
156
     * Check that user IDs are returned for a given context.
157
     */
157
     */
158
    public function test_add_userids_for_context() {
158
    public function test_add_userids_for_context(): void {
159
        $admin = \core_user::get_user(2);
159
        $admin = \core_user::get_user(2);
160
        $u1 = $this->getDataGenerator()->create_user();
160
        $u1 = $this->getDataGenerator()->create_user();
161
        $u2 = $this->getDataGenerator()->create_user();
161
        $u2 = $this->getDataGenerator()->create_user();
162
        $u3 = $this->getDataGenerator()->create_user();
162
        $u3 = $this->getDataGenerator()->create_user();
Línea 199... Línea 199...
199
        $this->assertCount(4, $userids);
199
        $this->assertCount(4, $userids);
200
        $expectedresult = [$admin->id, $u1->id, $u2->id, $u3->id];
200
        $expectedresult = [$admin->id, $u1->id, $u2->id, $u3->id];
201
        $this->assertEmpty(array_diff($expectedresult, $userids));
201
        $this->assertEmpty(array_diff($expectedresult, $userids));
202
    }
202
    }
Línea 203... Línea 203...
203
 
203
 
204
    public function test_delete_data_for_user() {
204
    public function test_delete_data_for_user(): void {
205
        global $DB;
205
        global $DB;
206
        $u1 = $this->getDataGenerator()->create_user();
206
        $u1 = $this->getDataGenerator()->create_user();
207
        $u2 = $this->getDataGenerator()->create_user();
207
        $u2 = $this->getDataGenerator()->create_user();
208
        $c1 = $this->getDataGenerator()->create_course();
208
        $c1 = $this->getDataGenerator()->create_course();
Línea 240... Línea 240...
240
        $this->assertFalse($DB->record_exists('logstore_standard_log', ['userid' => $u1->id, 'contextid' => $c1ctx->id]));
240
        $this->assertFalse($DB->record_exists('logstore_standard_log', ['userid' => $u1->id, 'contextid' => $c1ctx->id]));
241
        $this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
241
        $this->assertEquals(1, $DB->count_records('logstore_standard_log', ['userid' => $u1->id]));
242
        $this->assertEquals(2, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
242
        $this->assertEquals(2, $DB->count_records('logstore_standard_log', ['userid' => $u2->id]));
243
    }
243
    }
Línea 244... Línea 244...
244
 
244
 
245
    public function test_delete_data_for_all_users_in_context() {
245
    public function test_delete_data_for_all_users_in_context(): void {
246
        global $DB;
246
        global $DB;
247
        $u1 = $this->getDataGenerator()->create_user();
247
        $u1 = $this->getDataGenerator()->create_user();
248
        $u2 = $this->getDataGenerator()->create_user();
248
        $u2 = $this->getDataGenerator()->create_user();
249
        $c1 = $this->getDataGenerator()->create_course();
249
        $c1 = $this->getDataGenerator()->create_course();
Línea 284... Línea 284...
284
    }
284
    }
Línea 285... Línea 285...
285
 
285
 
286
    /**
286
    /**
287
     * Check that data is removed for the listed users in a given context.
287
     * Check that data is removed for the listed users in a given context.
288
     */
288
     */
289
    public function test_delete_data_for_userlist() {
289
    public function test_delete_data_for_userlist(): void {
Línea 290... Línea 290...
290
        global $DB;
290
        global $DB;
291
 
291
 
292
        $u1 = $this->getDataGenerator()->create_user();
292
        $u1 = $this->getDataGenerator()->create_user();
Línea 326... Línea 326...
326
        $this->assertCount(1, $records);
326
        $this->assertCount(1, $records);
327
        $currentrecord = array_shift($records);
327
        $currentrecord = array_shift($records);
328
        $this->assertEquals($u2->id, $currentrecord->userid);
328
        $this->assertEquals($u2->id, $currentrecord->userid);
329
    }
329
    }
Línea 330... Línea 330...
330
 
330
 
331
    public function test_export_data_for_user() {
331
    public function test_export_data_for_user(): void {
332
        $admin = \core_user::get_user(2);
332
        $admin = \core_user::get_user(2);
333
        $u1 = $this->getDataGenerator()->create_user();
333
        $u1 = $this->getDataGenerator()->create_user();
334
        $u2 = $this->getDataGenerator()->create_user();
334
        $u2 = $this->getDataGenerator()->create_user();
335
        $u3 = $this->getDataGenerator()->create_user();
335
        $u3 = $this->getDataGenerator()->create_user();