Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 95... Línea 95...
95
    }
95
    }
Línea 96... Línea 96...
96
 
96
 
97
    /**
97
    /**
98
     * Test get_comments
98
     * Test get_comments
99
     */
99
     */
100
    public function test_get_comments() {
100
    public function test_get_comments(): void {
101
        global $CFG;
101
        global $CFG;
Línea 102... Línea 102...
102
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
102
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
103
 
103
 
Línea 170... Línea 170...
170
    }
170
    }
Línea 171... Línea 171...
171
 
171
 
172
    /**
172
    /**
173
     * Test add_comments not enabled site level
173
     * Test add_comments not enabled site level
174
     */
174
     */
175
    public function test_add_comments_not_enabled_site_level() {
175
    public function test_add_comments_not_enabled_site_level(): void {
176
        global $CFG;
176
        global $CFG;
Línea 177... Línea 177...
177
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
177
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
178
 
178
 
Línea 194... Línea 194...
194
    }
194
    }
Línea 195... Línea 195...
195
 
195
 
196
    /**
196
    /**
197
     * Test add_comments not enabled module level
197
     * Test add_comments not enabled module level
198
     */
198
     */
199
    public function test_add_comments_not_enabled_module_level() {
199
    public function test_add_comments_not_enabled_module_level(): void {
200
        global $DB;
200
        global $DB;
Línea 201... Línea 201...
201
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
201
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
202
 
202
 
Línea 219... Línea 219...
219
    }
219
    }
Línea 220... Línea 220...
220
 
220
 
221
    /**
221
    /**
222
     * Test add_comments
222
     * Test add_comments
223
     */
223
     */
224
    public function test_add_comments_single() {
224
    public function test_add_comments_single(): void {
Línea 225... Línea 225...
225
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
225
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
226
 
226
 
227
        // Add a comment as student 1.
227
        // Add a comment as student 1.
Línea 262... Línea 262...
262
    /**
262
    /**
263
     * Test add_comments when one of the comments contains invalid data and cannot be created.
263
     * Test add_comments when one of the comments contains invalid data and cannot be created.
264
     *
264
     *
265
     * This simply verifies that the entire operation fails.
265
     * This simply verifies that the entire operation fails.
266
     */
266
     */
267
    public function test_add_comments_multiple_contains_invalid() {
267
    public function test_add_comments_multiple_contains_invalid(): void {
268
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
268
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
Línea 269... Línea 269...
269
 
269
 
270
        // Try to create some comments as student 1, but provide a bad area for the second comment.
270
        // Try to create some comments as student 1, but provide a bad area for the second comment.
271
        $this->setUser($student1);
271
        $this->setUser($student1);
Línea 293... Línea 293...
293
    /**
293
    /**
294
     * Test add_comments when one of the comments contains invalid data and cannot be created.
294
     * Test add_comments when one of the comments contains invalid data and cannot be created.
295
     *
295
     *
296
     * This simply verifies that the entire operation fails.
296
     * This simply verifies that the entire operation fails.
297
     */
297
     */
298
    public function test_add_comments_multiple_all_valid() {
298
    public function test_add_comments_multiple_all_valid(): void {
299
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
299
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
Línea 300... Línea 300...
300
 
300
 
301
        // Try to create some comments as student 1.
301
        // Try to create some comments as student 1.
302
        $this->setUser($student1);
302
        $this->setUser($student1);
Línea 333... Línea 333...
333
    }
333
    }
Línea 334... Línea 334...
334
 
334
 
335
    /**
335
    /**
336
     * Test add_comments invalid area
336
     * Test add_comments invalid area
337
     */
337
     */
338
    public function test_add_comments_invalid_area() {
338
    public function test_add_comments_invalid_area(): void {
Línea 339... Línea 339...
339
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
339
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
340
 
340
 
341
        // Try to create a comment with an invalid area, verifying failure.
341
        // Try to create a comment with an invalid area, verifying failure.
Línea 355... Línea 355...
355
    }
355
    }
Línea 356... Línea 356...
356
 
356
 
357
    /**
357
    /**
358
     * Test delete_comment invalid comment.
358
     * Test delete_comment invalid comment.
359
     */
359
     */
360
    public function test_delete_comments_invalid_comment_id() {
360
    public function test_delete_comments_invalid_comment_id(): void {
361
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
361
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
Línea 362... Línea 362...
362
        $this->setUser($student1);
362
        $this->setUser($student1);
363
 
363
 
364
        $this->expectException(comment_exception::class);
364
        $this->expectException(comment_exception::class);
Línea 365... Línea 365...
365
        core_comment_external::delete_comments([-1, 0]);
365
        core_comment_external::delete_comments([-1, 0]);
366
    }
366
    }
367
 
367
 
368
    /**
368
    /**
369
     * Test delete_comment own user.
369
     * Test delete_comment own user.
Línea 370... Línea 370...
370
     */
370
     */
371
    public function test_delete_comments_own_user() {
371
    public function test_delete_comments_own_user(): void {
372
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
372
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
Línea 403... Línea 403...
403
    }
403
    }
Línea 404... Línea 404...
404
 
404
 
405
    /**
405
    /**
406
     * Test delete_comment other student.
406
     * Test delete_comment other student.
407
     */
407
     */
408
    public function test_delete_comment_other_student() {
408
    public function test_delete_comment_other_student(): void {
Línea 409... Línea 409...
409
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
409
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
410
 
410
 
411
        // Create a comment as the student.
411
        // Create a comment as the student.
Línea 429... Línea 429...
429
    }
429
    }
Línea 430... Línea 430...
430
 
430
 
431
    /**
431
    /**
432
     * Test delete_comment as teacher.
432
     * Test delete_comment as teacher.
433
     */
433
     */
434
    public function test_delete_comments_as_teacher() {
434
    public function test_delete_comments_as_teacher(): void {
Línea 435... Línea 435...
435
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
435
        [$module1, $recordid, $teacher1, $student1, $student2] = $this->setup_course_and_users_basic();
436
 
436
 
437
        // Create a comment as the student.
437
        // Create a comment as the student.