Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 36... Línea 36...
36
 * @copyright  2013 Frédéric Massart
36
 * @copyright  2013 Frédéric Massart
37
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
38
 */
39
class lib_test extends \advanced_testcase {
39
class lib_test extends \advanced_testcase {
Línea 40... Línea 40...
40
 
40
 
41
    public function test_member_added_event() {
41
    public function test_member_added_event(): void {
Línea 42... Línea 42...
42
        $this->resetAfterTest();
42
        $this->resetAfterTest();
43
 
43
 
44
        $this->setAdminUser();
44
        $this->setAdminUser();
Línea 59... Línea 59...
59
        $this->assertEquals($group->id, $event->objectid);
59
        $this->assertEquals($group->id, $event->objectid);
60
        $url = new \moodle_url('/group/members.php', array('group' => $event->objectid));
60
        $url = new \moodle_url('/group/members.php', array('group' => $event->objectid));
61
        $this->assertEquals($url, $event->get_url());
61
        $this->assertEquals($url, $event->get_url());
62
    }
62
    }
Línea 63... Línea 63...
63
 
63
 
64
    public function test_member_removed_event() {
64
    public function test_member_removed_event(): void {
Línea 65... Línea 65...
65
        $this->resetAfterTest();
65
        $this->resetAfterTest();
66
 
66
 
67
        $this->setAdminUser();
67
        $this->setAdminUser();
Línea 83... Línea 83...
83
        $this->assertEquals($group->id, $event->objectid);
83
        $this->assertEquals($group->id, $event->objectid);
84
        $url = new \moodle_url('/group/members.php', array('group' => $event->objectid));
84
        $url = new \moodle_url('/group/members.php', array('group' => $event->objectid));
85
        $this->assertEquals($url, $event->get_url());
85
        $this->assertEquals($url, $event->get_url());
86
    }
86
    }
Línea 87... Línea 87...
87
 
87
 
88
    public function test_group_created_event() {
88
    public function test_group_created_event(): void {
Línea 89... Línea 89...
89
        $this->resetAfterTest();
89
        $this->resetAfterTest();
90
 
90
 
Línea 102... Línea 102...
102
        $this->assertEquals($group->id, $event->objectid);
102
        $this->assertEquals($group->id, $event->objectid);
103
        $url = new \moodle_url('/group/index.php', array('id' => $event->courseid));
103
        $url = new \moodle_url('/group/index.php', array('id' => $event->courseid));
104
        $this->assertEquals($url, $event->get_url());
104
        $this->assertEquals($url, $event->get_url());
105
    }
105
    }
Línea 106... Línea 106...
106
 
106
 
107
    public function test_grouping_created_event() {
107
    public function test_grouping_created_event(): void {
Línea 108... Línea 108...
108
        $this->resetAfterTest();
108
        $this->resetAfterTest();
109
 
109
 
Línea 122... Línea 122...
122
        $this->assertEquals($group->id, $event->objectid);
122
        $this->assertEquals($group->id, $event->objectid);
123
        $url = new \moodle_url('/group/groupings.php', array('id' => $event->courseid));
123
        $url = new \moodle_url('/group/groupings.php', array('id' => $event->courseid));
124
        $this->assertEquals($url, $event->get_url());
124
        $this->assertEquals($url, $event->get_url());
125
    }
125
    }
Línea 126... Línea 126...
126
 
126
 
127
    public function test_group_updated_event() {
127
    public function test_group_updated_event(): void {
Línea 128... Línea 128...
128
        global $DB;
128
        global $DB;
Línea 129... Línea 129...
129
 
129
 
Línea 151... Línea 151...
151
        $this->assertEquals($group->id, $event->objectid);
151
        $this->assertEquals($group->id, $event->objectid);
152
        $url = new \moodle_url('/group/group.php', array('id' => $event->objectid));
152
        $url = new \moodle_url('/group/group.php', array('id' => $event->objectid));
153
        $this->assertEquals($url, $event->get_url());
153
        $this->assertEquals($url, $event->get_url());
154
    }
154
    }
Línea 155... Línea 155...
155
 
155
 
156
    public function test_group_updated_event_does_not_require_names() {
156
    public function test_group_updated_event_does_not_require_names(): void {
Línea 157... Línea 157...
157
        global $DB;
157
        global $DB;
Línea 158... Línea 158...
158
 
158
 
Línea 178... Línea 178...
178
        $this->assertEquals($group->id, $event->objectid);
178
        $this->assertEquals($group->id, $event->objectid);
179
        $url = new \moodle_url('/group/group.php', array('id' => $event->objectid));
179
        $url = new \moodle_url('/group/group.php', array('id' => $event->objectid));
180
        $this->assertEquals($url, $event->get_url());
180
        $this->assertEquals($url, $event->get_url());
181
    }
181
    }
Línea 182... Línea 182...
182
 
182
 
183
    public function test_grouping_updated_event() {
183
    public function test_grouping_updated_event(): void {
Línea 184... Línea 184...
184
        global $DB;
184
        global $DB;
Línea 185... Línea 185...
185
 
185
 
Línea 209... Línea 209...
209
        $this->assertEquals($grouping->id, $event->objectid);
209
        $this->assertEquals($grouping->id, $event->objectid);
210
        $url = new \moodle_url('/group/grouping.php', array('id' => $event->objectid));
210
        $url = new \moodle_url('/group/grouping.php', array('id' => $event->objectid));
211
        $this->assertEquals($url, $event->get_url());
211
        $this->assertEquals($url, $event->get_url());
212
    }
212
    }
Línea 213... Línea 213...
213
 
213
 
214
    public function test_grouping_updated_event_does_not_require_names() {
214
    public function test_grouping_updated_event_does_not_require_names(): void {
Línea 215... Línea 215...
215
        global $DB;
215
        global $DB;
Línea 216... Línea 216...
216
 
216
 
Línea 246... Línea 246...
246
        $this->assertEquals($grouping->id, $event->objectid);
246
        $this->assertEquals($grouping->id, $event->objectid);
247
        $url = new \moodle_url('/group/grouping.php', array('id' => $event->objectid));
247
        $url = new \moodle_url('/group/grouping.php', array('id' => $event->objectid));
248
        $this->assertEquals($url, $event->get_url());
248
        $this->assertEquals($url, $event->get_url());
249
    }
249
    }
Línea 250... Línea 250...
250
 
250
 
251
    public function test_group_deleted_event() {
251
    public function test_group_deleted_event(): void {
Línea 252... Línea 252...
252
        $this->resetAfterTest();
252
        $this->resetAfterTest();
253
 
253
 
Línea 264... Línea 264...
264
        $this->assertEquals($group->id, $event->objectid);
264
        $this->assertEquals($group->id, $event->objectid);
265
        $url = new \moodle_url('/group/index.php', array('id' => $event->courseid));
265
        $url = new \moodle_url('/group/index.php', array('id' => $event->courseid));
266
        $this->assertEquals($url, $event->get_url());
266
        $this->assertEquals($url, $event->get_url());
267
    }
267
    }
Línea 268... Línea 268...
268
 
268
 
269
    public function test_grouping_deleted_event() {
269
    public function test_grouping_deleted_event(): void {
Línea 270... Línea 270...
270
        $this->resetAfterTest();
270
        $this->resetAfterTest();
271
 
271
 
Línea 283... Línea 283...
283
        $this->assertEquals($group->id, $event->objectid);
283
        $this->assertEquals($group->id, $event->objectid);
284
        $url = new \moodle_url('/group/groupings.php', array('id' => $event->courseid));
284
        $url = new \moodle_url('/group/groupings.php', array('id' => $event->courseid));
285
        $this->assertEquals($url, $event->get_url());
285
        $this->assertEquals($url, $event->get_url());
286
    }
286
    }
Línea 287... Línea 287...
287
 
287
 
288
    public function test_groups_delete_group_members() {
288
    public function test_groups_delete_group_members(): void {
289
        global $DB;
289
        global $DB;
Línea 290... Línea 290...
290
        $this->resetAfterTest();
290
        $this->resetAfterTest();
291
 
291
 
Línea 322... Línea 322...
322
        $this->assertTrue($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user1->id)));
322
        $this->assertTrue($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user1->id)));
