Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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 core_competency;
18
 
19
/**
20
 * Course module competency persistent testcase.
21
 *
22
 * @package    core_competency
23
 * @copyright  2019 Damyon Wiese
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
class course_module_competency_test extends \advanced_testcase {
27
 
11 efrain 28
    public function test_count_competencies(): void {
1 efrain 29
        global $CFG, $DB;
30
 
31
        $this->resetAfterTest(true);
32
        $dg = $this->getDataGenerator();
33
        $lpg = $dg->get_plugin_generator('core_competency');
34
 
35
        $c1 = $dg->create_course();
36
        $u1 = $dg->create_user();
37
        $u2 = $dg->create_user();
38
 
39
        $framework = $lpg->create_framework();
40
        $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));   // In C1, and C2.
41
        $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));   // In C2.
42
        $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));
43
        $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));
44
 
45
        $assign1a = $dg->create_module('assign', ['course' => $c1]);
46
        $assign1b = $dg->create_module('assign', ['course' => $c1]);
47
        $cmc1a = $lpg->create_course_module_competency(['competencyid' => $comp1->get('id'), 'cmid' => $assign1a->cmid]);
48
        $cmc1b = $lpg->create_course_module_competency(['competencyid' => $comp1->get('id'), 'cmid' => $assign1b->cmid]);
49
        $cmc2b = $lpg->create_course_module_competency(['competencyid' => $comp2->get('id'), 'cmid' => $assign1b->cmid]);
50
 
51
        // Enrol the user 1 in C1.
52
        $dg->enrol_user($u1->id, $c1->id);
53
 
54
        $all = course_module_competency::list_course_module_competencies($assign1a->cmid);
55
        $this->assertEquals(course_module_competency::count_competencies($assign1a->cmid), count($all));
56
 
57
        $all = course_module_competency::list_course_module_competencies($assign1b->cmid);
58
        $this->assertEquals(course_module_competency::count_competencies($assign1b->cmid), count($all));
59
    }
60
 
61
}