Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 34... Línea 34...
34
class events_test extends badgeslib_test {
34
class events_test extends badgeslib_test {
Línea 35... Línea 35...
35
 
35
 
36
    /**
36
    /**
37
     * Test badge awarded event.
37
     * Test badge awarded event.
38
     */
38
     */
Línea 39... Línea 39...
39
    public function test_badge_awarded() {
39
    public function test_badge_awarded(): void {
Línea 40... Línea 40...
40
 
40
 
Línea 60... Línea 60...
60
     * Test the badge created event.
60
     * Test the badge created event.
61
     *
61
     *
62
     * There is no external API for creating a badge, so the unit test will simply
62
     * There is no external API for creating a badge, so the unit test will simply
63
     * create and trigger the event and ensure data is returned as expected.
63
     * create and trigger the event and ensure data is returned as expected.
64
     */
64
     */
65
    public function test_badge_created() {
65
    public function test_badge_created(): void {
Línea 66... Línea 66...
66
 
66
 
67
        $badge = new badge($this->badgeid);
67
        $badge = new badge($this->badgeid);
68
        // Trigger an event: badge created.
68
        // Trigger an event: badge created.
69
        $eventparams = array(
69
        $eventparams = array(
Línea 90... Línea 90...
90
 
90
 
91
    /**
91
    /**
92
     * Test the badge archived event.
92
     * Test the badge archived event.
93
     *
93
     *
94
     */
94
     */
95
    public function test_badge_archived() {
95
    public function test_badge_archived(): void {
96
        $badge = new badge($this->badgeid);
96
        $badge = new badge($this->badgeid);
Línea 97... Línea 97...
97
        $sink = $this->redirectEvents();
97
        $sink = $this->redirectEvents();
98
 
98
 
Línea 113... Línea 113...
113
 
113
 
114
    /**
114
    /**
115
     * Test the badge updated event.
115
     * Test the badge updated event.
116
     *
116
     *
117
     */
117
     */
118
    public function test_badge_updated() {
118
    public function test_badge_updated(): void {
119
        $badge = new badge($this->badgeid);
119
        $badge = new badge($this->badgeid);
Línea 120... Línea 120...
120
        $sink = $this->redirectEvents();
120
        $sink = $this->redirectEvents();
121
 
121
 
Línea 133... Línea 133...
133
 
133
 
134
    }
134
    }
135
    /**
135
    /**
136
     * Test the badge deleted event.
136
     * Test the badge deleted event.
137
     */
137
     */
138
    public function test_badge_deleted() {
138
    public function test_badge_deleted(): void {
139
        $badge = new badge($this->badgeid);
139
        $badge = new badge($this->badgeid);
Línea 140... Línea 140...
140
        $sink = $this->redirectEvents();
140
        $sink = $this->redirectEvents();
141
 
141
 
Línea 155... Línea 155...
155
 
155
 
156
    /**
156
    /**
157
     * Test the badge duplicated event.
157
     * Test the badge duplicated event.
158
     *
158
     *
159
     */
159
     */
160
    public function test_badge_duplicated() {
160
    public function test_badge_duplicated(): void {
161
        $badge = new badge($this->badgeid);
161
        $badge = new badge($this->badgeid);
Línea 162... Línea 162...
162
        $sink = $this->redirectEvents();
162
        $sink = $this->redirectEvents();
163
 
163
 
Línea 177... Línea 177...
177
 
177
 
178
    /**
178
    /**
179
     * Test the badge disabled event.
179
     * Test the badge disabled event.
180
     *
180
     *
181
     */
181
     */
182
    public function test_badge_disabled() {
182
    public function test_badge_disabled(): void {
183
        $badge = new badge($this->badgeid);
183
        $badge = new badge($this->badgeid);
Línea 184... Línea 184...
184
        $sink = $this->redirectEvents();
184
        $sink = $this->redirectEvents();
185
 
185
 
Línea 200... Línea 200...
200
 
200
 
201
    /**
201
    /**
202
     * Test the badge enabled event.
202
     * Test the badge enabled event.
203
     *
203
     *
204
     */
204
     */
205
    public function test_badge_enabled() {
205
    public function test_badge_enabled(): void {
206
        $badge = new badge($this->badgeid);
206
        $badge = new badge($this->badgeid);
Línea 207... Línea 207...
207
        $sink = $this->redirectEvents();
207
        $sink = $this->redirectEvents();
208
 
208
 
Línea 225... Línea 225...
225
     * Test the badge criteria created event.
225
     * Test the badge criteria created event.
226
     *
226
     *
227
     * There is no external API for this, so the unit test will simply
227
     * There is no external API for this, so the unit test will simply
228
     * create and trigger the event and ensure data is returned as expected.
228
     * create and trigger the event and ensure data is returned as expected.
229
     */
229
     */
230
    public function test_badge_criteria_created() {
230
    public function test_badge_criteria_created(): void {
Línea 231... Línea 231...
231
 
231
 
Línea 232... Línea 232...
232
        $badge = new badge($this->badgeid);
232
        $badge = new badge($this->badgeid);
233
 
233
 
Línea 255... Línea 255...
255
     * Test the badge criteria updated event.
255
     * Test the badge criteria updated event.
256
     *
256
     *
257
     * There is no external API for this, so the unit test will simply
257
     * There is no external API for this, so the unit test will simply
258
     * create and trigger the event and ensure data is returned as expected.
258
     * create and trigger the event and ensure data is returned as expected.
259
     */
259
     */
260
    public function test_badge_criteria_updated() {
260
    public function test_badge_criteria_updated(): void {
Línea 261... Línea 261...
261
 
261
 
262
        $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid));
262
        $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid));
263
        $criteriaoverall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL));
263
        $criteriaoverall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL));
264
        $criteriaprofile = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_PROFILE, 'badgeid' => $this->badgeid));
264
        $criteriaprofile = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_PROFILE, 'badgeid' => $this->badgeid));
Línea 288... Línea 288...
288
     * Test the badge criteria deleted event.
288
     * Test the badge criteria deleted event.
289
     *
289
     *
290
     * There is no external API for this, so the unit test will simply
290
     * There is no external API for this, so the unit test will simply
291
     * create and trigger the event and ensure data is returned as expected.
291
     * create and trigger the event and ensure data is returned as expected.
292
     */
292
     */
293
    public function test_badge_criteria_deleted() {
293
    public function test_badge_criteria_deleted(): void {
Línea 294... Línea 294...
294
 
294
 
295
        $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid));
295
        $criteriaoverall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $this->badgeid));
296
        $criteriaoverall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL));
296
        $criteriaoverall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL));
Línea 315... Línea 315...
315
     * Test the badge viewed event.
315
     * Test the badge viewed event.
316
     *
316
     *
317
     * There is no external API for viewing a badge, so the unit test will simply
317
     * There is no external API for viewing a badge, so the unit test will simply
318
     * create and trigger the event and ensure data is returned as expected.
318
     * create and trigger the event and ensure data is returned as expected.
319
     */
319
     */
320
    public function test_badge_viewed() {
320
    public function test_badge_viewed(): void {
Línea 321... Línea 321...
321
 
321
 
322
        $badge = new badge($this->badgeid);
322
        $badge = new badge($this->badgeid);
323
        // Trigger an event: badge viewed.
323
        // Trigger an event: badge viewed.
324
        $other = array('badgeid' => $badge->id, 'badgehash' => '12345678');
324
        $other = array('badgeid' => $badge->id, 'badgehash' => '12345678');
Línea 347... Línea 347...
347
     * Test the badge listing viewed event.
347
     * Test the badge listing viewed event.
348
     *
348
     *
349
     * There is no external API for viewing a badge, so the unit test will simply
349
     * There is no external API for viewing a badge, so the unit test will simply
350
     * create and trigger the event and ensure data is returned as expected.
350
     * create and trigger the event and ensure data is returned as expected.
351
     */
351
     */
352
    public function test_badge_listing_viewed() {
352
    public function test_badge_listing_viewed(): void {
Línea 353... Línea 353...
353
 
353
 
354
        // Trigger an event: badge listing viewed.
354
        // Trigger an event: badge listing viewed.
355
        $context = context_system::instance();
355
        $context = context_system::instance();
356
        $eventparams = array(
356
        $eventparams = array(