Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 165... Línea 165...
165
            '"targetCode":"%s"}]}';
165
            '"targetCode":"%s"}]}';
166
        $this->assertion2->issuer = '{"name":"%s","url":"%s","email":"%s",' .
166
        $this->assertion2->issuer = '{"name":"%s","url":"%s","email":"%s",' .
167
            '"@context":"https:\/\/w3id.org\/openbadges\/v2","id":"%s","type":"Issuer"}';
167
            '"@context":"https:\/\/w3id.org\/openbadges\/v2","id":"%s","type":"Issuer"}';
168
    }
168
    }
Línea 169... Línea 169...
169
 
169
 
170
    public function test_create_badge() {
170
    public function test_create_badge(): void {
Línea 171... Línea 171...
171
        $badge = new badge($this->badgeid);
171
        $badge = new badge($this->badgeid);
172
 
172
 
173
        $this->assertInstanceOf('badge', $badge);
173
        $this->assertInstanceOf('badge', $badge);
Línea 174... Línea 174...
174
        $this->assertEquals($this->badgeid, $badge->id);
174
        $this->assertEquals($this->badgeid, $badge->id);
175
    }
175
    }
176
 
176
 
177
    public function test_clone_badge() {
177
    public function test_clone_badge(): void {
Línea 178... Línea 178...
178
        $badge = new badge($this->badgeid);
178
        $badge = new badge($this->badgeid);
Línea 198... Línea 198...
198
        $this->assertEquals($badge->imageauthorname, $clonedbadge->imageauthorname);
198
        $this->assertEquals($badge->imageauthorname, $clonedbadge->imageauthorname);
199
        $this->assertEquals($badge->imageauthoremail, $clonedbadge->imageauthoremail);
199
        $this->assertEquals($badge->imageauthoremail, $clonedbadge->imageauthoremail);
200
        $this->assertEquals($badge->imageauthorurl, $clonedbadge->imageauthorurl);
200
        $this->assertEquals($badge->imageauthorurl, $clonedbadge->imageauthorurl);
201
    }
201
    }
Línea 202... Línea 202...
202
 
202
 
203
    public function test_badge_status() {
203
    public function test_badge_status(): void {
204
        $badge = new badge($this->badgeid);
204
        $badge = new badge($this->badgeid);
205
        $old_status = $badge->status;
205
        $old_status = $badge->status;
206
        $badge->set_status(BADGE_STATUS_ACTIVE);
206
        $badge->set_status(BADGE_STATUS_ACTIVE);
207
        $this->assertNotEquals($old_status, $badge->status);
207
        $this->assertNotEquals($old_status, $badge->status);
208
        $this->assertEquals(BADGE_STATUS_ACTIVE, $badge->status);
208
        $this->assertEquals(BADGE_STATUS_ACTIVE, $badge->status);
Línea 209... Línea 209...
209
    }
209
    }
210
 
210
 
211
    public function test_delete_badge() {
211
    public function test_delete_badge(): void {
212
        $badge = new badge($this->badgeid);
212
        $badge = new badge($this->badgeid);
213
        $badge->delete();
213
        $badge->delete();
214
        // We don't actually delete badges. We archive them.
214
        // We don't actually delete badges. We archive them.
Línea 215... Línea 215...
215
        $this->assertEquals(BADGE_STATUS_ARCHIVED, $badge->status);
215
        $this->assertEquals(BADGE_STATUS_ARCHIVED, $badge->status);
216
    }
216
    }
217
 
217
 
218
    /**
218
    /**
219
     * Really delete the badge.
219
     * Really delete the badge.
Línea 220... Línea 220...
220
     */
220
     */
221
    public function test_delete_badge_for_real() {
221
    public function test_delete_badge_for_real(): void {
222
        global $DB;
222
        global $DB;
Línea 260... Línea 260...
260
 
260
 
261
        // Confirm that the tag instance of the badge has been removed.
261
        // Confirm that the tag instance of the badge has been removed.
262
        $this->assertFalse($DB->record_exists('tag_instance', ['itemid' => $this->badgeid]));
262
        $this->assertFalse($DB->record_exists('tag_instance', ['itemid' => $this->badgeid]));
Línea 263... Línea 263...
263
    }
263
    }
