Línea 26... |
Línea 26... |
26 |
* @package core
|
26 |
* @package core
|
27 |
* @copyright Petr Skoda
|
27 |
* @copyright Petr Skoda
|
28 |
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
28 |
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
29 |
* @coversDefaultClass \core\context\module
|
29 |
* @coversDefaultClass \core\context\module
|
30 |
*/
|
30 |
*/
|
31 |
class module_test extends \advanced_testcase {
|
31 |
final class module_test extends \advanced_testcase {
|
32 |
/**
|
32 |
/**
|
33 |
* Tests legacy class.
|
33 |
* Tests legacy class.
|
34 |
* @coversNothing
|
34 |
* @coversNothing
|
35 |
*/
|
35 |
*/
|
36 |
public function test_legacy_classname(): void {
|
36 |
public function test_legacy_classname(): void {
|
Línea 187... |
Línea 187... |
187 |
*/
|
187 |
*/
|
188 |
public function test_get_capabilities(): void {
|
188 |
public function test_get_capabilities(): void {
|
189 |
$this->resetAfterTest();
|
189 |
$this->resetAfterTest();
|
Línea 190... |
Línea 190... |
190 |
|
190 |
|
191 |
$course = $this->getDataGenerator()->create_course();
|
191 |
$course = $this->getDataGenerator()->create_course();
|
192 |
$page = $this->getDataGenerator()->create_module('page', ['course' => $course->id, 'name' => 'Pokus']);
|
192 |
$mod = $this->getDataGenerator()->create_module('book', ['course' => $course->id, 'name' => 'Pokus']);
|
Línea 193... |
Línea 193... |
193 |
$context = module::instance($page->cmid);
|
193 |
$context = module::instance($mod->cmid);
|
194 |
|
194 |
|
195 |
$capabilities = $context->get_capabilities();
|
195 |
$capabilities = $context->get_capabilities();
|
- |
|
196 |
$capabilities = convert_to_array($capabilities);
|
196 |
$capabilities = convert_to_array($capabilities);
|
197 |
$capabilities = array_column($capabilities, 'name');
|
- |
|
198 |
|
- |
|
199 |
$this->assertContains('mod/book:read', $capabilities);
|
197 |
$capabilities = array_column($capabilities, 'name');
|
200 |
$this->assertContains('booktool/exportimscp:export', $capabilities);
|
198 |
$this->assertContains('mod/page:view', $capabilities);
|
201 |
$this->assertContains('booktool/importhtml:import', $capabilities);
|
199 |
$this->assertNotContains('mod/url:view', $capabilities);
|
202 |
$this->assertNotContains('mod/url:view', $capabilities);
|
200 |
$this->assertNotContains('moodle/course:view', $capabilities);
|
203 |
$this->assertNotContains('moodle/course:view', $capabilities);
|
201 |
$this->assertNotContains('moodle/category:manage', $capabilities);
|
204 |
$this->assertNotContains('moodle/category:manage', $capabilities);
|