| Línea 24... |
Línea 24... |
| 24 |
* @copyright 2015 Frédéric Massart - FMCorz.net
|
24 |
* @copyright 2015 Frédéric Massart - FMCorz.net
|
| 25 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
25 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 26 |
*/
|
26 |
*/
|
| 27 |
class generator_test extends \advanced_testcase {
|
27 |
class generator_test extends \advanced_testcase {
|
| Línea 28... |
Línea 28... |
| 28 |
|
28 |
|
| 29 |
public function test_create_framework() {
|
29 |
public function test_create_framework(): void {
|
| Línea 30... |
Línea 30... |
| 30 |
$this->resetAfterTest(true);
|
30 |
$this->resetAfterTest(true);
|
| 31 |
|
31 |
|
| 32 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
32 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
| 33 |
$this->assertEquals(0, competency_framework::count_records());
|
33 |
$this->assertEquals(0, competency_framework::count_records());
|
| 34 |
$framework = $lpg->create_framework();
|
34 |
$framework = $lpg->create_framework();
|
| 35 |
$framework = $lpg->create_framework();
|
35 |
$framework = $lpg->create_framework();
|
| 36 |
$this->assertEquals(2, competency_framework::count_records());
|
36 |
$this->assertEquals(2, competency_framework::count_records());
|
| Línea 37... |
Línea 37... |
| 37 |
$this->assertInstanceOf('\core_competency\competency_framework', $framework);
|
37 |
$this->assertInstanceOf('\core_competency\competency_framework', $framework);
|
| 38 |
}
|
38 |
}
|
| Línea 39... |
Línea 39... |
| 39 |
|
39 |
|
| 40 |
public function test_create_competency() {
|
40 |
public function test_create_competency(): void {
|
| 41 |
$this->resetAfterTest(true);
|
41 |
$this->resetAfterTest(true);
|
| Línea 47... |
Línea 47... |
| 47 |
$competency = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));
|
47 |
$competency = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));
|
| 48 |
$this->assertEquals(2, competency::count_records());
|
48 |
$this->assertEquals(2, competency::count_records());
|
| 49 |
$this->assertInstanceOf('\core_competency\competency', $competency);
|
49 |
$this->assertInstanceOf('\core_competency\competency', $competency);
|
| 50 |
}
|
50 |
}
|
| Línea 51... |
Línea 51... |
| 51 |
|
51 |
|
| 52 |
public function test_create_related_competency() {
|
52 |
public function test_create_related_competency(): void {
|
| Línea 53... |
Línea 53... |
| 53 |
$this->resetAfterTest(true);
|
53 |
$this->resetAfterTest(true);
|
| 54 |
|
54 |
|
| 55 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
55 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
| Línea 62... |
Línea 62... |
| 62 |
$rc = $lpg->create_related_competency(array('competencyid' => $c2->get('id'), 'relatedcompetencyid' => $c3->get('id')));
|
62 |
$rc = $lpg->create_related_competency(array('competencyid' => $c2->get('id'), 'relatedcompetencyid' => $c3->get('id')));
|
| 63 |
$this->assertEquals(2, related_competency::count_records());
|
63 |
$this->assertEquals(2, related_competency::count_records());
|
| 64 |
$this->assertInstanceOf('\core_competency\related_competency', $rc);
|
64 |
$this->assertInstanceOf('\core_competency\related_competency', $rc);
|
| 65 |
}
|
65 |
}
|
| Línea 66... |
Línea 66... |
| 66 |
|
66 |
|
| 67 |
public function test_create_plan() {
|
67 |
public function test_create_plan(): void {
|
| Línea 68... |
Línea 68... |
| 68 |
$this->resetAfterTest(true);
|
68 |
$this->resetAfterTest(true);
|
| 69 |
|
69 |
|
| 70 |
$user = $this->getDataGenerator()->create_user();
|
70 |
$user = $this->getDataGenerator()->create_user();
|
| 71 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
71 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
| 72 |
$this->assertEquals(0, plan::count_records());
|
72 |
$this->assertEquals(0, plan::count_records());
|
| 73 |
$plan = $lpg->create_plan(array('userid' => $user->id));
|
73 |
$plan = $lpg->create_plan(array('userid' => $user->id));
|
| 74 |
$this->assertEquals(1, plan::count_records());
|
74 |
$this->assertEquals(1, plan::count_records());
|
| Línea 75... |
Línea 75... |
| 75 |
$this->assertInstanceOf('\core_competency\plan', $plan);
|
75 |
$this->assertInstanceOf('\core_competency\plan', $plan);
|
| 76 |
}
|
76 |
}
|
| Línea 77... |
Línea 77... |
| 77 |
|
77 |
|
| 78 |
public function test_create_user_competency() {
|
78 |
public function test_create_user_competency(): void {
|
| 79 |
$this->resetAfterTest(true);
|
79 |
$this->resetAfterTest(true);
|
| Línea 89... |
Línea 89... |
| 89 |
$rc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));
|
89 |
$rc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));
|
| 90 |
$this->assertEquals(2, user_competency::count_records());
|
90 |
$this->assertEquals(2, user_competency::count_records());
|
| 91 |
$this->assertInstanceOf('\core_competency\user_competency', $rc);
|
91 |
$this->assertInstanceOf('\core_competency\user_competency', $rc);
|
| 92 |
}
|
92 |
}
|
| Línea 93... |
Línea 93... |
| 93 |
|
93 |
|
| 94 |
public function test_create_user_competency_plan() {
|
94 |
public function test_create_user_competency_plan(): void {
|
| Línea 95... |
Línea 95... |
| 95 |
$this->resetAfterTest(true);
|
95 |
$this->resetAfterTest(true);
|
| 96 |
|
96 |
|
| 97 |
$user = $this->getDataGenerator()->create_user();
|
97 |
$user = $this->getDataGenerator()->create_user();
|
| Línea 113... |
Línea 113... |
| 113 |
));
|
113 |
));
|
| 114 |
$this->assertEquals(2, user_competency_plan::count_records());
|
114 |
$this->assertEquals(2, user_competency_plan::count_records());
|
| 115 |
$this->assertInstanceOf('\core_competency\user_competency_plan', $ucp);
|
115 |
$this->assertInstanceOf('\core_competency\user_competency_plan', $ucp);
|
| 116 |
}
|
116 |
}
|
| Línea 117... |
Línea 117... |
| 117 |
|
117 |
|
| 118 |
public function test_create_template() {
|
118 |
public function test_create_template(): void {
|
| Línea 119... |
Línea 119... |
| 119 |
$this->resetAfterTest(true);
|
119 |
$this->resetAfterTest(true);
|
| 120 |
|
120 |
|
| 121 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
121 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
| 122 |
$this->assertEquals(0, template::count_records());
|
122 |
$this->assertEquals(0, template::count_records());
|
| 123 |
$template = $lpg->create_template();
|
123 |
$template = $lpg->create_template();
|
| 124 |
$template = $lpg->create_template();
|
124 |
$template = $lpg->create_template();
|
| 125 |
$this->assertEquals(2, template::count_records());
|
125 |
$this->assertEquals(2, template::count_records());
|
| Línea 126... |
Línea 126... |
| 126 |
$this->assertInstanceOf('\core_competency\template', $template);
|
126 |
$this->assertInstanceOf('\core_competency\template', $template);
|
| 127 |
}
|
127 |
}
|
| 128 |
|
128 |
|
| Línea 129... |
Línea 129... |
| 129 |
public function test_create_template_competency() {
|
129 |
public function test_create_template_competency(): void {
|
| 130 |
$this->resetAfterTest(true);
|
130 |
$this->resetAfterTest(true);
|
| Línea 139... |
Línea 139... |
| 139 |
$relation = $lpg->create_template_competency(array('competencyid' => $c2->get('id'), 'templateid' => $template->get('id')));
|
139 |
$relation = $lpg->create_template_competency(array('competencyid' => $c2->get('id'), 'templateid' => $template->get('id')));
|
| 140 |
$this->assertEquals(2, template_competency::count_records());
|
140 |
$this->assertEquals(2, template_competency::count_records());
|
| 141 |
$this->assertInstanceOf('\core_competency\template_competency', $relation);
|
141 |
$this->assertInstanceOf('\core_competency\template_competency', $relation);
|
| 142 |
}
|
142 |
}
|
| Línea 143... |
Línea 143... |
| 143 |
|
143 |
|
| 144 |
public function test_create_plan_competency() {
|
144 |
public function test_create_plan_competency(): void {
|
| 145 |
$this->resetAfterTest(true);
|
145 |
$this->resetAfterTest(true);
|
| 146 |
$user = $this->getDataGenerator()->create_user();
|
146 |
$user = $this->getDataGenerator()->create_user();
|
| Línea 147... |
Línea 147... |
| 147 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
147 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
| Línea 159... |
Línea 159... |
| 159 |
$this->assertInstanceOf('\core_competency\plan_competency', $pc1);
|
159 |
$this->assertInstanceOf('\core_competency\plan_competency', $pc1);
|
| 160 |
$this->assertInstanceOf('\core_competency\plan_competency', $pc2);
|
160 |
$this->assertInstanceOf('\core_competency\plan_competency', $pc2);
|
| 161 |
$this->assertEquals($plan->get('id'), $pc1->get('planid'));
|
161 |
$this->assertEquals($plan->get('id'), $pc1->get('planid'));
|
| 162 |
}
|
162 |
}
|
| Línea 163... |
Línea 163... |
| 163 |
|
163 |
|
| 164 |
public function test_create_template_cohort() {
|
164 |
public function test_create_template_cohort(): void {
|
| Línea 165... |
Línea 165... |
| 165 |
$this->resetAfterTest(true);
|
165 |
$this->resetAfterTest(true);
|
| 166 |
|
166 |
|
| 167 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
167 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
| Línea 174... |
Línea 174... |
| 174 |
$tc = $lpg->create_template_cohort(array('templateid' => $t1->get('id'), 'cohortid' => $c2->id));
|
174 |
$tc = $lpg->create_template_cohort(array('templateid' => $t1->get('id'), 'cohortid' => $c2->id));
|
| 175 |
$this->assertEquals(2, template_cohort::count_records());
|
175 |
$this->assertEquals(2, template_cohort::count_records());
|
| 176 |
$this->assertInstanceOf('\core_competency\template_cohort', $tc);
|
176 |
$this->assertInstanceOf('\core_competency\template_cohort', $tc);
|
| 177 |
}
|
177 |
}
|
| Línea 178... |
Línea 178... |
| 178 |
|
178 |
|
| 179 |
public function test_create_evidence() {
|
179 |
public function test_create_evidence(): void {
|
| Línea 180... |
Línea 180... |
| 180 |
$this->resetAfterTest(true);
|
180 |
$this->resetAfterTest(true);
|
| 181 |
|
181 |
|
| 182 |
$user = $this->getDataGenerator()->create_user();
|
182 |
$user = $this->getDataGenerator()->create_user();
|
| Línea 190... |
Línea 190... |
| 190 |
$e = $lpg->create_evidence(array('usercompetencyid' => $rc2->get('id')));
|
190 |
$e = $lpg->create_evidence(array('usercompetencyid' => $rc2->get('id')));
|
| 191 |
$this->assertEquals(2, evidence::count_records());
|
191 |
$this->assertEquals(2, evidence::count_records());
|
| 192 |
$this->assertInstanceOf('\core_competency\evidence', $e);
|
192 |
$this->assertInstanceOf('\core_competency\evidence', $e);
|
| 193 |
}
|
193 |
}
|
| Línea 194... |
Línea 194... |
| 194 |
|
194 |
|
| 195 |
public function test_create_course_competency() {
|
195 |
public function test_create_course_competency(): void {
|
| Línea 196... |
Línea 196... |
| 196 |
$this->resetAfterTest(true);
|
196 |
$this->resetAfterTest(true);
|
| 197 |
|
197 |
|
| 198 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
198 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
| Línea 210... |
Línea 210... |
| 210 |
$rc = $lpg->create_course_competency(array('competencyid' => $c3->get('id'), 'courseid' => $course2->id));
|
210 |
$rc = $lpg->create_course_competency(array('competencyid' => $c3->get('id'), 'courseid' => $course2->id));
|
| 211 |
$this->assertEquals(1, course_competency::count_records(array('courseid' => $course2->id)));
|
211 |
$this->assertEquals(1, course_competency::count_records(array('courseid' => $course2->id)));
|
| 212 |
$this->assertInstanceOf('\core_competency\course_competency', $rc);
|
212 |
$this->assertInstanceOf('\core_competency\course_competency', $rc);
|
| 213 |
}
|
213 |
}
|
| Línea 214... |
Línea 214... |
| 214 |
|
214 |
|
| 215 |
public function test_create_course_module_competency() {
|
215 |
public function test_create_course_module_competency(): void {
|
| Línea 216... |
Línea 216... |
| 216 |
$this->resetAfterTest(true);
|
216 |
$this->resetAfterTest(true);
|
| 217 |
|
217 |
|
| 218 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
218 |
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|