Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 31... Línea 31...
31
class course_test extends \advanced_testcase {
31
class course_test extends \advanced_testcase {
32
    /**
32
    /**
33
     * Tests legacy class.
33
     * Tests legacy class.
34
     * @coversNothing
34
     * @coversNothing
35
     */
35
     */
36
    public function test_legacy_classname() {
36
    public function test_legacy_classname(): void {
37
        global $SITE;
37
        global $SITE;
38
        $course = $SITE;
38
        $course = $SITE;
39
        $context = \context_course::instance($course->id);
39
        $context = \context_course::instance($course->id);
40
        $this->assertInstanceOf(course::class, $context);
40
        $this->assertInstanceOf(course::class, $context);
41
        $this->assertInstanceOf(\context_course::class, $context);
41
        $this->assertInstanceOf(\context_course::class, $context);
Línea 44... Línea 44...
44
    /**
44
    /**
45
     * Tests covered methods.
45
     * Tests covered methods.
46
     * @covers ::instance
46
     * @covers ::instance
47
     * @covers \core\context::instance_by_id
47
     * @covers \core\context::instance_by_id
48
     */
48
     */
49
    public function test_factory_methods() {
49
    public function test_factory_methods(): void {
50
        global $SITE;
50
        global $SITE;
51
        $course = $SITE;
51
        $course = $SITE;
52
        $context = course::instance($course->id);
52
        $context = course::instance($course->id);
53
        $this->assertInstanceOf(course::class, $context);
53
        $this->assertInstanceOf(course::class, $context);
54
        $this->assertSame($course->id, $context->instanceid);
54
        $this->assertSame($course->id, $context->instanceid);
Línea 60... Línea 60...
60
 
60
 
61
    /**
61
    /**
62
     * Tests covered method.
62
     * Tests covered method.
63
     * @covers ::get_short_name
63
     * @covers ::get_short_name
64
     */
64
     */
65
    public function test_get_short_name() {
65
    public function test_get_short_name(): void {
66
        $this->assertSame('course', course::get_short_name());
66
        $this->assertSame('course', course::get_short_name());
Línea 67... Línea 67...
67
    }
67
    }
68
 
68
 
69
    /**
69
    /**
70
     * Tests levels.
70
     * Tests levels.
71
     * @coversNothing
71
     * @coversNothing
72
     */
72
     */
73
    public function test_level() {
73
    public function test_level(): void {
74
        $this->assertSame(50, course::LEVEL);
74
        $this->assertSame(50, course::LEVEL);
Línea 75... Línea 75...
75
        $this->assertSame(CONTEXT_COURSE, course::LEVEL);
75
        $this->assertSame(CONTEXT_COURSE, course::LEVEL);
76
    }
76
    }
77
 
77
 
78
    /**
78
    /**
79
     * Tests covered method.
79
     * Tests covered method.
80
     * @covers ::get_level_name
80
     * @covers ::get_level_name
81
     */
81
     */
Línea 82... Línea 82...
82
    public function test_get_level_name() {
82
    public function test_get_level_name(): void {
83
        $this->assertSame('Course', course::get_level_name());
83
        $this->assertSame('Course', course::get_level_name());
84
    }
84
    }
85
 
85
 
86
    /**
86
    /**
87
     * Tests covered method.
87
     * Tests covered method.
Línea 88... Línea 88...
88
     * @covers ::get_context_name
88
     * @covers ::get_context_name
89
     */
89
     */
Línea 102... Línea 102...
102
 
102
 
103
    /**
103
    /**
104
     * Tests covered method.
104
     * Tests covered method.
105
     * @covers ::get_url
105
     * @covers ::get_url
106
     */
106
     */
107
    public function test_get_url() {
107
    public function test_get_url(): void {
Línea 108... Línea 108...
108
        $this->resetAfterTest();
108
        $this->resetAfterTest();
109
 
109
 
Línea 120... Línea 120...
120
     * Tests covered methods.
120
     * Tests covered methods.
121
     * @covers ::get_instance_table()
121
     * @covers ::get_instance_table()
122
     * @covers ::get_behat_reference_columns()
122
     * @covers ::get_behat_reference_columns()
123
     * @covers \core\context_helper::resolve_behat_reference
123
     * @covers \core\context_helper::resolve_behat_reference
124
     */
124
     */
125
    public function test_resolve_behat_reference() {
125
    public function test_resolve_behat_reference(): void {
126
        $this->resetAfterTest();
126
        $this->resetAfterTest();
Línea 127... Línea 127...
127
 
127
 
128
        $instance = $this->getDataGenerator()->create_course(['shortname' => 'xyz']);
128
        $instance = $this->getDataGenerator()->create_course(['shortname' => 'xyz']);
Línea 146... Línea 146...
146
 
146
 
147
    /**
147
    /**
148
     * Tests covered method.
148
     * Tests covered method.
149
     * @covers ::get_compatible_role_archetypes
149
     * @covers ::get_compatible_role_archetypes
150
     */
150
     */
151
    public function test_get_compatible_role_archetypes() {
151
    public function test_get_compatible_role_archetypes(): void {
Línea 152... Línea 152...
152
        global $DB;
152
        global $DB;
153
 
153
 
154
        $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL');
154
        $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL');
Línea 165... Línea 165...
165
 
165
 
166
    /**
166
    /**
167
     * Tests covered method.
167
     * Tests covered method.
168
     * @covers ::get_possible_parent_levels
168
     * @covers ::get_possible_parent_levels
169
     */
169
     */
170
    public function test_get_possible_parent_levels() {
170
    public function test_get_possible_parent_levels(): void {
171
        $this->assertSame([coursecat::LEVEL], course::get_possible_parent_levels());
171
        $this->assertSame([coursecat::LEVEL], course::get_possible_parent_levels());
Línea 172... Línea 172...
172
    }
172
    }
173
 
173
 
174
    /**
174
    /**
175
     * Tests covered method.
175
     * Tests covered method.
176
     * @covers ::get_capabilities
176
     * @covers ::get_capabilities
177
     */
177
     */
Línea 178... Línea 178...
178
    public function test_get_capabilities() {
178
    public function test_get_capabilities(): void {
179
        $this->resetAfterTest();
179
        $this->resetAfterTest();
Línea 193... Línea 193...
193
 
193
 
194
    /**
194
    /**
195
     * Tests covered method.
195
     * Tests covered method.
196
     * @covers ::create_level_instances
196
     * @covers ::create_level_instances
197
     */
197
     */
198
    public function test_create_level_instances() {
198
    public function test_create_level_instances(): void {
199
        global $DB;
199
        global $DB;
Línea 200... Línea 200...
200
        $this->resetAfterTest();
200
        $this->resetAfterTest();
201
 
201
 
Línea 209... Línea 209...
209
 
209
 
210
    /**
210
    /**
211
     * Tests covered method.
211
     * Tests covered method.
212
     * @covers ::get_child_contexts
212
     * @covers ::get_child_contexts
213
     */
213
     */
214
    public function test_get_child_contexts() {
214
    public function test_get_child_contexts(): void {
Línea 215... Línea 215...
215
        $this->resetAfterTest();
215
        $this->resetAfterTest();
216
 
216
 
Línea 227... Línea 227...
227
 
227
 
228
    /**
228
    /**
229
     * Tests covered method.
229
     * Tests covered method.
230
     * @covers ::get_cleanup_sql
230
     * @covers ::get_cleanup_sql
231
     */
231
     */
232
    public function test_get_cleanup_sql() {
232
    public function test_get_cleanup_sql(): void {
233
        global $DB;
233
        global $DB;
Línea 234... Línea 234...
234
        $this->resetAfterTest();
234
        $this->resetAfterTest();
235
 
235
 
Línea 244... Línea 244...
244
 
244
 
245
    /**
245
    /**
246
     * Tests covered method.
246
     * Tests covered method.
247
     * @covers ::build_paths
247
     * @covers ::build_paths
248
     */
248
     */
249
    public function test_build_paths() {
249
    public function test_build_paths(): void {
250
        global $DB;
250
        global $DB;
Línea 251... Línea 251...
251
        $this->resetAfterTest();
251
        $this->resetAfterTest();
252
 
252
 
Línea 267... Línea 267...
267
 
267
 
268
    /**
268
    /**
269
     * Tests covered method.
269
     * Tests covered method.
270
     * @covers ::set_locked
270
     * @covers ::set_locked
271
     */
271
     */
272
    public function test_set_locked() {
272
    public function test_set_locked(): void {
273
        global $DB;
273
        global $DB;
Línea 274... Línea 274...
274
        $this->resetAfterTest();
274
        $this->resetAfterTest();
275
 
275