Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 50... Línea 50...
50
 
50
 
51
    public function setUp(): void {
51
    public function setUp(): void {
52
        $this->resetAfterTest();
52
        $this->resetAfterTest();
Línea 53... Línea 53...
53
    }
53
    }
54
 
54
 
55
    public function test_get_contexts_for_userid() {
55
    public function test_get_contexts_for_userid(): void {
56
        $dg = $this->getDataGenerator();
56
        $dg = $this->getDataGenerator();
57
        $c1 = $dg->create_course();
57
        $c1 = $dg->create_course();
58
        $c2 = $dg->create_course();
58
        $c2 = $dg->create_course();
Línea 110... Línea 110...
110
        $contextids = provider::get_contexts_for_userid($u2->id)->get_contextids();
110
        $contextids = provider::get_contexts_for_userid($u2->id)->get_contextids();
111
        $this->assertCount(1, $contextids);
111
        $this->assertCount(1, $contextids);
112
        $this->assertTrue(in_array($u1ctx->id, $contextids));
112
        $this->assertTrue(in_array($u1ctx->id, $contextids));
113
    }
113
    }
Línea 114... Línea 114...
114
 
114
 
115
    public function test_get_contexts_for_userid_with_one_associated_post_only() {
115
    public function test_get_contexts_for_userid_with_one_associated_post_only(): void {
116
        $dg = $this->getDataGenerator();
116
        $dg = $this->getDataGenerator();
117
        $c1 = $dg->create_course();
117
        $c1 = $dg->create_course();
118
        $u1 = $dg->create_user();
118
        $u1 = $dg->create_user();
Línea 131... Línea 131...
131
    }
131
    }
Línea 132... Línea 132...
132
 
132
 
133
    /**
133
    /**
134
     * Test that user IDs are returned for a specificed course or module context.
134
     * Test that user IDs are returned for a specificed course or module context.
135
     */
135
     */
136
    public function test_get_users_in_context_course_and_module() {
136
    public function test_get_users_in_context_course_and_module(): void {
137
        $user1 = $this->getDataGenerator()->create_user();
137
        $user1 = $this->getDataGenerator()->create_user();
138
        $user2 = $this->getDataGenerator()->create_user();
138
        $user2 = $this->getDataGenerator()->create_user();
139
        $course = $this->getDataGenerator()->create_course();
139
        $course = $this->getDataGenerator()->create_course();
Línea 168... Línea 168...
168
    }
168
    }
Línea 169... Línea 169...
169
 
169
 
170
    /**
170
    /**
171
     * Test that user IDs are returned for a specificed user context.
171
     * Test that user IDs are returned for a specificed user context.
172
     */
172
     */
173
    public function test_get_users_in_context_user_context() {
173
    public function test_get_users_in_context_user_context(): void {
174
        $user1 = $this->getDataGenerator()->create_user();
174
        $user1 = $this->getDataGenerator()->create_user();
175
        $user2 = $this->getDataGenerator()->create_user();
175
        $user2 = $this->getDataGenerator()->create_user();
Línea 176... Línea 176...
176
        $u1ctx = \context_user::instance($user1->id);
176
        $u1ctx = \context_user::instance($user1->id);
Línea 190... Línea 190...
190
    }
190
    }
Línea 191... Línea 191...
191
 
191
 
192
    /**
192
    /**
193
     * Test that user IDs are returned for a specificed user context for an external blog.
193
     * Test that user IDs are returned for a specificed user context for an external blog.
194
     */
194
     */
195
    public function test_get_users_in_context_external_blog() {
195
    public function test_get_users_in_context_external_blog(): void {
196
        $user1 = $this->getDataGenerator()->create_user();
196
        $user1 = $this->getDataGenerator()->create_user();
197
        $u1ctx = \context_user::instance($user1->id);
197
        $u1ctx = \context_user::instance($user1->id);
Línea 198... Línea 198...
198
        $extu1 = $this->create_external_blog(['userid' => $user1->id]);
198
        $extu1 = $this->create_external_blog(['userid' => $user1->id]);
199
 
199
 
200
        $userlist = new \core_privacy\local\request\userlist($u1ctx, 'core_blog');
200
        $userlist = new \core_privacy\local\request\userlist($u1ctx, 'core_blog');
201
        provider::get_users_in_context($userlist);
201
        provider::get_users_in_context($userlist);
202
        $userids = $userlist->get_userids();
202
        $userids = $userlist->get_userids();
Línea 203... Línea 203...
203
        $this->assertCount(1, $userids);
203
        $this->assertCount(1, $userids);
204
    }
204
    }