323
        $this->assertTrue($DB->record_exists('groups_members', array('groupid' => $group2->id, 'userid' => $user1->id)));
323
        $this->assertTrue($DB->record_exists('groups_members', array('groupid' => $group2->id, 'userid' => $user1->id)));
324
        $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user2->id)));
324
        $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user2->id)));
325
    }
325
    }
Línea 326... Línea 326...
326
 
326
 
327
    public function test_groups_remove_member() {
327
    public function test_groups_remove_member(): void {
328
        global $DB;
328
        global $DB;
Línea 329... Línea 329...
329
        $this->resetAfterTest();
329
        $this->resetAfterTest();
330
 
330
 
Línea 352... Línea 352...
352
        $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user2->id)));
352
        $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user2->id)));
353
        groups_remove_member($group2->id, $user1->id);
353
        groups_remove_member($group2->id, $user1->id);
354
        $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group2->id, 'userid' => $user1->id)));
354
        $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group2->id, 'userid' => $user1->id)));
355
    }
355
    }
Línea 356... Línea 356...
356
 
356
 
357
    public function test_groups_delete_groupings_groups() {
357
    public function test_groups_delete_groupings_groups(): void {
358
        global $DB;
358
        global $DB;
Línea 359... Línea 359...
359
        $this->resetAfterTest();
359
        $this->resetAfterTest();
360
 
360
 
Línea 382... Línea 382...
382
        $this->assertFalse($DB->record_exists('groupings_groups', array('groupid' => $group1->id, 'groupingid' => $grouping2->id)));
382
        $this->assertFalse($DB->record_exists('groupings_groups', array('groupid' => $group1->id, 'groupingid' => $grouping2->id)));
383
        $this->assertTrue($DB->record_exists('groupings_groups',
383
        $this->assertTrue($DB->record_exists('groupings_groups',
384
            array('groupid' => $group1c2->id, 'groupingid' => $grouping1c2->id)));
384
            array('groupid' => $group1c2->id, 'groupingid' => $grouping1c2->id)));
385
    }
385
    }
