Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 42... Línea 42...
42
 */
42
 */
43
class provider_test extends provider_testcase {
43
class provider_test extends provider_testcase {
44
    /**
44
    /**
45
     * Check that a course context is returned if there is any user data for this user.
45
     * Check that a course context is returned if there is any user data for this user.
46
     */
46
     */
47
    public function test_get_contexts_for_userid() {
47
    public function test_get_contexts_for_userid(): void {
48
        $this->resetAfterTest();
48
        $this->resetAfterTest();
49
        $user1 = $this->getDataGenerator()->create_user();
49
        $user1 = $this->getDataGenerator()->create_user();
50
        $course1 = $this->getDataGenerator()->create_course();
50
        $course1 = $this->getDataGenerator()->create_course();
51
        $this->assertEmpty(provider::get_contexts_for_userid($user1->id));
51
        $this->assertEmpty(provider::get_contexts_for_userid($user1->id));
52
        // Enrol user into courses and check contextlist.
52
        // Enrol user into courses and check contextlist.
Línea 59... Línea 59...
59
        $this->assertEquals($coursecontext1->id, $contextlist->get_contextids()[0]);
59
        $this->assertEquals($coursecontext1->id, $contextlist->get_contextids()[0]);
60
    }
60
    }
61
    /**
61
    /**
62
     * Test that user data is exported correctly.
62
     * Test that user data is exported correctly.
63
     */
63
     */
64
    public function test_export_user_data() {
64
    public function test_export_user_data(): void {
65
        global $DB;
65
        global $DB;
Línea 66... Línea 66...
66
 
66
 
67
        $this->resetAfterTest();
67
        $this->resetAfterTest();
68
        $user1 = $this->getDataGenerator()->create_user();
68
        $user1 = $this->getDataGenerator()->create_user();
Línea 106... Línea 106...
106
        $this->assertEquals(transform::datetime($enrolmentcouse2->timemodified), reset($data)->timemodified);
106
        $this->assertEquals(transform::datetime($enrolmentcouse2->timemodified), reset($data)->timemodified);
107
    }
107
    }
108
    /**
108
    /**
109
     * Test deleting all user data for a specific context.
109
     * Test deleting all user data for a specific context.
110
     */
110
     */
111
    public function test_delete_data_for_all_users_in_context() {
111
    public function test_delete_data_for_all_users_in_context(): void {
112
        global $DB;
112
        global $DB;
Línea 113... Línea 113...
113
 
113
 
114
        $this->resetAfterTest();
114
        $this->resetAfterTest();
115
        $user1 = $this->getDataGenerator()->create_user();
115
        $user1 = $this->getDataGenerator()->create_user();
Línea 144... Línea 144...
144
        $this->assertCount(2, $userenrolments);
144
        $this->assertCount(2, $userenrolments);
145
    }
145
    }
146
    /**
146
    /**
147
     * This should work identical to the above test.
147
     * This should work identical to the above test.
148
     */
148
     */
149
    public function test_delete_data_for_user() {
149
    public function test_delete_data_for_user(): void {
150
        global $DB;
150
        global $DB;
Línea 151... Línea 151...
151
 
151
 
152
        $this->resetAfterTest();
152
        $this->resetAfterTest();
153
        $user1 = $this->getDataGenerator()->create_user();
153
        $user1 = $this->getDataGenerator()->create_user();
Línea 179... Línea 179...
179
    }
179
    }
Línea 180... Línea 180...
180
 
180
 
181
    /**
181
    /**
182
     * Test that only users within a course context are fetched.
182
     * Test that only users within a course context are fetched.
183
     */
183
     */
184
    public function test_get_users_in_context() {
184
    public function test_get_users_in_context(): void {
Línea 185... Línea 185...
185
        $this->resetAfterTest();
185
        $this->resetAfterTest();
Línea 186... Línea 186...
186
 
186
 
Línea 212... Línea 212...
212
    }
212
    }
Línea 213... Línea 213...
213
 
213
 
214
    /**
214
    /**
215
     * Test that data for users in approved userlist is deleted.
215
     * Test that data for users in approved userlist is deleted.
216
     */
216
     */
217
    public function test_delete_data_for_users() {
217
    public function test_delete_data_for_users(): void {
Línea 218... Línea 218...
218
        $this->resetAfterTest();
218
        $this->resetAfterTest();
Línea 219... Línea 219...
219
 
219