Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace mod_assign;
18
 
19
/**
20
 * Test for mod assign generator.
21
 * @package mod_assign
22
 * @copyright Frederik Pytlick <fmp@moxis.dk>
23
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @covers \mod_assign_generator
25
 */
26
final class generator_test extends \advanced_testcase {
27
    /**
28
     * Test creating an assignment instance using the mod_assign generator.
29
     */
30
    public function test_create_instance(): void {
31
        $this->resetAfterTest();
32
 
33
        $datagenerator = self::getDataGenerator();
34
        $course = $datagenerator->create_course();
35
 
36
        $scale = $datagenerator->create_scale();
37
 
38
        $generator = $datagenerator->get_plugin_generator('mod_assign');
39
        $instance1 = $generator->create_instance([
40
            'course' => $course,
41
            'name' => 'Assign 1',
42
            'gradetype' => GRADE_TYPE_SCALE,
43
            'gradescale' => $scale->id,
44
        ]);
45
        $instance2 = $generator->create_instance([
46
            'course' => $course,
47
            'name' => 'Assign 2',
48
            'gradetype' => GRADE_TYPE_NONE,
49
        ]);
50
        $instance3 = $generator->create_instance([
51
            'course' => $course,
52
            'name' => 'Assign 3',
53
            'gradetype' => GRADE_TYPE_VALUE,
54
        ]);
55
 
56
        $this->assertEquals(-$scale->id, $instance1->grade);
57
        $this->assertEquals(0, $instance2->grade);
58
        $this->assertEquals(100, $instance3->grade);
59
    }
60
}