Exemple #1
0
 /**
  * @expectedException        require_login_exception
  * @expectedExceptionMessage Activity is hidden
  */
 public function test_view_glossary_without_permission()
 {
     $this->resetAfterTest(true);
     // Generate all the things.
     $c1 = $this->getDataGenerator()->create_course();
     $g1 = $this->getDataGenerator()->create_module('glossary', array('course' => $c1->id));
     $u1 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($u1->id, $c1->id);
     $ctx = context_module::instance($g1->cmid);
     // Revoke permission.
     $roles = get_archetype_roles('user');
     $role = array_shift($roles);
     assign_capability('mod/glossary:view', CAP_PROHIBIT, $role->id, $ctx, true);
     accesslib_clear_all_caches_for_unit_testing();
     // Assertion.
     $this->setUser($u1);
     mod_glossary_external::view_glossary($g1->id, 'letter');
 }