Línea 386... Línea 386...
386
 
386
 
387
    public function test_groups_delete_groups() {
387
    public function test_groups_delete_groups(): void {
388
        global $DB;
388
        global $DB;
Línea 389... Línea 389...
389
        $this->resetAfterTest();
389
        $this->resetAfterTest();
390
 
390
 
Línea 413... Línea 413...
413
        $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user1->id)));
413
        $this->assertFalse($DB->record_exists('groups_members', array('groupid' => $group1->id, 'userid' => $user1->id)));
414
        $this->assertTrue($DB->record_exists('groupings', array('id' => $grouping1->id, 'courseid' => $course->id)));
414
        $this->assertTrue($DB->record_exists('groupings', array('id' => $grouping1->id, 'courseid' => $course->id)));
415
        $this->assertFalse($DB->record_exists('groupings_groups', array('groupid' => $group1->id, 'groupingid' => $grouping1->id)));
415
        $this->assertFalse($DB->record_exists('groupings_groups', array('groupid' => $group1->id, 'groupingid' => $grouping1->id)));
416
    }
416
    }
Línea 417... Línea 417...
417
 
417
 
418
    public function test_groups_delete_groupings() {
418
    public function test_groups_delete_groupings(): void {
419
        global $DB;
419
        global $DB;
Línea 420... Línea 420...
420
        $this->resetAfterTest();
420
        $this->resetAfterTest();
421
 
421
 
Línea 443... Línea 443...
443
    /**
443
    /**
444
     * Test custom field for group.
444
     * Test custom field for group.
445
     * @covers ::groups_create_group
445
     * @covers ::groups_create_group
446
     * @covers ::groups_get_group
446
     * @covers ::groups_get_group
447
     */
447
     */
448
    public function test_groups_with_customfield() {
448
    public function test_groups_with_customfield(): void {
449
        $this->resetAfterTest();
449
        $this->resetAfterTest();
450
        $this->setAdminUser();
450
        $this->setAdminUser();
Línea 451... Línea 451...
451
 
451
 
452
        $course1 = self::getDataGenerator()->create_course();
452
        $course1 = self::getDataGenerator()->create_course();
Línea 527... Línea 527...
527
        $this->assertCount(1, $grouping->customfields);
527
        $this->assertCount(1, $grouping->customfields);
528
        $customfield = reset($grouping->customfields);
528
        $customfield = reset($grouping->customfields);
529
        $this->assertSame('Updated input for grouping1', $customfield['value']);
529
        $this->assertSame('Updated input for grouping1', $customfield['value']);
530
    }
530
    }
Línea 531... Línea 531...
531
 
531
 
532
    public function test_groups_create_autogroups() {
532
    public function test_groups_create_autogroups(): void {
533
        global $DB;
533
        global $DB;
Línea 534... Línea 534...
534
        $this->resetAfterTest();
534
        $this->resetAfterTest();
535
 
535
 
Línea 583... Línea 583...
583
    }
583
    }
Línea 584... Línea 584...
584
 
584
 
585
    /**
585
    /**
586
     * Test groups_create_group enabling a group conversation.
586
     * Test groups_create_group enabling a group conversation.
587
     */
587
     */
588
    public function test_groups_create_group_with_conversation() {
588
    public function test_groups_create_group_with_conversation(): void {
Línea 589... Línea 589...
589
        global $DB;
589
        global $DB;
590
 
590
 
591
        $this->resetAfterTest();
591
        $this->resetAfterTest();
Línea 621... Línea 621...
621
    }
621
    }
Línea 622... Línea 622...
622
 
622
 
623
    /**
623
    /**
624
     * Test groups_update_group enabling and disabling a group conversation.
624
     * Test groups_update_group enabling and disabling a group conversation.
625
     */
625
     */
626
    public function test_groups_update_group_conversation() {
626
    public function test_groups_update_group_conversation(): void {
Línea 627... Línea 627...
627
        global $DB;
627
        global $DB;
628
 
628
 
629
        $this->resetAfterTest();
629
        $this->resetAfterTest();
Línea 679... Línea 679...
679
    }
679
    }
Línea 680... Línea 680...
680
 
680
 
681
    /**
681
    /**
682
     * Test groups_add_member to conversation.
682
     * Test groups_add_member to conversation.
683
     */
683
     */
684
    public function test_groups_add_member_conversation() {
684
    public function test_groups_add_member_conversation(): void {
685
        global $DB;
685
        global $DB;
Línea 686... Línea 686...
686
        $this->resetAfterTest();
686
        $this->resetAfterTest();
Línea 721... Línea 721...
721
    }
721
    }
Línea 722... Línea 722...
722
 
722
 
723
    /**
723
    /**
724
     * Test groups_remove_member to conversation.
724
     * Test groups_remove_member to conversation.
725
     */
725
     */
726
    public function test_groups_remove_member_conversation() {
726
    public function test_groups_remove_member_conversation(): void {
Línea 727... Línea 727...
727
        global $DB;
727
        global $DB;
Línea 728... Línea 728...
728
 
728
 
Línea 768... Línea 768...
768
    }
768
    }
Línea 769... Línea 769...
769
 
769
 
770
    /**
770
    /**
771
     * Test if you enable group messaging in a group with members these are added to the conversation.
771
     * Test if you enable group messaging in a group with members these are added to the conversation.
772
     */
772
     */
773
    public function test_add_members_group_updated_conversation_enabled() {
773
    public function test_add_members_group_updated_conversation_enabled(): void {
Línea 774... Línea 774...
774
        global $DB;
774
        global $DB;
Línea 775... Línea 775...
775
 
775
 
Línea 883... Línea 883...
883
    /**
883
    /**
884
     * Tests set_groups_messaging
884
     * Tests set_groups_messaging
885
     *
885
     *
886
     * @covers \core_group::set_groups_messaging
886
     * @covers \core_group::set_groups_messaging
887
     */
887
     */
888
    public function test_set_groups_messaging() {
888
    public function test_set_groups_messaging(): void {
889
        $this->resetAfterTest();
889
        $this->resetAfterTest();
890
        $this->setAdminUser();
890
        $this->setAdminUser();
891
        $dg = $this->getDataGenerator();
891
        $dg = $this->getDataGenerator();
892
        $course = $dg->create_course();
892
        $course = $dg->create_course();
Línea 923... Línea 923...
923
    /**
923
    /**
924
     * Tests set group messaging where it doesn't exist
924
     * Tests set group messaging where it doesn't exist
925
     *
925
     *
926
     * @covers \core_group::set_groups_messaging
926
     * @covers \core_group::set_groups_messaging
927
     */
927
     */
928
    public function test_set_groups_messaging_doesnt_exist() {
928
    public function test_set_groups_messaging_doesnt_exist(): void {
929
        $this->resetAfterTest();
929
        $this->resetAfterTest();
930
        $this->setAdminUser();
930
        $this->setAdminUser();
Línea 931... Línea 931...
931
 
931