264
 
264
 
265
    public function test_create_badge_criteria() {
265
    public function test_create_badge_criteria(): void {
266
        $badge = new badge($this->badgeid);
266
        $badge = new badge($this->badgeid);
Línea 267... Línea 267...
267
        $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $badge->id));
267
        $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $badge->id));
Línea 274... Línea 274...
274
        $criteria_profile->save($params);
274
        $criteria_profile->save($params);
Línea 275... Línea 275...
275
 
275
 
276
        $this->assertCount(2, $badge->get_criteria());
276
        $this->assertCount(2, $badge->get_criteria());
Línea 277... Línea 277...
277
    }
277
    }
278
 
278
 
279
    public function test_add_badge_criteria_description() {
279
    public function test_add_badge_criteria_description(): void {
280
        $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid));
280
        $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid));
281
        $criteriaoverall->save(array(
281
        $criteriaoverall->save(array(
282
                'agg' => BADGE_CRITERIA_AGGREGATION_ALL,
282
                'agg' => BADGE_CRITERIA_AGGREGATION_ALL,
Línea 296... Línea 296...
296
        $badge = new badge($this->badgeid);
296
        $badge = new badge($this->badgeid);
297
        $this->assertEquals('Overall description', $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]->description);
297
        $this->assertEquals('Overall description', $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]->description);
298
        $this->assertEquals('Description', $badge->criteria[BADGE_CRITERIA_TYPE_PROFILE]->description);
298
        $this->assertEquals('Description', $badge->criteria[BADGE_CRITERIA_TYPE_PROFILE]->description);
299
    }
299
    }
Línea 300... Línea 300...
300
 
300
 
301
    public function test_delete_badge_criteria() {
301
    public function test_delete_badge_criteria(): void {
302
        $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid));
302
        $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid));
303
        $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL));
303
        $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL));
Línea 304... Línea 304...
304
        $badge = new badge($this->badgeid);
304
        $badge = new badge($this->badgeid);
Línea 305... Línea 305...
305
 
305
 
306
        $this->assertInstanceOf('award_criteria_overall', $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]);
306
        $this->assertInstanceOf('award_criteria_overall', $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]);
307
 
307
 
Línea 308... Línea 308...
308
        $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]->delete();
308
        $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]->delete();
309
        $this->assertEmpty($badge->get_criteria());
309
        $this->assertEmpty($badge->get_criteria());
310
    }
310
    }
311
 
311
 
312
    public function test_badge_awards() {
312
    public function test_badge_awards(): void {
Línea 341... Línea 341...
341
    }
341
    }
Línea 342... Línea 342...
342
 
342
 
343
    /**
343
    /**
344
     * Test the {@link badges_get_user_badges()} function in lib/badgeslib.php
344
     * Test the {@link badges_get_user_badges()} function in lib/badgeslib.php
345
     */
345
     */
346
    public function test_badges_get_user_badges() {
346
    public function test_badges_get_user_badges(): void {
Línea 347... Línea 347...
347
        global $DB;
347
        global $DB;
348
 
348
 
Línea 518... Línea 518...
518
    }
518
    }
Línea 519... Línea 519...
519
 
519
 
520
    /**
520
    /**
521
     * @dataProvider data_for_message_from_template
521
     * @dataProvider data_for_message_from_template
522
     */
522
     */
523
    public function test_badge_message_from_template($message, $params, $result) {
523
    public function test_badge_message_from_template($message, $params, $result): void {
524
        $this->assertEquals(badge_message_from_template($message, $params), $result);
524
        $this->assertEquals(badge_message_from_template($message, $params), $result);
Línea 525... Línea 525...
525
    }
525
    }
526
 
