Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 245... Línea 245...
245
    }
245
    }
Línea 246... Línea 246...
246
 
246
 
247
    /*
247
    /*
248
     * Test get wikis by courses
248
     * Test get wikis by courses
249
     */
249
     */
Línea 250... Línea 250...
250
    public function test_mod_wiki_get_wikis_by_courses() {
250
    public function test_mod_wiki_get_wikis_by_courses(): void {
251
 
251
 
Línea 252... Línea 252...
252
        // Create additional course.
252
        // Create additional course.
Línea 388... Línea 388...
388
    }
388
    }
Línea 389... Línea 389...
389
 
389
 
390
    /**
390
    /**
391
     * Test view_wiki.
391
     * Test view_wiki.
392
     */
392
     */
Línea 393... Línea 393...
393
    public function test_view_wiki() {
393
    public function test_view_wiki(): void {
394
 
394
 
395
        // Test invalid instance id.
395
        // Test invalid instance id.
396
        try {
396
        try {
Línea 446... Línea 446...
446
    }
446
    }
Línea 447... Línea 447...
447
 
447
 
448
    /**
448
    /**
449
     * Test view_page.
449
     * Test view_page.
450
     */
450
     */
Línea 451... Línea 451...
451
    public function test_view_page() {
451
    public function test_view_page(): void {
452
 
452
 
453
        // Test invalid page id.
453
        // Test invalid page id.
454
        try {
454
        try {
Línea 504... Línea 504...
504
    }
504
    }
Línea 505... Línea 505...
505
 
505
 
506
    /**
506
    /**
507
     * Test get_subwikis.
507
     * Test get_subwikis.
508
     */
508
     */
Línea 509... Línea 509...
509
    public function test_get_subwikis() {
509
    public function test_get_subwikis(): void {
510
 
510
 
511
        // Test invalid wiki id.
511
        // Test invalid wiki id.
512
        try {
512
        try {
Línea 561... Línea 561...
561
    }
561
    }
Línea 562... Línea 562...
562
 
562
 
563
    /**
563
    /**
564
     * Test get_subwiki_pages using an invalid wiki instance.
564
     * Test get_subwiki_pages using an invalid wiki instance.
565
     */
565
     */
566
    public function test_get_subwiki_pages_invalid_instance() {
566
    public function test_get_subwiki_pages_invalid_instance(): void {
567
        $this->expectException(\moodle_exception::class);
567
        $this->expectException(\moodle_exception::class);
568
        mod_wiki_external::get_subwiki_pages(0);
568
        mod_wiki_external::get_subwiki_pages(0);
Línea 569... Línea 569...
569
    }
569
    }
570
 
570
 
571
    /**
571
    /**
572
     * Test get_subwiki_pages using a user not enrolled in the course.
572
     * Test get_subwiki_pages using a user not enrolled in the course.
573
     */
573
     */
574
    public function test_get_subwiki_pages_unenrolled_user() {
574
    public function test_get_subwiki_pages_unenrolled_user(): void {
575
        // Create and use the user.
575
        // Create and use the user.
Línea 576... Línea 576...
576
        $usernotenrolled = self::getDataGenerator()->create_user();
576
        $usernotenrolled = self::getDataGenerator()->create_user();
Línea 581... Línea 581...
581
    }
581
    }
Línea 582... Línea 582...
582
 
582
 
583
    /**
583
    /**
584
     * Test get_subwiki_pages using a hidden wiki as student.
584
     * Test get_subwiki_pages using a hidden wiki as student.
585
     */
585
     */
586
    public function test_get_subwiki_pages_hidden_wiki_as_student() {
586
    public function test_get_subwiki_pages_hidden_wiki_as_student(): void {
587
        // Create a hidden wiki and try to get the list of pages.
587
        // Create a hidden wiki and try to get the list of pages.
588
        $hiddenwiki = $this->getDataGenerator()->create_module('wiki',
588
        $hiddenwiki = $this->getDataGenerator()->create_module('wiki',
Línea 589... Línea 589...
589
                            array('course' => $this->course->id, 'visible' => false));
589
                            array('course' => $this->course->id, 'visible' => false));
Línea 594... Línea 594...
594
    }
594
    }
Línea 595... Línea 595...
595
 
595
 
596
    /**
596
    /**
597
     * Test get_subwiki_pages without the viewpage capability.
597
     * Test get_subwiki_pages without the viewpage capability.
598
     */
598
     */
599
    public function test_get_subwiki_pages_without_viewpage_capability() {
599
    public function test_get_subwiki_pages_without_viewpage_capability(): void {
600
        // Prohibit capability = mod/wiki:viewpage on the course for students.
600
        // Prohibit capability = mod/wiki:viewpage on the course for students.
601
        $contextcourse = \context_course::instance($this->course->id);
601
        $contextcourse = \context_course::instance($this->course->id);
602
        assign_capability('mod/wiki:viewpage', CAP_PROHIBIT, $this->studentrole->id, $contextcourse->id);
602
        assign_capability('mod/wiki:viewpage', CAP_PROHIBIT, $this->studentrole->id, $contextcourse->id);
Línea 608... Línea 608...
608
    }
608
    }
Línea 609... Línea 609...
609
 
609
 
610
    /**
610
    /**
611
     * Test get_subwiki_pages using an invalid userid.
611
     * Test get_subwiki_pages using an invalid userid.
612
     */
612
     */
613
    public function test_get_subwiki_pages_invalid_userid() {
613
    public function test_get_subwiki_pages_invalid_userid(): void {
614
        // Create an individual wiki.
614
        // Create an individual wiki.
615
        $indwiki = $this->getDataGenerator()->create_module('wiki',
615
        $indwiki = $this->getDataGenerator()->create_module('wiki',
Línea 616... Línea 616...
616
                                array('course' => $this->course->id, 'wikimode' => 'individual'));
616
                                array('course' => $this->course->id, 'wikimode' => 'individual'));
Línea 620... Línea 620...
620
    }
620
    }
Línea 621... Línea 621...
621
 
621
 
622
    /**
622
    /**
623
     * Test get_subwiki_pages using an invalid groupid.
623
     * Test get_subwiki_pages using an invalid groupid.
624
     */
624
     */
625
    public function test_get_subwiki_pages_invalid_groupid() {
625
    public function test_get_subwiki_pages_invalid_groupid(): void {
626
        // Create testing data.
626
        // Create testing data.
Línea 627... Línea 627...
627
        $this->create_collaborative_wikis_with_groups();
627
        $this->create_collaborative_wikis_with_groups();
628
 
628
 
629
        $this->expectException(\moodle_exception::class);
629
        $this->expectException(\moodle_exception::class);
Línea 630... Línea 630...
630
        mod_wiki_external::get_subwiki_pages($this->wikisep->id, -111);
630
        mod_wiki_external::get_subwiki_pages($this->wikisep->id, -111);
631
    }
631
    }
632
 
632
 
633
    /**
633
    /**
634
     * Test get_subwiki_pages, check that a student can't see another user pages in an individual wiki without groups.
634
     * Test get_subwiki_pages, check that a student can't see another user pages in an individual wiki without groups.
635
     */
635
     */
636
    public function test_get_subwiki_pages_individual_student_see_other_user() {
636
    public function test_get_subwiki_pages_individual_student_see_other_user(): void {
Línea 637... Línea 637...
637
        // Create an individual wiki.
637
        // Create an individual wiki.
Línea 645... Línea 645...
645
 
645
 
646
    /**
646
    /**
647
     * Test get_subwiki_pages, check that a student can't get the pages from another group in
647
     * Test get_subwiki_pages, check that a student can't get the pages from another group in
648
     * a collaborative wiki using separate groups.
648
     * a collaborative wiki using separate groups.
649
     */
649
     */
650
    public function test_get_subwiki_pages_collaborative_separate_groups_student_see_other_group() {
650
    public function test_get_subwiki_pages_collaborative_separate_groups_student_see_other_group(): void {
651
        // Create testing data.
651
        // Create testing data.
Línea 652... Línea 652...
652
        $this->create_collaborative_wikis_with_groups();
652
        $this->create_collaborative_wikis_with_groups();
653
 
653
 
Línea 658... Línea 658...
658
 
658
 
659
    /**
659
    /**
660
     * Test get_subwiki_pages, check that a student can't get the pages from another group in
660
     * Test get_subwiki_pages, check that a student can't get the pages from another group in
661
     * an individual wiki using separate groups.
661
     * an individual wiki using separate groups.
662
     */
662
     */
663
    public function test_get_subwiki_pages_individual_separate_groups_student_see_other_group() {
663
    public function test_get_subwiki_pages_individual_separate_groups_student_see_other_group(): void {
664
        // Create testing data.
664
        // Create testing data.
Línea 665... Línea 665...
665
        $this->create_individual_wikis_with_groups();
665
        $this->create_individual_wikis_with_groups();
666
 
666
 
Línea 671... Línea 671...
671
 
671
 
672
    /**
672
    /**
673
     * Test get_subwiki_pages, check that a student can't get the pages from all participants in
673
     * Test get_subwiki_pages, check that a student can't get the pages from all participants in
674
     * a collaborative wiki using separate groups.
674
     * a collaborative wiki using separate groups.
675
     */
675
     */
676
    public function test_get_subwiki_pages_collaborative_separate_groups_student_see_all_participants() {
676
    public function test_get_subwiki_pages_collaborative_separate_groups_student_see_all_participants(): void {
677
        // Create testing data.
677
        // Create testing data.
Línea 678... Línea 678...
678
        $this->create_collaborative_wikis_with_groups();
678
        $this->create_collaborative_wikis_with_groups();
679
 
679
 
Línea 684... Línea 684...
684
 
684
 
685
    /**
685
    /**
686
     * Test get_subwiki_pages, check that a student can't get the pages from all participants in
686
     * Test get_subwiki_pages, check that a student can't get the pages from all participants in
687
     * an individual wiki using separate groups.
687
     * an individual wiki using separate groups.
688
     */
688
     */
689
    public function test_get_subwiki_pages_individual_separate_groups_student_see_all_participants() {
689
    public function test_get_subwiki_pages_individual_separate_groups_student_see_all_participants(): void {
690
        // Create testing data.
690
        // Create testing data.
Línea 691... Línea 691...
691
        $this->create_individual_wikis_with_groups();
691
        $this->create_individual_wikis_with_groups();
692
 
692
 
Línea 696... Línea 696...
696
    }
696
    }
Línea 697... Línea 697...
697
 
697
 
698
    /**
698
    /**
699
     * Test get_subwiki_pages without groups and collaborative wiki.
699
     * Test get_subwiki_pages without groups and collaborative wiki.
700
     */
700
     */
Línea 701... Línea 701...
701
    public function test_get_subwiki_pages_collaborative() {
701
    public function test_get_subwiki_pages_collaborative(): void {
702
 
702
 
Línea 703... Línea 703...
703
        // Test user with full capabilities.
703
        // Test user with full capabilities.
Línea 762... Línea 762...
762
    }
762
    }
Línea 763... Línea 763...
763
 
763
 
764
    /**
764
    /**
765
     * Test get_subwiki_pages without groups.
765
     * Test get_subwiki_pages without groups.
766
     */
766
     */
Línea 767... Línea 767...
767
    public function test_get_subwiki_pages_individual() {
767
    public function test_get_subwiki_pages_individual(): void {
768
 
768
 
769
        // Create an individual wiki to test userid param.
769
        // Create an individual wiki to test userid param.
Línea 819... Línea 819...
819
    }
819
    }
Línea 820... Línea 820...
820
 
820
 
821
    /**
821
    /**
822
     * Test get_subwiki_pages with groups and collaborative wikis.
822
     * Test get_subwiki_pages with groups and collaborative wikis.
823
     */
823
     */
Línea 824... Línea 824...
824
    public function test_get_subwiki_pages_separate_groups_collaborative() {
824
    public function test_get_subwiki_pages_separate_groups_collaborative(): void {
825
 
825
 
Línea 826... Línea 826...
826
        // Create testing data.
826
        // Create testing data.
Línea 866... Línea 866...
866
    }
866
    }
Línea 867... Línea 867...
867
 
867
 
868
    /**
868
    /**
869
     * Test get_subwiki_pages with groups and collaborative wikis.
869
     * Test get_subwiki_pages with groups and collaborative wikis.
870
     */
870
     */
Línea 871... Línea 871...
871
    public function test_get_subwiki_pages_visible_groups_collaborative() {
871
    public function test_get_subwiki_pages_visible_groups_collaborative(): void {
872
 
872
 
Línea 873... Línea 873...
873
        // Create testing data.
873
        // Create testing data.
Línea 914... Línea 914...
914
    }
914
    }
Línea 915... Línea 915...
915
 
915
 
916
    /**
916
    /**
917
     * Test get_subwiki_pages with groups and individual wikis.
917
     * Test get_subwiki_pages with groups and individual wikis.
918
     */
918
     */
Línea 919... Línea 919...
919
    public function test_get_subwiki_pages_separate_groups_individual() {
919
    public function test_get_subwiki_pages_separate_groups_individual(): void {
920
 
920
 
Línea 921... Línea 921...
921
        // Create testing data.
921
        // Create testing data.
Línea 961... Línea 961...
961
    }
961
    }
Línea 962... Línea 962...
962
 
962
 
963
    /**
963
    /**
964
     * Test get_subwiki_pages with groups and individual wikis.
964
     * Test get_subwiki_pages with groups and individual wikis.
965
     */
965
     */
Línea 966... Línea 966...
966
    public function test_get_subwiki_pages_visible_groups_individual() {
966
    public function test_get_subwiki_pages_visible_groups_individual(): void {
967
 
967
 
Línea 968... Línea 968...
968
        // Create testing data.
968
        // Create testing data.
Línea 1008... Línea 1008...
1008
    }
1008
    }
Línea 1009... Línea 1009...
1009
 
1009
 
1010
    /**
1010
    /**
1011
     * Test get_page_contents using an invalid pageid.
1011
     * Test get_page_contents using an invalid pageid.
1012
     */
1012
     */
1013
    public function test_get_page_contents_invalid_pageid() {
1013
    public function test_get_page_contents_invalid_pageid(): void {
1014
        $this->expectException(\moodle_exception::class);
1014
        $this->expectException(\moodle_exception::class);
1015
        mod_wiki_external::get_page_contents(0);
1015
        mod_wiki_external::get_page_contents(0);
Línea 1016... Línea 1016...
1016
    }
1016
    }
1017
 
1017
 
1018
    /**
1018
    /**
1019
     * Test get_page_contents using a user not enrolled in the course.
1019
     * Test get_page_contents using a user not enrolled in the course.
1020
     */
1020
     */
1021
    public function test_get_page_contents_unenrolled_user() {
1021
    public function test_get_page_contents_unenrolled_user(): void {
1022
        // Create and use the user.
1022
        // Create and use the user.
Línea 1023... Línea 1023...
1023
        $usernotenrolled = self::getDataGenerator()->create_user();
1023
        $usernotenrolled = self::getDataGenerator()->create_user();
Línea 1028... Línea 1028...
1028
    }
1028
    }
Línea 1029... Línea 1029...
1029
 
1029
 
1030
    /**
1030
    /**
1031
     * Test get_page_contents using a hidden wiki as student.
1031
     * Test get_page_contents using a hidden wiki as student.
1032
     */
1032
     */
1033
    public function test_get_page_contents_hidden_wiki_as_student() {
1033
    public function test_get_page_contents_hidden_wiki_as_student(): void {
1034
        // Create a hidden wiki and try to get a page contents.
1034
        // Create a hidden wiki and try to get a page contents.
1035
        $hiddenwiki = $this->getDataGenerator()->create_module('wiki',
1035
        $hiddenwiki = $this->getDataGenerator()->create_module('wiki',
1036
                            array('course' => $this->course->id, 'visible' => false));
1036
                            array('course' => $this->course->id, 'visible' => false));
Línea 1042... Línea 1042...
1042
    }
1042
    }
Línea 1043... Línea 1043...
1043
 
1043
 
1044
    /**
1044
    /**
1045
     * Test get_page_contents without the viewpage capability.
1045
     * Test get_page_contents without the viewpage capability.
1046
     */
1046
     */
1047
    public function test_get_page_contents_without_viewpage_capability() {
1047
    public function test_get_page_contents_without_viewpage_capability(): void {
1048
        // Prohibit capability = mod/wiki:viewpage on the course for students.
1048
        // Prohibit capability = mod/wiki:viewpage on the course for students.
1049
        $contextcourse = \context_course::instance($this->course->id);
1049
        $contextcourse = \context_course::instance($this->course->id);
1050
        assign_capability('mod/wiki:viewpage', CAP_PROHIBIT, $this->studentrole->id, $contextcourse->id);
1050
        assign_capability('mod/wiki:viewpage', CAP_PROHIBIT, $this->studentrole->id, $contextcourse->id);
Línea 1057... Línea 1057...
1057
 
1057
 
1058
    /**
1058
    /**
1059
     * Test get_page_contents, check that a student can't get a page from another group when
1059
     * Test get_page_contents, check that a student can't get a page from another group when
1060
     * using separate groups.
1060
     * using separate groups.
1061
     */
1061
     */
1062
    public function test_get_page_contents_separate_groups_student_see_other_group() {
1062
    public function test_get_page_contents_separate_groups_student_see_other_group(): void {
1063
        // Create testing data.
1063
        // Create testing data.
Línea 1064... Línea 1064...
1064
        $this->create_individual_wikis_with_groups();
1064
        $this->create_individual_wikis_with_groups();
1065
 
1065
 
Línea 1070... Línea 1070...
1070
 
1070
 
1071
    /**
1071
    /**
1072
     * Test get_page_contents without groups. We won't test all the possible cases because that's already
1072
     * Test get_page_contents without groups. We won't test all the possible cases because that's already
1073
     * done in the tests for get_subwiki_pages.
1073
     * done in the tests for get_subwiki_pages.
1074
     */
1074
     */
Línea 1075... Línea 1075...
1075
    public function test_get_page_contents() {
1075
    public function test_get_page_contents(): void {
1076
 
1076
 
Línea 1077... Línea 1077...
1077
        // Test user with full capabilities.
1077
        // Test user with full capabilities.
Línea 1114... Línea 1114...
1114
 
1114
 
1115
    /**
1115
    /**
1116
     * Test get_page_contents with groups. We won't test all the possible cases because that's already
1116
     * Test get_page_contents with groups. We won't test all the possible cases because that's already
1117
     * done in the tests for get_subwiki_pages.
1117
     * done in the tests for get_subwiki_pages.
1118
     */
1118
     */
Línea 1119... Línea 1119...
1119
    public function test_get_page_contents_with_groups() {
1119
    public function test_get_page_contents_with_groups(): void {
1120
 
1120
 
Línea 1121... Línea 1121...
1121
        // Create testing data.
1121
        // Create testing data.
Línea 1150... Línea 1150...
1150
    }
1150
    }
Línea 1151... Línea 1151...
1151
 
1151
 
1152
    /**
1152
    /**
1153
     * Test get_subwiki_files using a wiki without files.
1153
     * Test get_subwiki_files using a wiki without files.
1154
     */
1154
     */
1155
    public function test_get_subwiki_files_no_files() {
1155
    public function test_get_subwiki_files_no_files(): void {
1156
        $result = mod_wiki_external::get_subwiki_files($this->wiki->id);
1156
        $result = mod_wiki_external::get_subwiki_files($this->wiki->id);
1157
        $result = external_api::clean_returnvalue(mod_wiki_external::get_subwiki_files_returns(), $result);
1157
        $result = external_api::clean_returnvalue(mod_wiki_external::get_subwiki_files_returns(), $result);
1158
        $this->assertCount(0, $result['files']);
1158
        $this->assertCount(0, $result['files']);
1159
        $this->assertCount(0, $result['warnings']);
1159
        $this->assertCount(0, $result['warnings']);
Línea 1160... Línea 1160...
1160
    }
1160
    }
1161
 
1161
 
1162
    /**
1162
    /**
1163
     * Test get_subwiki_files, check that a student can't get files from another group's subwiki when
1163
     * Test get_subwiki_files, check that a student can't get files from another group's subwiki when
1164
     * using separate groups.
1164
     * using separate groups.
1165
     */
1165
     */
1166
    public function test_get_subwiki_files_separate_groups_student_see_other_group() {
1166
    public function test_get_subwiki_files_separate_groups_student_see_other_group(): void {
Línea 1167... Línea 1167...
1167
        // Create testing data.
1167
        // Create testing data.
1168
        $this->create_collaborative_wikis_with_groups();
1168
        $this->create_collaborative_wikis_with_groups();
Línea 1173... Línea 1173...
1173
    }
1173
    }
Línea 1174... Línea 1174...
1174
 
1174
 
1175
    /**
1175
    /**
1176
     * Test get_subwiki_files using a collaborative wiki without groups.
1176
     * Test get_subwiki_files using a collaborative wiki without groups.
1177
     */
1177
     */
1178
    public function test_get_subwiki_files_collaborative_no_groups() {
1178
    public function test_get_subwiki_files_collaborative_no_groups(): void {
Línea 1179... Línea 1179...
1179
        $this->setUser($this->student);
1179
        $this->setUser($this->student);
1180
 
1180
 
1181
        // Add a file as subwiki attachment.
1181
        // Add a file as subwiki attachment.
Línea 1225... Línea 1225...
1225
    }
1225
    }
Línea 1226... Línea 1226...
1226
 
1226
 
1227
    /**
1227
    /**
1228
     * Test get_subwiki_files using an individual wiki with visible groups.
1228
     * Test get_subwiki_files using an individual wiki with visible groups.
1229
     */
1229
     */
1230
    public function test_get_subwiki_files_visible_groups_individual() {
1230
    public function test_get_subwiki_files_visible_groups_individual(): void {
1231
        // Create testing data.
1231
        // Create testing data.
Línea 1232... Línea 1232...
1232
        $this->create_individual_wikis_with_groups();
1232
        $this->create_individual_wikis_with_groups();
Línea 1271... Línea 1271...
1271
 
1271
 
1272
    /**
1272
    /**
1273
     * Test get_page_for_editing. We won't test all the possible cases because that's already
1273
     * Test get_page_for_editing. We won't test all the possible cases because that's already
1274
     * done in the tests for wiki_parser_proxy::get_section.
1274
     * done in the tests for wiki_parser_proxy::get_section.
1275
     */
1275
     */
Línea 1276... Línea 1276...
1276
    public function test_get_page_for_editing() {
1276
    public function test_get_page_for_editing(): void {
Línea 1277... Línea 1277...
1277
 
1277
 
1278
        $this->create_individual_wikis_with_groups();
1278
        $this->create_individual_wikis_with_groups();
Línea 1310... Línea 1310...
1310
    }
1310
    }
Línea 1311... Línea 1311...
1311
 
1311
 
1312
    /**
1312
    /**
1313
     * Test test_get_page_locking.
1313
     * Test test_get_page_locking.
1314
     */
1314
     */
Línea 1315... Línea 1315...
1315
    public function test_get_page_locking() {
1315
    public function test_get_page_locking(): void {
Línea 1316... Línea 1316...
1316
 
1316
 
1317
        $this->create_individual_wikis_with_groups();
1317
        $this->create_individual_wikis_with_groups();
Línea 1369... Línea 1369...
1369
 
1369
 
1370
    /**
1370
    /**
1371
     * Test new_page. We won't test all the possible cases because that's already
1371
     * Test new_page. We won't test all the possible cases because that's already
1372
     * done in the tests for wiki_create_page.
1372
     * done in the tests for wiki_create_page.
1373
     */
1373
     */
Línea 1374... Línea 1374...
1374
    public function test_new_page() {
1374
    public function test_new_page(): void {
Línea 1375... Línea 1375...
1375
 
1375
 
1376
        $this->create_individual_wikis_with_groups();
1376
        $this->create_individual_wikis_with_groups();
Línea 1441... Línea 1441...
1441
 
1441
 
1442
    /**
1442
    /**
1443
     * Test edit_page. We won't test all the possible cases because that's already
1443
     * Test edit_page. We won't test all the possible cases because that's already
1444
     * done in the tests for wiki_save_section / wiki_save_page.
1444
     * done in the tests for wiki_save_section / wiki_save_page.
1445
     */
1445
     */
Línea 1446... Línea 1446...
1446
    public function test_edit_page() {
1446
    public function test_edit_page(): void {
Línea 1447... Línea 1447...
1447
 
1447
 
1448
        $this->create_individual_wikis_with_groups();
1448
        $this->create_individual_wikis_with_groups();