| Línea 49... |
Línea 49... |
| 49 |
}
|
49 |
}
|
| Línea 50... |
Línea 50... |
| 50 |
|
50 |
|
| 51 |
/**
|
51 |
/**
|
| 52 |
* Test getting the event factory.
|
52 |
* Test getting the event factory.
|
| 53 |
*/
|
53 |
*/
|
| 54 |
public function test_get_event_factory() {
|
54 |
public function test_get_event_factory(): void {
|
| Línea 55... |
Línea 55... |
| 55 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
55 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
| 56 |
|
56 |
|
| 57 |
// Test that the container is returning the right type.
|
57 |
// Test that the container is returning the right type.
|
| Línea 68... |
Línea 68... |
| 68 |
* Test that the event factory correctly creates instances of events.
|
68 |
* Test that the event factory correctly creates instances of events.
|
| 69 |
*
|
69 |
*
|
| 70 |
* @dataProvider get_event_factory_testcases()
|
70 |
* @dataProvider get_event_factory_testcases()
|
| 71 |
* @param \stdClass $dbrow Row from the "database".
|
71 |
* @param \stdClass $dbrow Row from the "database".
|
| 72 |
*/
|
72 |
*/
|
| 73 |
public function test_event_factory_create_instance($dbrow) {
|
73 |
public function test_event_factory_create_instance($dbrow): void {
|
| 74 |
$legacyevent = $this->create_event($dbrow);
|
74 |
$legacyevent = $this->create_event($dbrow);
|
| 75 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
75 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
| 76 |
$course = $this->getDataGenerator()->create_course();
|
76 |
$course = $this->getDataGenerator()->create_course();
|
| 77 |
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
77 |
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
| 78 |
$moduleinstance = $generator->create_instance(['course' => $course->id]);
|
78 |
$moduleinstance = $generator->create_instance(['course' => $course->id]);
|
| Línea 129... |
Línea 129... |
| 129 |
* Test that the event factory deals with invisible modules properly as admin.
|
129 |
* Test that the event factory deals with invisible modules properly as admin.
|
| 130 |
*
|
130 |
*
|
| 131 |
* @dataProvider get_event_factory_testcases()
|
131 |
* @dataProvider get_event_factory_testcases()
|
| 132 |
* @param \stdClass $dbrow Row from the "database".
|
132 |
* @param \stdClass $dbrow Row from the "database".
|
| 133 |
*/
|
133 |
*/
|
| 134 |
public function test_event_factory_when_module_visibility_is_toggled_as_admin($dbrow) {
|
134 |
public function test_event_factory_when_module_visibility_is_toggled_as_admin($dbrow): void {
|
| 135 |
$legacyevent = $this->create_event($dbrow);
|
135 |
$legacyevent = $this->create_event($dbrow);
|
| 136 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
136 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
| 137 |
$course = $this->getDataGenerator()->create_course();
|
137 |
$course = $this->getDataGenerator()->create_course();
|
| 138 |
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
138 |
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
| 139 |
$moduleinstance = $generator->create_instance(['course' => $course->id]);
|
139 |
$moduleinstance = $generator->create_instance(['course' => $course->id]);
|
| Línea 155... |
Línea 155... |
| 155 |
* Test that the event factory deals with invisible modules properly as a guest.
|
155 |
* Test that the event factory deals with invisible modules properly as a guest.
|
| 156 |
*
|
156 |
*
|
| 157 |
* @dataProvider get_event_factory_testcases()
|
157 |
* @dataProvider get_event_factory_testcases()
|
| 158 |
* @param \stdClass $dbrow Row from the "database".
|
158 |
* @param \stdClass $dbrow Row from the "database".
|
| 159 |
*/
|
159 |
*/
|
| 160 |
public function test_event_factory_when_module_visibility_is_toggled_as_guest($dbrow) {
|
160 |
public function test_event_factory_when_module_visibility_is_toggled_as_guest($dbrow): void {
|
| 161 |
$legacyevent = $this->create_event($dbrow);
|
161 |
$legacyevent = $this->create_event($dbrow);
|
| 162 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
162 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
| 163 |
$course = $this->getDataGenerator()->create_course();
|
163 |
$course = $this->getDataGenerator()->create_course();
|
| 164 |
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
164 |
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
| 165 |
$moduleinstance = $generator->create_instance(['course' => $course->id]);
|
165 |
$moduleinstance = $generator->create_instance(['course' => $course->id]);
|
| Línea 184... |
Línea 184... |
| 184 |
* Test that the event factory deals with invisible courses as an admin.
|
184 |
* Test that the event factory deals with invisible courses as an admin.
|
| 185 |
*
|
185 |
*
|
| 186 |
* @dataProvider get_event_factory_testcases()
|
186 |
* @dataProvider get_event_factory_testcases()
|
| 187 |
* @param \stdClass $dbrow Row from the "database".
|
187 |
* @param \stdClass $dbrow Row from the "database".
|
| 188 |
*/
|
188 |
*/
|
| 189 |
public function test_event_factory_when_course_visibility_is_toggled_as_admin($dbrow) {
|
189 |
public function test_event_factory_when_course_visibility_is_toggled_as_admin($dbrow): void {
|
| 190 |
$legacyevent = $this->create_event($dbrow);
|
190 |
$legacyevent = $this->create_event($dbrow);
|
| 191 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
191 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
| Línea 192... |
Línea 192... |
| 192 |
|
192 |
|
| 193 |
// Create a hidden course with an assignment.
|
193 |
// Create a hidden course with an assignment.
|
| Línea 209... |
Línea 209... |
| 209 |
* Test that the event factory deals with invisible courses as a student.
|
209 |
* Test that the event factory deals with invisible courses as a student.
|
| 210 |
*
|
210 |
*
|
| 211 |
* @dataProvider get_event_factory_testcases()
|
211 |
* @dataProvider get_event_factory_testcases()
|
| 212 |
* @param \stdClass $dbrow Row from the "database".
|
212 |
* @param \stdClass $dbrow Row from the "database".
|
| 213 |
*/
|
213 |
*/
|
| 214 |
public function test_event_factory_when_course_visibility_is_toggled_as_student($dbrow) {
|
214 |
public function test_event_factory_when_course_visibility_is_toggled_as_student($dbrow): void {
|
| 215 |
$legacyevent = $this->create_event($dbrow);
|
215 |
$legacyevent = $this->create_event($dbrow);
|
| 216 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
216 |
$factory = \core_calendar\local\event\container::get_event_factory();
|
| Línea 217... |
Línea 217... |
| 217 |
|
217 |
|
| 218 |
// Create a hidden course with an assignment.
|
218 |
// Create a hidden course with an assignment.
|
| Línea 238... |
Línea 238... |
| 238 |
}
|
238 |
}
|
| Línea 239... |
Línea 239... |
| 239 |
|
239 |
|
| 240 |
/**
|
240 |
/**
|
| 241 |
* Test that the event factory deals with invisible categorys as an admin.
|
241 |
* Test that the event factory deals with invisible categorys as an admin.
|
| 242 |
*/
|
242 |
*/
|
| 243 |
public function test_event_factory_when_category_visibility_is_toggled_as_admin() {
|
243 |
public function test_event_factory_when_category_visibility_is_toggled_as_admin(): void {
|
| 244 |
// Create a hidden category.
|
244 |
// Create a hidden category.
|
| Línea 245... |
Línea 245... |
| 245 |
$category = $this->getDataGenerator()->create_category(['visible' => 0]);
|
245 |
$category = $this->getDataGenerator()->create_category(['visible' => 0]);
|
| 246 |
|
246 |
|
| Línea 261... |
Línea 261... |
| 261 |
}
|
261 |
}
|
| Línea 262... |
Línea 262... |
| 262 |
|
262 |
|
| 263 |
/**
|
263 |
/**
|
| 264 |
* Test that the event factory deals with invisible categorys as an user.
|
264 |
* Test that the event factory deals with invisible categorys as an user.
|
| 265 |
*/
|
265 |
*/
|
| 266 |
public function test_event_factory_when_category_visibility_is_toggled_as_user() {
|
266 |
public function test_event_factory_when_category_visibility_is_toggled_as_user(): void {
|
| 267 |
// Create a hidden category.
|
267 |
// Create a hidden category.
|
| Línea 268... |
Línea 268... |
| 268 |
$category = $this->getDataGenerator()->create_category(['visible' => 0]);
|
268 |
$category = $this->getDataGenerator()->create_category(['visible' => 0]);
|
| 269 |
|
269 |
|
| Línea 290... |
Línea 290... |
| 290 |
}
|
290 |
}
|
| Línea 291... |
Línea 291... |
| 291 |
|
291 |
|
| 292 |
/**
|
292 |
/**
|
| 293 |
* Test that the event factory deals with invisible categorys as an guest.
|
293 |
* Test that the event factory deals with invisible categorys as an guest.
|
| 294 |
*/
|
294 |
*/
|
| 295 |
public function test_event_factory_when_category_visibility_is_toggled_as_guest() {
|
295 |
public function test_event_factory_when_category_visibility_is_toggled_as_guest(): void {
|
| 296 |
// Create a hidden category.
|
296 |
// Create a hidden category.
|
| Línea 297... |
Línea 297... |
| 297 |
$category = $this->getDataGenerator()->create_category(['visible' => 0]);
|
297 |
$category = $this->getDataGenerator()->create_category(['visible' => 0]);
|
| 298 |
|
298 |
|
| Línea 316... |
Línea 316... |
| 316 |
}
|
316 |
}
|
| Línea 317... |
Línea 317... |
| 317 |
|
317 |
|
| 318 |
/**
|
318 |
/**
|
| 319 |
* Test that the event factory deals with completion related events properly.
|
319 |
* Test that the event factory deals with completion related events properly.
|
| 320 |
*/
|
320 |
*/
|
| 321 |
public function test_event_factory_with_completion_related_event() {
|
321 |
public function test_event_factory_with_completion_related_event(): void {
|
| Línea 322... |
Línea 322... |
| 322 |
global $CFG;
|
322 |
global $CFG;
|
| Línea 323... |
Línea 323... |
| 323 |
|
323 |
|
| Línea 369... |
Línea 369... |
| 369 |
|
369 |
|
| 370 |
/**
|
370 |
/**
|
| 371 |
* Checks that completed activities events do not show.
|
371 |
* Checks that completed activities events do not show.
|
| 372 |
* @covers \core_calendar\local\event::init
|
372 |
* @covers \core_calendar\local\event::init
|
| 373 |
*/
|
373 |
*/
|
| 374 |
public function test_event_factory_with_completed_module_related_event() {
|
374 |
public function test_event_factory_with_completed_module_related_event(): void {
|
| Línea 375... |
Línea 375... |
| 375 |
global $CFG, $DB;
|
375 |
global $CFG, $DB;
|
| Línea 376... |
Línea 376... |
| 376 |
|
376 |
|
| Línea 404... |
Línea 404... |
| 404 |
|
404 |
|
| 405 |
/**
|
405 |
/**
|
| 406 |
* Test that the event factory only returns an event if the logged in user
|
406 |
* Test that the event factory only returns an event if the logged in user
|
| 407 |
* is enrolled in the course.
|
407 |
* is enrolled in the course.
|
| 408 |
*/
|
408 |
*/
|
| 409 |
public function test_event_factory_unenrolled_user() {
|
409 |
public function test_event_factory_unenrolled_user(): void {
|
| 410 |
$user = $this->getDataGenerator()->create_user();
|
410 |
$user = $this->getDataGenerator()->create_user();
|
| 411 |
// Create the course we will be using.
|
411 |
// Create the course we will be using.
|
| Línea 412... |
Línea 412... |
| 412 |
$course = $this->getDataGenerator()->create_course();
|
412 |
$course = $this->getDataGenerator()->create_course();
|
| Línea 457... |
Línea 457... |
| 457 |
}
|
457 |
}
|
| Línea 458... |
Línea 458... |
| 458 |
|
458 |
|
| 459 |
/**
|
459 |
/**
|
| 460 |
* Test that when course module is deleted all events are also deleted.
|
460 |
* Test that when course module is deleted all events are also deleted.
|
| 461 |
*/
|
461 |
*/
|
| 462 |
public function test_delete_module_delete_events() {
|
462 |
public function test_delete_module_delete_events(): void {
|
| 463 |
global $DB;
|
463 |
global $DB;
|
| 464 |
$user = $this->getDataGenerator()->create_user();
|
464 |
$user = $this->getDataGenerator()->create_user();
|
| 465 |
// Create the course we will be using.
|
465 |
// Create the course we will be using.
|
| 466 |
$course = $this->getDataGenerator()->create_course();
|
466 |
$course = $this->getDataGenerator()->create_course();
|
| Línea 488... |
Línea 488... |
| 488 |
}
|
488 |
}
|
| Línea 489... |
Línea 489... |
| 489 |
|
489 |
|
| 490 |
/**
|
490 |
/**
|
| 491 |
* Test getting the event mapper.
|
491 |
* Test getting the event mapper.
|
| 492 |
*/
|
492 |
*/
|
| 493 |
public function test_get_event_mapper() {
|
493 |
public function test_get_event_mapper(): void {
|
| Línea 494... |
Línea 494... |
| 494 |
$mapper = \core_calendar\local\event\container::get_event_mapper();
|
494 |
$mapper = \core_calendar\local\event\container::get_event_mapper();
|
| 495 |
|
495 |
|