| Línea 33... |
Línea 33... |
| 33 |
* The test class for the content_item_readonly_repository class.
|
33 |
* The test class for the content_item_readonly_repository class.
|
| 34 |
*
|
34 |
*
|
| 35 |
* @copyright 2020 Jake Dallimore <jrhdallimore@gmail.com>
|
35 |
* @copyright 2020 Jake Dallimore <jrhdallimore@gmail.com>
|
| 36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 37 |
*/
|
37 |
*/
|
| 38 |
class content_item_readonly_repository_test extends \advanced_testcase {
|
38 |
final class content_item_readonly_repository_test extends \advanced_testcase {
|
| 39 |
/**
|
39 |
/**
|
| 40 |
* Test the repository method, find_all_for_course().
|
40 |
* Test the repository method, find_all_for_course().
|
| 41 |
*/
|
41 |
*/
|
| 42 |
public function test_find_all_for_course(): void {
|
42 |
public function test_find_all_for_course(): void {
|
| 43 |
$this->resetAfterTest();
|
43 |
$this->resetAfterTest();
|
| Línea 45... |
Línea 45... |
| 45 |
$course = $this->getDataGenerator()->create_course();
|
45 |
$course = $this->getDataGenerator()->create_course();
|
| 46 |
$user = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
46 |
$user = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
| 47 |
$cir = new content_item_readonly_repository();
|
47 |
$cir = new content_item_readonly_repository();
|
| Línea 48... |
Línea 48... |
| 48 |
|
48 |
|
| - |
|
49 |
$items = $cir->find_all_for_course($course, $user);
|
| 49 |
$items = $cir->find_all_for_course($course, $user);
|
50 |
$modqbankfound = false;
|
| 50 |
foreach ($items as $key => $item) {
|
51 |
foreach ($items as $key => $item) {
|
| 51 |
$this->assertInstanceOf(content_item::class, $item);
|
52 |
$this->assertInstanceOf(content_item::class, $item);
|
| 52 |
$this->assertEquals($course->id, $item->get_link()->param('id'));
|
53 |
$this->assertEquals($course->id, $item->get_link()->param('id'));
|
| - |
|
54 |
$this->assertNotNull($item->get_link()->param('add'));
|
| - |
|
55 |
|
| - |
|
56 |
// We should never get an instance of mod_qbank, as they have FEATURE_CAN_DISPLAY set to false.
|
| - |
|
57 |
if ($item->get_component_name() === 'mod_qbank') {
|
| - |
|
58 |
$modqbankfound = true;
|
| 53 |
$this->assertNotNull($item->get_link()->param('add'));
|
59 |
}
|
| - |
|
60 |
}
|
| 54 |
}
|
61 |
$this->assertFalse($modqbankfound);
|
| Línea 55... |
Línea 62... |
| 55 |
}
|
62 |
}
|
| 56 |
|
63 |
|
| 57 |
/**
|
64 |
/**
|
| Línea 111... |
Línea 118... |
| 111 |
$all = $cir->find_all();
|
118 |
$all = $cir->find_all();
|
| 112 |
$all = array_filter($all, function($contentitem) {
|
119 |
$all = array_filter($all, function($contentitem) {
|
| 113 |
return str_contains($contentitem->get_name(), 'lti_type');
|
120 |
return str_contains($contentitem->get_name(), 'lti_type');
|
| 114 |
});
|
121 |
});
|
| 115 |
$this->assertCount(1, $all);
|
122 |
$this->assertCount(1, $all);
|
| - |
|
123 |
|
| - |
|
124 |
// We should never get an instance of mod_qbank, as they have FEATURE_CAN_DISPLAY set to false.
|
| - |
|
125 |
$all = $cir->find_all();
|
| - |
|
126 |
$all = array_filter($all, static fn($contentitem) => str_contains($contentitem->get_component_name(), 'mod_qbank'));
|
| - |
|
127 |
|
| - |
|
128 |
$this->assertCount(0, $all);
|
| 116 |
}
|
129 |
}
|
| 117 |
}
|
130 |
}
|