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 coursecat_test extends \advanced_testcase {
31
class coursecat_test extends \advanced_testcase {
32
    /**
32
    /**
33
     * Tests legacy class name.
33
     * Tests legacy class name.
34
     * @coversNothing
34
     * @coversNothing
35
     */
35
     */
36
    public function test_legacy_classname() {
36
    public function test_legacy_classname(): void {
37
        $category = \core_course_category::get_default();
37
        $category = \core_course_category::get_default();
38
        $context = \context_coursecat::instance($category->id);
38
        $context = \context_coursecat::instance($category->id);
39
        $this->assertInstanceOf(coursecat::class, $context);
39
        $this->assertInstanceOf(coursecat::class, $context);
40
        $this->assertInstanceOf(\context_coursecat::class, $context);
40
        $this->assertInstanceOf(\context_coursecat::class, $context);
41
    }
41
    }
Línea 43... Línea 43...
43
    /**
43
    /**
44
     * Tests covered methods.
44
     * Tests covered methods.
45
     * @covers ::instance
45
     * @covers ::instance
46
     * @covers \core\context::instance_by_id
46
     * @covers \core\context::instance_by_id
47
     */
47
     */
48
    public function test_factory_methods() {
48
    public function test_factory_methods(): void {
49
        $category = \core_course_category::get_default();
49
        $category = \core_course_category::get_default();
50
        $context = coursecat::instance($category->id);
50
        $context = coursecat::instance($category->id);
51
        $this->assertInstanceOf(coursecat::class, $context);
51
        $this->assertInstanceOf(coursecat::class, $context);
52
        $this->assertSame($category->id, $context->instanceid);
52
        $this->assertSame($category->id, $context->instanceid);
Línea 58... Línea 58...
58
 
58
 
59
    /**
59
    /**
60
     * Tests covered method.
60
     * Tests covered method.
61
     * @covers ::get_short_name
61
     * @covers ::get_short_name
62
     */
62
     */
63
    public function test_get_short_name() {
63
    public function test_get_short_name(): void {
64
        $this->assertSame('coursecat', coursecat::get_short_name());
64
        $this->assertSame('coursecat', coursecat::get_short_name());
Línea 65... Línea 65...
65
    }
65
    }
66
 
66
 
67
    /**
67
    /**
68
     * Tests levels.
68
     * Tests levels.
69
     * @coversNothing
69
     * @coversNothing
70
     */
70
     */
71
    public function test_level() {
71
    public function test_level(): void {
72
        $this->assertSame(40, coursecat::LEVEL);
72
        $this->assertSame(40, coursecat::LEVEL);
Línea 73... Línea 73...
73
        $this->assertSame(CONTEXT_COURSECAT, coursecat::LEVEL);
73
        $this->assertSame(CONTEXT_COURSECAT, coursecat::LEVEL);
74
    }
74
    }
75
 
75
 
76
    /**
76
    /**
77
     * Tests covered method.
77
     * Tests covered method.
78
     * @covers ::get_level_name
78
     * @covers ::get_level_name
79
     */
79
     */
Línea 80... Línea 80...
80
    public function test_get_level_name() {
80
    public function test_get_level_name(): void {
81
        $this->assertSame('Category', coursecat::get_level_name());
81
        $this->assertSame('Category', coursecat::get_level_name());
82
    }
82
    }
83
 
83
 
84
    /**
84
    /**
85
     * Tests covered method.
85
     * Tests covered method.
86
     * @covers ::get_context_name
86
     * @covers ::get_context_name
87
     */
87
     */
88
    public function test_get_context_name() {
88
    public function test_get_context_name(): void {
89
        $category = \core_course_category::get_default();
89
        $category = \core_course_category::get_default();
Línea 97... Línea 97...
97
 
97
 
98
    /**
98
    /**
99
     * Tests covered method.
99
     * Tests covered method.
100
     * @covers ::get_url
100
     * @covers ::get_url
101
     */
101
     */
102
    public function test_get_url() {
102
    public function test_get_url(): void {
103
        $category = \core_course_category::get_default();
103
        $category = \core_course_category::get_default();
104
        $context = coursecat::instance($category->id);
104
        $context = coursecat::instance($category->id);
105
        $expected = new \moodle_url('/course/index.php', ['categoryid' => $category->id]);
105
        $expected = new \moodle_url('/course/index.php', ['categoryid' => $category->id]);
106
        $url = $context->get_url();
106
        $url = $context->get_url();
Línea 112... Línea 112...
112
     * Tests covered methods.
112
     * Tests covered methods.
113
     * @covers ::get_instance_table()
113
     * @covers ::get_instance_table()
114
     * @covers ::get_behat_reference_columns()
114
     * @covers ::get_behat_reference_columns()
115
     * @covers \core\context_helper::resolve_behat_reference
115
     * @covers \core\context_helper::resolve_behat_reference
116
     */
116
     */
117
    public function test_resolve_behat_reference() {
117
    public function test_resolve_behat_reference(): void {
118
        $this->resetAfterTest();
118
        $this->resetAfterTest();
Línea 119... Línea 119...
119
 
119
 
120
        $instance = $this->getDataGenerator()->create_category(['idnumber' => 'xyz']);
120
        $instance = $this->getDataGenerator()->create_category(['idnumber' => 'xyz']);
Línea 138... Línea 138...
138
 
138
 
139
    /**
139
    /**
140
     * Tests covered method.
140
     * Tests covered method.
141
     * @covers ::get_compatible_role_archetypes
141
     * @covers ::get_compatible_role_archetypes
142
     */
142
     */
143
    public function test_get_compatible_role_archetypes() {
143
    public function test_get_compatible_role_archetypes(): void {
Línea 144... Línea 144...
144
        global $DB;
144
        global $DB;
145
 
145
 
146
        $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL');
146
        $allarchetypes = $DB->get_fieldset_select('role', 'DISTINCT archetype', 'archetype IS NOT NULL');
Línea 156... Línea 156...
156
 
156
 
157
    /**
157
    /**
158
     * Tests covered method.
158
     * Tests covered method.
159
     * @covers ::get_possible_parent_levels
159
     * @covers ::get_possible_parent_levels
160
     */
160
     */
161
    public function test_get_possible_parent_levels() {
161
    public function test_get_possible_parent_levels(): void {
162
        $this->assertSame([system::LEVEL, coursecat::LEVEL], coursecat::get_possible_parent_levels());
162
        $this->assertSame([system::LEVEL, coursecat::LEVEL], coursecat::get_possible_parent_levels());
Línea 163... Línea 163...
163
    }
163
    }
164
 
164
 
165
    /**
165
    /**
166
     * Tests covered method.
166
     * Tests covered method.
167
     * @covers ::get_capabilities
167
     * @covers ::get_capabilities
168
     */
168
     */
Línea 169... Línea 169...
169
    public function test_get_capabilities() {
169
    public function test_get_capabilities(): void {
170
        $category = \core_course_category::get_default();
170
        $category = \core_course_category::get_default();
171
 
171
 
Línea 180... Línea 180...
180
 
180
 
181
    /**
181
    /**
182
     * Tests covered method.
182
     * Tests covered method.
183
     * @covers ::create_level_instances
183
     * @covers ::create_level_instances
184
     */
184
     */
185
    public function test_create_level_instances() {
185
    public function test_create_level_instances(): void {
186
        global $DB;
186
        global $DB;
Línea 187... Línea 187...
187
        $this->resetAfterTest();
187
        $this->resetAfterTest();
188
 
188
 
Línea 196... Línea 196...
196
 
196
 
197
    /**
197
    /**
198
     * Tests covered method.
198
     * Tests covered method.
199
     * @covers ::get_child_contexts
199
     * @covers ::get_child_contexts
200
     */
200
     */
201
    public function test_get_child_contexts() {
201
    public function test_get_child_contexts(): void {
Línea 202... Línea 202...
202
        $this->resetAfterTest();
202
        $this->resetAfterTest();
Línea 203... Línea 203...
203
 
203
 
Línea 216... Línea 216...
216
 
216
 
217
    /**
217
    /**
218
     * Tests covered method.
218
     * Tests covered method.
219
     * @covers ::get_cleanup_sql
219
     * @covers ::get_cleanup_sql
220
     */
220
     */
221
    public function test_get_cleanup_sql() {
221
    public function test_get_cleanup_sql(): void {
222
        global $DB;
222
        global $DB;
Línea 223... Línea 223...
223
        $this->resetAfterTest();
223
        $this->resetAfterTest();
224
 
224
 
Línea 233... Línea 233...
233
 
233
 
234
    /**
234
    /**
235
     * Tests covered method.
235
     * Tests covered method.
236
     * @covers ::build_paths
236
     * @covers ::build_paths
237
     */
237
     */
238
    public function test_build_paths() {
238
    public function test_build_paths(): void {
239
        global $DB;
239
        global $DB;
Línea 240... Línea 240...
240
        $this->resetAfterTest();
240
        $this->resetAfterTest();
241
 
241
 
Línea 255... Línea 255...
255
 
255
 
256
    /**
256
    /**
257
     * Tests covered method.
257
     * Tests covered method.
258
     * @covers ::set_locked
258
     * @covers ::set_locked
259
     */
259
     */
260
    public function test_set_locked() {
260
    public function test_set_locked(): void {
261
        global $DB;
261
        global $DB;
Línea 262... Línea 262...
262
        $this->resetAfterTest();
262
        $this->resetAfterTest();
263
 
263