Differences Between: [Versions 310 and 311] [Versions 39 and 311]
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 * User evidence competency persistent testcase. 21 * 22 * @package core_competency 23 * @copyright 2016 Serge Gauthier - <serge.gauthier.2@umontreal.ca> 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 class user_evidence_competency_test extends \advanced_testcase { 27 28 public function test_get_user_competencies_by_userevidenceid() { 29 global $CFG, $DB; 30 31 $this->resetAfterTest(true); 32 $dg = $this->getDataGenerator(); 33 $lpg = $dg->get_plugin_generator('core_competency'); 34 35 $u1 = $dg->create_user(); 36 37 // Create framework with competencies. 38 $fw = $lpg->create_framework(); 39 $c1 = $lpg->create_competency(array('competencyframeworkid' => $fw->get('id'))); 40 $c2 = $lpg->create_competency(array('competencyframeworkid' => $fw->get('id'))); 41 $c3 = $lpg->create_competency(array('competencyframeworkid' => $fw->get('id'))); 42 $c4 = $lpg->create_competency(array('competencyframeworkid' => $fw->get('id'))); 43 44 // Create a plan with competencies. 45 $p1 = $lpg->create_plan(array('userid' => $u1->id)); 46 $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id'))); 47 $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c2->get('id'))); 48 $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c3->get('id'))); 49 $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c4->get('id'))); 50 51 // Create a prior learning evidence and link competencies. 52 $ue1 = $lpg->create_user_evidence(array('userid' => $u1->id)); 53 $uec11 = $lpg->create_user_evidence_competency(array('userevidenceid' => $ue1->get('id'), 'competencyid' => $c1->get('id'))); 54 $uec12 = $lpg->create_user_evidence_competency(array('userevidenceid' => $ue1->get('id'), 'competencyid' => $c2->get('id'))); 55 $uec13 = $lpg->create_user_evidence_competency(array('userevidenceid' => $ue1->get('id'), 'competencyid' => $c3->get('id'))); 56 $uc11 = $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $c1->get('id'))); 57 $uc12 = $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $c2->get('id'))); 58 $uc13 = $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $c3->get('id'))); 59 60 // Create an other prior learning evidence and link competencies. 61 $ue2 = $lpg->create_user_evidence(array('userid' => $u1->id)); 62 $uec22 = $lpg->create_user_evidence_competency(array('userevidenceid' => $ue2->get('id'), 'competencyid' => $c4->get('id'))); 63 $uc22 = $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $c4->get('id'))); 64 65 // Check the user competencies associated to the first prior learning evidence. 66 $ucs = user_evidence_competency::get_user_competencies_by_userevidenceid($ue1->get('id')); 67 $this->assertCount(3, $ucs); 68 $uc = array_shift($ucs); 69 $this->assertEquals($uc->get('id'), $uc11->get('id')); 70 $uc = array_shift($ucs); 71 $this->assertEquals($uc->get('id'), $uc12->get('id')); 72 $uc = array_shift($ucs); 73 $this->assertEquals($uc->get('id'), $uc13->get('id')); 74 75 // Check the user competencies associated to the second prior learning evidence. 76 $ucs = user_evidence_competency::get_user_competencies_by_userevidenceid($ue2->get('id')); 77 $this->assertCount(1, $ucs); 78 $uc = array_shift($ucs); 79 $this->assertEquals($uc->get('id'), $uc22->get('id')); 80 } 81 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body