Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 51... Línea 51...
51
 
51
 
52
    public function setUp(): void {
52
    public function setUp(): void {
53
        $this->resetAfterTest();
53
        $this->resetAfterTest();
Línea 54... Línea 54...
54
    }
54
    }
55
 
55
 
56
    public function test_get_contexts_for_userid_for_badge_editing() {
56
    public function test_get_contexts_for_userid_for_badge_editing(): void {
57
        $dg = $this->getDataGenerator();
57
        $dg = $this->getDataGenerator();
58
        $u1 = $dg->create_user();
58
        $u1 = $dg->create_user();
59
        $u2 = $dg->create_user();
59
        $u2 = $dg->create_user();
Línea 93... Línea 93...
93
        $this->assertCount(2, $contexts);
93
        $this->assertCount(2, $contexts);
94
        $this->assertTrue(in_array($sysctx->id, $contexts));
94
        $this->assertTrue(in_array($sysctx->id, $contexts));
95
        $this->assertTrue(in_array($c2ctx->id, $contexts));
95
        $this->assertTrue(in_array($c2ctx->id, $contexts));
96
    }
96
    }
Línea 97... Línea 97...
97
 
97
 
98
    public function test_get_contexts_for_userid_for_manual_award() {
98
    public function test_get_contexts_for_userid_for_manual_award(): void {
Línea 99... Línea 99...
99
        global $DB;
99
        global $DB;
100
 
100
 
101
        $dg = $this->getDataGenerator();
101
        $dg = $this->getDataGenerator();
Línea 124... Línea 124...
124
        $contexts = provider::get_contexts_for_userid($u2->id)->get_contextids();
124
        $contexts = provider::get_contexts_for_userid($u2->id)->get_contextids();
125
        $this->assertCount(1, $contexts);
125
        $this->assertCount(1, $contexts);
126
        $this->assertEquals($u3ctx->id, $contexts[0]);
126
        $this->assertEquals($u3ctx->id, $contexts[0]);
127
    }
127
    }
Línea 128... Línea 128...
128
 
128
 
129
    public function test_get_contexts_for_userid_for_my_stuff() {
129
    public function test_get_contexts_for_userid_for_my_stuff(): void {
Línea 130... Línea 130...
130
        global $DB;
130
        global $DB;
131
 
131
 
132
        $dg = $this->getDataGenerator();
132
        $dg = $this->getDataGenerator();
Línea 166... Línea 166...
166
        $contexts = provider::get_contexts_for_userid($u4->id)->get_contextids();
166
        $contexts = provider::get_contexts_for_userid($u4->id)->get_contextids();
167
        $this->assertCount(1, $contexts);
167
        $this->assertCount(1, $contexts);
168
        $this->assertEquals($u4ctx->id, $contexts[0]);
168
        $this->assertEquals($u4ctx->id, $contexts[0]);
169
    }
169
    }
Línea 170... Línea 170...
170
 
170
 
171
    public function test_delete_data_for_user() {
171
    public function test_delete_data_for_user(): void {
Línea 172... Línea 172...
172
        global $DB;
172
        global $DB;
173
 
173
 
174
        $dg = $this->getDataGenerator();
174
        $dg = $this->getDataGenerator();
Línea 224... Línea 224...
224
        $this->assertTrue($DB->record_exists('badge_issued', ['userid' => $u2->id]));
224
        $this->assertTrue($DB->record_exists('badge_issued', ['userid' => $u2->id]));
225
        $this->assertFalse($DB->record_exists('badge_criteria_met', ['userid' => $u1->id]));
225
        $this->assertFalse($DB->record_exists('badge_criteria_met', ['userid' => $u1->id]));
226
        $this->assertTrue($DB->record_exists('badge_criteria_met', ['userid' => $u2->id]));
226
        $this->assertTrue($DB->record_exists('badge_criteria_met', ['userid' => $u2->id]));
227
    }
227
    }
Línea 228... Línea 228...
228
 
228
 
229
    public function test_delete_data_for_all_users_in_context() {
229
    public function test_delete_data_for_all_users_in_context(): void {
Línea 230... Línea 230...
230
        global $DB;
230
        global $DB;
231
 
231
 
232
        $dg = $this->getDataGenerator();
232
        $dg = $this->getDataGenerator();
Línea 289... Línea 289...
289
        $this->assertTrue($DB->record_exists('badge_issued', ['userid' => $u2->id]));
289
        $this->assertTrue($DB->record_exists('badge_issued', ['userid' => $u2->id]));
290
        $this->assertFalse($DB->record_exists('badge_criteria_met', ['userid' => $u1->id]));
290
        $this->assertFalse($DB->record_exists('badge_criteria_met', ['userid' => $u1->id]));
291
        $this->assertTrue($DB->record_exists('badge_criteria_met', ['userid' => $u2->id]));
291
        $this->assertTrue($DB->record_exists('badge_criteria_met', ['userid' => $u2->id]));
292
    }
292
    }
Línea 293... Línea 293...
293
 
293
 
294
    public function test_export_data_for_user() {
294
    public function test_export_data_for_user(): void {
Línea 295... Línea 295...
295
        global $DB;
295
        global $DB;
296
 
296
 
Línea 440... Línea 440...
440
    }
440
    }
Línea 441... Línea 441...
441
 
441
 
442
    /**
442
    /**
443
     * Test that only users within a user, system and course context are fetched.
443
     * Test that only users within a user, system and course context are fetched.
444
     */
444
     */
445
    public function test_get_users_in_context() {
445
    public function test_get_users_in_context(): void {
Línea 446... Línea 446...
446
        $component = 'core_badges';
446
        $component = 'core_badges';
447
 
447
 
448
        // Create course1.
448
        // Create course1.
Línea 510... Línea 510...
510
    }
510
    }
Línea 511... Línea 511...
511
 
511
 
512
    /**
512
    /**
513
     * Test that data for users in approved userlist is deleted.
513
     * Test that data for users in approved userlist is deleted.
514
     */
514
     */
515
    public function test_delete_data_for_users() {
515
    public function test_delete_data_for_users(): void {
Línea 516... Línea 516...
516
        $component = 'core_badges';
516
        $component = 'core_badges';
517
 
517
 
518
        // Create course1.
518
        // Create course1.