Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 29... Línea 29...
29
class context_helper_test extends \advanced_testcase {
29
class context_helper_test extends \advanced_testcase {
30
    /**
30
    /**
31
     * Tests covered method.
31
     * Tests covered method.
32
     * @covers ::parse_external_level
32
     * @covers ::parse_external_level
33
     */
33
     */
34
    public function test_parse_external_level() {
34
    public function test_parse_external_level(): void {
35
        $this->assertSame(context\system::class, context_helper::parse_external_level('system'));
35
        $this->assertSame(context\system::class, context_helper::parse_external_level('system'));
36
        $this->assertSame(context\system::class, context_helper::parse_external_level(CONTEXT_SYSTEM));
36
        $this->assertSame(context\system::class, context_helper::parse_external_level(CONTEXT_SYSTEM));
37
        $this->assertSame(context\system::class, context_helper::parse_external_level((string)CONTEXT_SYSTEM));
37
        $this->assertSame(context\system::class, context_helper::parse_external_level((string)CONTEXT_SYSTEM));
Línea 38... Línea 38...
38
 
38
 
Línea 64... Línea 64...
64
 
64
 
65
    /**
65
    /**
66
     * Tests covered method.
66
     * Tests covered method.
67
     * @covers ::resolve_behat_reference
67
     * @covers ::resolve_behat_reference
68
     */
68
     */
69
    public function test_resolve_behat_reference() {
69
    public function test_resolve_behat_reference(): void {
70
        $this->assertNull(context_helper::resolve_behat_reference('blahbla', 'blahbla'));
70
        $this->assertNull(context_helper::resolve_behat_reference('blahbla', 'blahbla'));
71
        $this->assertNull(context_helper::resolve_behat_reference('', ''));
71
        $this->assertNull(context_helper::resolve_behat_reference('', ''));
Línea 72... Línea 72...
72
        $this->assertNull(context_helper::resolve_behat_reference('0', ''));
72
        $this->assertNull(context_helper::resolve_behat_reference('0', ''));
Línea 84... Línea 84...
84
 
84
 
85
    /**
85
    /**
86
     * Tests covered method.
86
     * Tests covered method.
87
     * @covers ::get_class_for_level
87
     * @covers ::get_class_for_level
88
     */
88
     */
89
    public function test_get_class_for_level() {
89
    public function test_get_class_for_level(): void {
90
        $this->assertSame(context\system::class, context_helper::get_class_for_level(CONTEXT_SYSTEM));
90
        $this->assertSame(context\system::class, context_helper::get_class_for_level(CONTEXT_SYSTEM));
Línea 91... Línea 91...
91
        $this->assertSame(context\system::class, context_helper::get_class_for_level((string)CONTEXT_SYSTEM));
91
        $this->assertSame(context\system::class, context_helper::get_class_for_level((string)CONTEXT_SYSTEM));
92
 
92
 
Línea 117... Línea 117...
117
 
117
 
118
    /**
118
    /**
119
     * Tests covered method.
119
     * Tests covered method.
120
     * @covers ::get_all_levels
120
     * @covers ::get_all_levels
121
     */
121
     */
122
    public function test_get_all_levels() {
122
    public function test_get_all_levels(): void {
Línea 123... Línea 123...
123
        $levels = context_helper::get_all_levels();
123
        $levels = context_helper::get_all_levels();
124
 
124
 
Línea 158... Línea 158...
158
 
158
 
159
    /**
159
    /**
160
     * Tests covered method.
160
     * Tests covered method.
161
     * @covers ::get_child_levels
161
     * @covers ::get_child_levels
162
     */
162
     */
163
    public function test_get_child_levels() {
163
    public function test_get_child_levels(): void {
Línea 164... Línea 164...
164
        $alllevels = context_helper::get_all_levels();
164
        $alllevels = context_helper::get_all_levels();
165
 
165
 
Línea 204... Línea 204...
204
 
204
 
205
    /**
205
    /**
206
     * Tests covered method.
206
     * Tests covered method.
207
     * @covers ::get_compatible_levels
207
     * @covers ::get_compatible_levels
208
     */
208
     */
209
    public function test_get_compatible_levels() {
209
    public function test_get_compatible_levels(): void {
210
        $levels = context_helper::get_compatible_levels('manager');
210
        $levels = context_helper::get_compatible_levels('manager');
211
        $this->assertContains(CONTEXT_SYSTEM, $levels);
211
        $this->assertContains(CONTEXT_SYSTEM, $levels);
212
        $this->assertNotContains(CONTEXT_USER, $levels);
212
        $this->assertNotContains(CONTEXT_USER, $levels);
213
        $this->assertContains(CONTEXT_COURSECAT, $levels);
213
        $this->assertContains(CONTEXT_COURSECAT, $levels);
Línea 259... Línea 259...
259
 
259
 
260
    /**
260
    /**
261
     * Tests covered method.
261
     * Tests covered method.
262
     * @covers ::cleanup_instances
262
     * @covers ::cleanup_instances
263
     */
263
     */
264
    public function test_cleanup_instances() {
264
    public function test_cleanup_instances(): void {
Línea 265... Línea 265...
265
        global $DB;
265
        global $DB;
266
 
266
 
Línea 294... Línea 294...
294
 
294
 
295
    /**
295
    /**
296
     * Tests covered method.
296
     * Tests covered method.
297
     * @covers ::create_instances
297
     * @covers ::create_instances
298
     */
298
     */
299
    public function test_create_instances() {
299
    public function test_create_instances(): void {
Línea 300... Línea 300...
300
        global $DB;
300
        global $DB;
301
 
301
 
Línea 324... Línea 324...
324
 
324
 
325
    /**
325
    /**
326
     * Tests covered method.
326
     * Tests covered method.
327
     * @covers ::build_all_paths
327
     * @covers ::build_all_paths
328
     */
328
     */
329
    public function test_build_all_paths() {
329
    public function test_build_all_paths(): void {
330
        $this->resetAfterTest();
330
        $this->resetAfterTest();
Línea 331... Línea 331...
331
        $this->preventResetByRollback();
331
        $this->preventResetByRollback();
332
 
332
 
Línea 337... Línea 337...
337
 
337
 
338
    /**
338
    /**
339
     * Tests covered method.
339
     * Tests covered method.
340
     * @covers ::reset_caches
340
     * @covers ::reset_caches
341
     */
341
     */
342
    public function test_reset_caches() {
342
    public function test_reset_caches(): void {
343
        $this->resetAfterTest();
343
        $this->resetAfterTest();
Línea 344... Línea 344...
344
        $this->preventResetByRollback();
344
        $this->preventResetByRollback();
345
 
345
 
Línea 349... Línea 349...
349
 
349
 
350
    /**
350
    /**
351
     * Tests covered method.
351
     * Tests covered method.
352
     * @covers ::get_preload_record_columns
352
     * @covers ::get_preload_record_columns
353
     */
353
     */
354
    public function test_get_preload_record_columns() {
354
    public function test_get_preload_record_columns(): void {
355
        $expected = array (
355
        $expected = array (
356
            'testalias.id' => 'ctxid',
356
            'testalias.id' => 'ctxid',
357
            'testalias.path' => 'ctxpath',
357
            'testalias.path' => 'ctxpath',
358
            'testalias.depth' => 'ctxdepth',
358
            'testalias.depth' => 'ctxdepth',
Línea 366... Línea 366...
366
 
366
 
367
    /**
367
    /**
368
     * Tests covered method.
368
     * Tests covered method.
369
     * @covers ::get_preload_record_columns_sql
369
     * @covers ::get_preload_record_columns_sql
370
     */
370
     */
371
    public function test_get_preload_record_columns_sql() {
371
    public function test_get_preload_record_columns_sql(): void {
Línea 372... Línea 372...
372
        global $DB;
372
        global $DB;
373
 
373
 
374
        $result = context_helper::get_preload_record_columns_sql('testalias');
374
        $result = context_helper::get_preload_record_columns_sql('testalias');
Línea 383... Línea 383...
383
 
383
 
384
    /**
384
    /**
385
     * Tests covered method.
385
     * Tests covered method.
386
     * @covers ::preload_from_record
386
     * @covers ::preload_from_record
387
     */
387
     */
388
    public function test_preload_from_record() {
388
    public function test_preload_from_record(): void {
Línea 389... Línea 389...
389
        global $DB;
389
        global $DB;
390
 
390
 
391
        $select = context_helper::get_preload_record_columns_sql('testalias');
391
        $select = context_helper::get_preload_record_columns_sql('testalias');
Línea 404... Línea 404...
404
 
404
 
405
    /**
405
    /**
406
     * Tests covered method.
406
     * Tests covered method.
407
     * @covers ::preload_contexts_by_id
407
     * @covers ::preload_contexts_by_id
408
     */
408
     */
409
    public function test_preload_contexts_by_id() {
409
    public function test_preload_contexts_by_id(): void {
Línea 410... Línea 410...
410
        global $DB;
410
        global $DB;
411
 
411
 
412
        $contextids = $DB->get_fieldset_sql("SELECT id FROM {context}", []);
412
        $contextids = $DB->get_fieldset_sql("SELECT id FROM {context}", []);
Línea 419... Línea 419...
419
 
419
 
420
    /**
420
    /**
421
     * Tests covered method.
421
     * Tests covered method.
422
     * @covers ::preload_course
422
     * @covers ::preload_course
423
     */
423
     */
424
    public function test_preload_course() {
424
    public function test_preload_course(): void {
425
        global $SITE;
425
        global $SITE;
426
        context_helper::preload_course($SITE->id);
426
        context_helper::preload_course($SITE->id);
Línea 427... Línea 427...
427
    }
427
    }
428
 
428
 
429
    /**
429
    /**
430
     * Tests covered method.
430
     * Tests covered method.
431
     * @covers ::delete_instance
431
     * @covers ::delete_instance
432
     */
432
     */
Línea 433... Línea 433...
433
    public function test_delete_instance() {
433
    public function test_delete_instance(): void {
434
        $this->resetAfterTest();
434
        $this->resetAfterTest();
435
 
435
 
Línea 448... Línea 448...
448
 
448
 
449
    /**
449
    /**
450
     * Tests covered method.
450
     * Tests covered method.
451
     * @covers ::get_level_name
451
     * @covers ::get_level_name
452
     */
452
     */
453
    public function test_get_level_name() {
453
    public function test_get_level_name(): void {
454
        $allevels = context_helper::get_all_levels();
454
        $allevels = context_helper::get_all_levels();
455
        foreach ($allevels as $level => $classname) {
455
        foreach ($allevels as $level => $classname) {
456
            $name = context_helper::get_level_name($level);
456
            $name = context_helper::get_level_name($level);
457
            $this->assertIsString($name);
457
            $this->assertIsString($name);
Línea 467... Línea 467...
467
 
467
 
468
    /**
468
    /**
469
     * Tests covered method.
469
     * Tests covered method.
470
     * @covers ::get_navigation_filter_context
470
     * @covers ::get_navigation_filter_context
471
     */
471
     */
472
    public function test_get_navigation_filter_context() {
472
    public function test_get_navigation_filter_context(): void {
473
        global $CFG;
473
        global $CFG;
Línea 474... Línea 474...
474
        $this->resetAfterTest();
474
        $this->resetAfterTest();
475
 
475