526
 
527
    /**
527
    /**
528
     * Test for working around the 61 tables join limit of mysql in award_criteria_activity in combination with the scheduled task.
528
     * Test for working around the 61 tables join limit of mysql in award_criteria_activity in combination with the scheduled task.
529
     *
529
     *
530
     * @covers \core_badges\badge::review_all_criteria
530
     * @covers \core_badges\badge::review_all_criteria
531
     */
531
     */
532
    public function test_badge_activity_criteria_with_a_huge_number_of_coursemodules() {
532
    public function test_badge_activity_criteria_with_a_huge_number_of_coursemodules(): void {
Línea 533... Línea 533...
533
        global $CFG;
533
        global $CFG;
534
        require_once($CFG->dirroot.'/completion/criteria/completion_criteria_activity.php');
534
        require_once($CFG->dirroot.'/completion/criteria/completion_criteria_activity.php');
Línea 603... Línea 603...
603
    }
603
    }
Línea 604... Línea 604...
604
 
604
 
605
    /**
605
    /**
606
     * Test badges observer when course module completion event id fired.
606
     * Test badges observer when course module completion event id fired.
607
     */
607
     */
608
    public function test_badges_observer_course_module_criteria_review() {
608
    public function test_badges_observer_course_module_criteria_review(): void {
609
        $this->preventResetByRollback(); // Messaging is not compatible with transactions.
609
        $this->preventResetByRollback(); // Messaging is not compatible with transactions.
610
        $badge = new badge($this->coursebadge);
610
        $badge = new badge($this->coursebadge);
Línea 611... Línea 611...
611
        $this->assertFalse($badge->is_issued($this->user->id));
611
        $this->assertFalse($badge->is_issued($this->user->id));
Línea 641... Línea 641...
641
    }
641
    }
Línea 642... Línea 642...
642
 
642
 
643
    /**
643
    /**
644
     * Test badges observer when course_completed event is fired.
644
     * Test badges observer when course_completed event is fired.
645
     */
645
     */
646
    public function test_badges_observer_course_criteria_review() {
646
    public function test_badges_observer_course_criteria_review(): void {
647
        $this->preventResetByRollback(); // Messaging is not compatible with transactions.
647
        $this->preventResetByRollback(); // Messaging is not compatible with transactions.
648
        $badge = new badge($this->coursebadge);
648
        $badge = new badge($this->coursebadge);
Línea 649... Línea 649...
649
        $this->assertFalse($badge->is_issued($this->user->id));
649
        $this->assertFalse($badge->is_issued($this->user->id));
Línea 676... Línea 676...
676
    }
676
    }
Línea 677... Línea 677...
677
 
677
 
678
    /**
678
    /**
679
     * Test badges observer when user_updated event is fired.
679
     * Test badges observer when user_updated event is fired.
680
     */
680
     */