Línea 205... Línea 205...
205
 
205
 
206
    public function test_delete_data_for_user() {
206
    public function test_delete_data_for_user(): void {
207
        global $DB;
207
        global $DB;
Línea 374... Línea 374...
374
    /**
374
    /**
375
     * Test provider delete_data_for_user with a context that contains no entries
375
     * Test provider delete_data_for_user with a context that contains no entries
376
     *
376
     *
377
     * @return void
377
     * @return void
378
     */
378
     */
379
    public function test_delete_data_for_user_empty_context() {
379
    public function test_delete_data_for_user_empty_context(): void {
380
        global $DB;
380
        global $DB;
Línea 381... Línea 381...
381
 
381
 
382
        $user = $this->getDataGenerator()->create_user();
382
        $user = $this->getDataGenerator()->create_user();
383
        $course = $this->getDataGenerator()->create_course();
383
        $course = $this->getDataGenerator()->create_course();
Línea 400... Línea 400...
400
 
400
 
401
        // Sanity check to ensure blog_associations is really empty.
401
        // Sanity check to ensure blog_associations is really empty.
402
        $this->assertEmpty($DB->get_records('blog_association', ['contextid' => $context->id]));
402
        $this->assertEmpty($DB->get_records('blog_association', ['contextid' => $context->id]));
Línea 403... Línea 403...
403
    }
403
    }
404
 
404
 
Línea 405... Línea 405...
405
    public function test_delete_data_for_all_users_in_context() {
405
    public function test_delete_data_for_all_users_in_context(): void {
406
        global $DB;
406
        global $DB;
407
 
407
 
Línea 537... Línea 537...
537
 
537
 
538
        $this->assertCount(0, $DB->get_records('blog_external', ['userid' => $u1->id]));
538
        $this->assertCount(0, $DB->get_records('blog_external', ['userid' => $u1->id]));
539
        $this->assertCount(1, $DB->get_records('blog_external', ['userid' => $u2->id]));
539
        $this->assertCount(1, $DB->get_records('blog_external', ['userid' => $u2->id]));
Línea 540... Línea 540...
540
    }
540
    }
541
 
541
 
542
    public function test_export_data_for_user() {
542
    public function test_export_data_for_user(): void {
Línea 543... Línea 543...
543
        global $DB;
543
        global $DB;
544
        $dg = $this->getDataGenerator();
544
        $dg = $this->getDataGenerator();
Línea 735... Línea 735...
735
    }
735
    }
Línea 736... Línea 736...
736
 
736
 
737
    /**
737
    /**
738
     * Test that deleting of blog information in a user context works as desired.
738
     * Test that deleting of blog information in a user context works as desired.
739
     */
739
     */
740
    public function test_delete_data_for_users_user_context() {
740
    public function test_delete_data_for_users_user_context(): void {
Línea 741... Línea 741...
741
        global $DB;
741
        global $DB;
742
 
742
 
743
        $u1 = $this->getDataGenerator()->create_user();
743
        $u1 = $this->getDataGenerator()->create_user();
Línea 778... Línea 778...
778
    }
778
    }
Línea 779... Línea 779...
779
 
779
 
780
    /**
780
    /**
781
     * Test that deleting of an external blog in a user context works as desired.
781
     * Test that deleting of an external blog in a user context works as desired.
782
     */
782
     */
783
    public function test_delete_data_for_users_external_blog() {
783
    public function test_delete_data_for_users_external_blog(): void {
Línea 784... Línea 784...
784
        global $DB;
784
        global $DB;
785
 
785
 
Línea 798... Línea 798...
798
        $userlist = new \core_privacy\local\request\approved_userlist($u1ctx, 'core_blog', [$u1->id, $u2->id]);
798
        $userlist = new \core_privacy\local\request\approved_userlist($u1ctx, 'core_blog', [$u1->id, $u2->id]);
799
        provider::delete_data_for_users($userlist);
799
        provider::delete_data_for_users($userlist);
800
        $this->assertCount(1, $DB->get_records('blog_external'));
800
        $this->assertCount(1, $DB->get_records('blog_external'));
801
    }
801
    }
Línea 802... Línea 802...
802
 
802
 
803
    public function test_delete_data_for_users_course_and_module_context() {
803
    public function test_delete_data_for_users_course_and_module_context(): void {
Línea 804... Línea 804...
804
        global $DB;
804
        global $DB;
805
 
805
 
806
        $u1 = $this->getDataGenerator()->create_user();
806
        $u1 = $this->getDataGenerator()->create_user();