681
    public function test_badges_observer_profile_criteria_review() {
681
    public function test_badges_observer_profile_criteria_review(): void {
682
        global $CFG, $DB;
682
        global $CFG, $DB;
Línea 683... Línea 683...
683
        require_once($CFG->dirroot.'/user/profile/lib.php');
683
        require_once($CFG->dirroot.'/user/profile/lib.php');
684
 
684
 
Línea 717... Línea 717...
717
    /**
717
    /**
718
     * Test badges observer when cohort_member_added event is fired and user required to belong to any cohort.
718
     * Test badges observer when cohort_member_added event is fired and user required to belong to any cohort.
719
     *
719
     *
720
     * @covers \award_criteria_cohort
720
     * @covers \award_criteria_cohort
721
     */
721
     */
722
    public function test_badges_observer_any_cohort_criteria_review() {
722
    public function test_badges_observer_any_cohort_criteria_review(): void {
723
        global $CFG;
723
        global $CFG;
Línea 724... Línea 724...
724
 
724
 
Línea 725... Línea 725...
725
        require_once("$CFG->dirroot/cohort/lib.php");
725
        require_once("$CFG->dirroot/cohort/lib.php");
Línea 756... Línea 756...
756
        // cohort, there are no other users that can award this badge.
756
        // cohort, there are no other users that can award this badge.
757
        $this->assertSame(0, $badge->review_all_criteria()); // Verify award_criteria_cohort->get_completed_criteria_sql().
757
        $this->assertSame(0, $badge->review_all_criteria()); // Verify award_criteria_cohort->get_completed_criteria_sql().
758
    }
758
    }
Línea 759... Línea 759...
759
 
759
 
-
 
760
    /**
-
 
761
     * Test badges observer when user_updated event is fired.
-
 
762
     * @covers \award_criteria_courseset
-
 
763
     */
-
 
764
    public function test_badges_observer_courseset_criteria_review(): void {
-
 
765
        $this->preventResetByRollback(); // Messaging is not compatible with transactions.
-
 
766
        $badge = new badge($this->coursebadge);
-
 
767
        $this->assertFalse($badge->is_issued($this->user->id));
-
 
768
 
-
 
769
        $additionalcourse = $this->getDataGenerator()->create_course(['enablecompletion' => true]);
-
 
770
        $this->getDataGenerator()->enrol_user($this->user->id, $additionalcourse->id);
-
 
771
 
-
 
772
        $criteriaoverall = award_criteria::build(['criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $badge->id]);
-
 
773
        $criteriaoverall->save(['agg' => BADGE_CRITERIA_AGGREGATION_ANY]);
-
 
774
        $criteriaoverall1 = award_criteria::build(['criteriatype' => BADGE_CRITERIA_TYPE_COURSESET, 'badgeid' => $badge->id]);
-
 
775
        $criteriaoverall1->save(['agg' => BADGE_CRITERIA_AGGREGATION_ANY, 'course_' . $this->course->id => $this->course->id,
-
 
776
            'course_' . $additionalcourse->id => $additionalcourse->id]);
-
 
777
 
-
 
778
        $ccompletion = new completion_completion(['course' => $this->course->id, 'userid' => $this->user->id]);
-
 
779
        $ccompletion2 = new completion_completion(['course' => $additionalcourse->id, 'userid' => $this->user->id]);
-
 
780
        // Assert the badge will not be issued to the user as is.
-
 
781
        $badge = new badge($this->coursebadge);
-
 
782
        $badge->review_all_criteria();
-
 
783
        $this->assertFalse($badge->is_issued($this->user->id));
-
 
784
 
-
 
785
        // Mark course as complete.
-
 
786
        $sink = $this->redirectMessages();
-
 
787
        $ccompletion->mark_complete();
-
 
788
        $ccompletion2->mark_complete();
-
 
789
        // Thee messages are generated: Two for the course completed and the other one for the badge awarded.
-
 
790
        $messages = $sink->get_messages();
-
 
791
        $this->assertCount(3, $messages);
-
 
792
        $this->assertEquals('badgerecipientnotice', $messages[0]->eventtype);
-
 
793
        $this->assertEquals('coursecompleted', $messages[1]->eventtype);
-
 
794
        $sink->close();
-
 
795
 
-
 
796
        // Check if badge is awarded.
-
 
797
        $this->assertDebuggingCalled('Error baking badge image!');
-
 
798
        $this->assertTrue($badge->is_issued($this->user->id));
-
 
799
    }
-
 
800
 
-
 
801
    /**
-
 
802
     * Test the criteria review method for courseset
-
 
803
     * @covers \award_criteria_courseset::review
-
 
804
     */
-
 
805
    public function test_badges_courseset_criteria_review_empty_courseset(): void {
-
 
806
        $this->preventResetByRollback(); // Messaging is not compatible with transactions.
-
 
807
        $badge = new badge($this->coursebadge);
-
 
808
        $this->assertFalse($badge->is_issued($this->user->id));
-
 
809
 
-
 
810
        $criteriaoverall = award_criteria::build(['criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $badge->id]);
-
 
811
        $criteriaoverall->save(['agg' => BADGE_CRITERIA_AGGREGATION_ANY]);
-
 
812
        $criteriaoverall1 = award_criteria::build(['criteriatype' => BADGE_CRITERIA_TYPE_COURSESET, 'badgeid' => $badge->id]);
-
 
813
        $criteriaoverall1->save();
-
 
814
        // Assert the badge will not be issued to the user as is.
-
 
815
        $badge = new badge($this->coursebadge);
-
 
816
        $badge->review_all_criteria();
-
 
817
        $this->assertFalse($badge->is_issued($this->user->id));
-
 
818
    }
-
 
819
 
760
    /**
820
    /**
761
     * Test badges observer when cohort_member_added event is fired and user required to belong to multiple (all) cohorts.
821
     * Test badges observer when cohort_member_added event is fired and user required to belong to multiple (all) cohorts.
762
     *
822
     *
763
     * @covers \award_criteria_cohort
823
     * @covers \award_criteria_cohort
764
     */
824
     */
765
    public function test_badges_observer_all_cohort_criteria_review() {
825
    public function test_badges_observer_all_cohort_criteria_review(): void {
Línea 766... Línea 826...
766
        global $CFG;
826
        global $CFG;
Línea 767... Línea 827...
767
 
827
 
Línea 839... Línea 899...
839
    }
899
    }
Línea 840... Línea 900...
840
 
900
 
841
    /**
901
    /**
842
     * Test badges assertion generated when a badge is issued.
902
     * Test badges assertion generated when a badge is issued.
843
     */
903
     */
844
    public function test_badges_assertion() {
904
    public function test_badges_assertion(): void {
845
        $this->preventResetByRollback(); // Messaging is not compatible with transactions.
905
        $this->preventResetByRollback(); // Messaging is not compatible with transactions.
846
        $badge = new badge($this->coursebadge);
906
        $badge = new badge($this->coursebadge);
Línea 847... Línea 907...
847
        $this->assertFalse($badge->is_issued($this->user->id));
907
        $this->assertFalse($badge->is_issued($this->user->id));
Línea 894... Línea 954...
894
    }
954
    }
Línea 895... Línea 955...
895
 
955
 
896
    /**
956
    /**
897
     * Tests the core_badges_myprofile_navigation() function.
957
     * Tests the core_badges_myprofile_navigation() function.
898
     */
958
     */
899
    public function test_core_badges_myprofile_navigation() {
959
    public function test_core_badges_myprofile_navigation(): void {
900
        // Set up the test.
960
        // Set up the test.
901
        $tree = new \core_user\output\myprofile\tree();
961
        $tree = new \core_user\output\myprofile\tree();
902
        $this->setAdminUser();
962
        $this->setAdminUser();
903
        $badge = new badge($this->badgeid);
963
        $badge = new badge($this->badgeid);
Línea 916... Línea 976...
916
    }
976
    }
Línea 917... Línea 977...
917
 
977
 
918
    /**
978
    /**
919
     * Tests the core_badges_myprofile_navigation() function with badges disabled..
979
     * Tests the core_badges_myprofile_navigation() function with badges disabled..
920
     */
980
     */
921
    public function test_core_badges_myprofile_navigation_badges_disabled() {
981
    public function test_core_badges_myprofile_navigation_badges_disabled(): void {
922
        // Set up the test.
982
        // Set up the test.
923
        $tree = new \core_user\output\myprofile\tree();
983
        $tree = new \core_user\output\myprofile\tree();
924
        $this->setAdminUser();
984
        $this->setAdminUser();
925
        $badge = new badge($this->badgeid);
985
        $badge = new badge($this->badgeid);
Línea 938... Línea 998...
938
    }
998
    }
Línea 939... Línea 999...
939
 
999
 
940
    /**
1000
    /**
941
     * Tests the core_badges_myprofile_navigation() function with a course badge.
1001
     * Tests the core_badges_myprofile_navigation() function with a course badge.
942
     */
1002
     */
943
    public function test_core_badges_myprofile_navigation_with_course_badge() {
1003
    public function test_core_badges_myprofile_navigation_with_course_badge(): void {
944
        // Set up the test.
1004
        // Set up the test.
945
        $tree = new \core_user\output\myprofile\tree();
1005
        $tree = new \core_user\output\myprofile\tree();
946
        $this->setAdminUser();
1006
        $this->setAdminUser();
947
        $badge = new badge($this->coursebadge);
1007
        $badge = new badge($this->coursebadge);
Línea 956... Línea 1016...
956
    }
1016
    }
Línea 957... Línea 1017...
957
 
1017
 
958
    /**
1018
    /**
959
     * Test insert and update endorsement with a site badge.
1019
     * Test insert and update endorsement with a site badge.
960
     */
1020
     */
961
    public function test_badge_endorsement() {
1021
    public function test_badge_endorsement(): void {
Línea 962... Línea 1022...
962
        $badge = new badge($this->badgeid);
1022
        $badge = new badge($this->badgeid);
963
 
1023
 
964
        // Insert Endorsement.
1024
        // Insert Endorsement.
Línea 990... Línea 1050...
990
    }
1050
    }
Línea 991... Línea 1051...
991
 
1051
 
992
    /**
1052
    /**
993
     * Test insert and delete related badge with a site badge.
1053
     * Test insert and delete related badge with a site badge.
994
     */
1054
     */
995
    public function test_badge_related() {
1055
    public function test_badge_related(): void {
996
        $badge = new badge($this->badgeid);
1056
        $badge = new badge($this->badgeid);
997
        $newid1 = $badge->make_clone();
1057
        $newid1 = $badge->make_clone();
998
        $newid2 = $badge->make_clone();
1058
        $newid2 = $badge->make_clone();
Línea 1014... Línea 1074...
1014
    }
1074
    }
Línea 1015... Línea 1075...
1015
 
1075
 
1016
    /**
1076
    /**
1017
     * Test insert, update, delete alignment with a site badge.
1077
     * Test insert, update, delete alignment with a site badge.
1018
     */
1078
     */
1019
    public function test_alignments() {
1079
    public function test_alignments(): void {
Línea 1020... Línea 1080...
1020
        $badge = new badge($this->badgeid);
1080
        $badge = new badge($this->badgeid);
1021
 
1081
 
1022
        // Insert a alignment.
1082
        // Insert a alignment.
Línea 1112... Línea 1172...
1112
     * @dataProvider save_backpack_credentials_provider
1172
     * @dataProvider save_backpack_credentials_provider
1113
     * @param  bool $addbackpack True if backpack data has to be created; false otherwise (empty data will be used then).
1173
     * @param  bool $addbackpack True if backpack data has to be created; false otherwise (empty data will be used then).
1114
     * @param  string|null  $mail  Backpack mail address.
1174
     * @param  string|null  $mail  Backpack mail address.
1115
     * @param  string|null  $password  Backpack password.
1175
     * @param  string|null  $password  Backpack password.
1116
     */
1176
     */
1117
    public function test_save_backpack_credentials(bool $addbackpack = true, ?string $mail = null, ?string $password = null) {
1177
    public function test_save_backpack_credentials(bool $addbackpack = true, ?string $mail = null, ?string $password = null): void {
1118
        global $DB;
1178
        global $DB;
Línea 1119... Línea 1179...
1119
 
1179
 
1120
        $this->resetAfterTest();
1180
        $this->resetAfterTest();
Línea 1208... Línea 1268...
1208
     * @dataProvider badges_save_external_backpack_provider
1268
     * @dataProvider badges_save_external_backpack_provider
1209
     * @param  array $data  Backpack data to save.
1269
     * @param  array $data  Backpack data to save.
1210
     * @param  bool $adduser True if a real user has to be used for creating the backpack; false otherwise.
1270
     * @param  bool $adduser True if a real user has to be used for creating the backpack; false otherwise.
1211
     * @param  bool $duplicates True if duplicates has to be tested too; false otherwise.
1271
     * @param  bool $duplicates True if duplicates has to be tested too; false otherwise.
1212
     */
1272
     */
1213
    public function test_badges_save_external_backpack(array $data, bool $adduser, bool $duplicates) {
1273
    public function test_badges_save_external_backpack(array $data, bool $adduser, bool $duplicates): void {
1214
        global $DB;
1274
        global $DB;
Línea 1215... Línea 1275...
1215
 
1275
 
Línea 1216... Línea 1276...
1216
        $this->resetAfterTest();
1276
        $this->resetAfterTest();
Línea 1319... Línea 1379...
1319
     *
1379
     *
1320
     * @param boolean $isadmin
1380
     * @param boolean $isadmin
1321
     * @param boolean $updatetest
1381
     * @param boolean $updatetest
1322
     * @dataProvider badges_create_site_backpack_provider
1382
     * @dataProvider badges_create_site_backpack_provider
1323
     */
1383
     */
1324
    public function test_badges_create_site_backpack($isadmin, $updatetest) {
1384
    public function test_badges_create_site_backpack($isadmin, $updatetest): void {
1325
        global $DB;
1385
        global $DB;
1326
        $this->resetAfterTest();
1386
        $this->resetAfterTest();
Línea 1327... Línea 1387...
1327
 
1387
 
1328
        $data = [
1388
        $data = [
Línea 1377... Línea 1437...
1377
    }
1437
    }
Línea 1378... Línea 1438...
1378
 
1438
 
1379
    /**
1439
    /**
1380
     * Test the badges_open_badges_backpack_api with different backpacks
1440
     * Test the badges_open_badges_backpack_api with different backpacks
1381
     */
1441
     */
1382
    public function test_badges_open_badges_backpack_api() {
1442
    public function test_badges_open_badges_backpack_api(): void {
Línea 1383... Línea 1443...
1383
        $this->resetAfterTest();
1443
        $this->resetAfterTest();
1384
 
1444
 
1385
        $data = [
1445
        $data = [
Línea 1410... Línea 1470...
1410
    }
1470
    }
Línea 1411... Línea 1471...
1411
 
1471
 
1412
    /**
1472
    /**
1413
     * Test the badges_get_site_backpack function
1473
     * Test the badges_get_site_backpack function
1414
     */
1474
     */
1415
    public function test_badges_get_site_backpack() {
1475
    public function test_badges_get_site_backpack(): void {
1416
        $this->resetAfterTest();
1476
        $this->resetAfterTest();
1417
        $user = $this->getDataGenerator()->create_user();
1477
        $user = $this->getDataGenerator()->create_user();
1418
        $data = [
1478
        $data = [
1419
            'apiversion' => '2',
1479
            'apiversion' => '2',
Línea 1451... Línea 1511...
1451
    }
1511
    }
Línea 1452... Línea 1512...
1452
 
1512
 
1453
    /**
1513
    /**
1454
     * Test the badges_get_user_backpack function
1514
     * Test the badges_get_user_backpack function
1455
     */
1515
     */
1456
    public function test_badges_get_user_backpack() {
1516
    public function test_badges_get_user_backpack(): void {
1457
        $this->resetAfterTest();
1517
        $this->resetAfterTest();
1458
        $user = $this->getDataGenerator()->create_user();
1518
        $user = $this->getDataGenerator()->create_user();
1459
        $data = [
1519
        $data = [
1460
            'apiversion' => '2',
1520
            'apiversion' => '2',
Línea 1495... Línea 1555...
1495
     * Test the badges_get_site_primary_backpack function
1555
     * Test the badges_get_site_primary_backpack function
1496
     *
1556
     *
1497
     * @param boolean $withauth Testing with authentication or not.
1557
     * @param boolean $withauth Testing with authentication or not.
1498
     * @dataProvider badges_get_site_primary_backpack_provider
1558
     * @dataProvider badges_get_site_primary_backpack_provider
1499
     */
1559
     */
1500
    public function test_badges_get_site_primary_backpack($withauth) {
1560
    public function test_badges_get_site_primary_backpack($withauth): void {
1501
        $data = [
1561
        $data = [
1502
            'apiversion' => '2',
1562
            'apiversion' => '2',
1503
            'backpackapiurl' => 'https://api.ca.badgr.io/v2',
1563
            'backpackapiurl' => 'https://api.ca.badgr.io/v2',
1504
            'backpackweburl' => 'https://ca.badgr.io',
1564
            'backpackweburl' => 'https://ca.badgr.io',
1505
            'sortorder' => '2',
1565
            'sortorder' => '2',
Línea 1628... Línea 1688...
1628
     *
1688
     *
1629
     * @param mixed $type Type corresponding to the badge entites
1689
     * @param mixed $type Type corresponding to the badge entites
1630
     * @param string $expected Expected string result
1690
     * @param string $expected Expected string result
1631
     * @dataProvider badgr_open_url_generator
1691
     * @dataProvider badgr_open_url_generator
1632
     */
1692
     */
1633
    public function test_badges_generate_badgr_open_url($type, $expected) {
1693
    public function test_badges_generate_badgr_open_url($type, $expected): void {
1634
        $data = [
1694
        $data = [
1635
            'apiversion' => '2',
1695
            'apiversion' => '2',
1636
            'backpackapiurl' => 'https://api.ca.badgr.io/v2',
1696
            'backpackapiurl' => 'https://api.ca.badgr.io/v2',
1637
            'backpackweburl' => 'https://ca.badgr.io',
1697
            'backpackweburl' => 'https://ca.badgr.io',
1638
            'backpackemail' => 'test@test.com',
1698
            'backpackemail' => 'test@test.com',
Línea 1669... Línea 1729...
1669
     * @param mixed $expected The expected result from the function
1729
     * @param mixed $expected The expected result from the function
1670
     * @param string|null $field The field we are passing to the function. Null if we don't want to pass anything.ss
1730
     * @param string|null $field The field we are passing to the function. Null if we don't want to pass anything.ss
1671
     *
1731
     *
1672
     * @dataProvider badges_external_get_mapping_provider
1732
     * @dataProvider badges_external_get_mapping_provider
1673
     */
1733
     */
1674
    public function test_badges_external_get_mapping($internalid, $externalid, $expected, $field = null) {
1734
    public function test_badges_external_get_mapping($internalid, $externalid, $expected, $field = null): void {
1675
        $data = [
1735
        $data = [
1676
            'apiversion' => '2',
1736
            'apiversion' => '2',
1677
            'backpackapiurl' => 'https://api.ca.badgr.io/v2',
1737
            'backpackapiurl' => 'https://api.ca.badgr.io/v2',
1678
            'backpackweburl' => 'https://ca.badgr.io',
1738
            'backpackweburl' => 'https://ca.badgr.io',
1679
            'backpackemail' => 'test@test.com',
1739
            'backpackemail' => 'test@test.com',
Línea 1730... Línea 1790...
1730
    /**
1790
    /**
1731
     * Testing function test_badge_get_tagged_badges - search tagged badges
1791
     * Testing function test_badge_get_tagged_badges - search tagged badges
1732
     *
1792
     *
1733
     * @covers ::badge_get_tagged_badges
1793
     * @covers ::badge_get_tagged_badges
1734
     */
1794
     */
1735
    public function test_badge_get_tagged_badges() {
1795
    public function test_badge_get_tagged_badges(): void {
1736
        $this->resetAfterTest();
1796
        $this->resetAfterTest();
1737
        $this->setAdminUser();
1797
        $this->setAdminUser();
Línea 1738... Línea 1798...
1738
 
1798
 
1739
        // Setup test data.
1799
        // Setup test data.