Ejemplo n.º 1
0
 /**
  * Test we can read a competency with read permissions.
  */
 public function test_read_competencies_with_read_permissions_in_category()
 {
     $this->setUser($this->creator);
     $sysframework = $this->create_competency_framework(1, true);
     $insystem = $this->create_competency(1, $sysframework->id);
     $catframework = $this->create_competency_framework(2, false);
     $incat = $this->create_competency(2, $catframework->id);
     // Switch users to someone with less permissions.
     $this->setUser($this->catuser);
     $id = $incat->id;
     $result = external::read_competency($id);
     $result = (object) external_api::clean_returnvalue(external::read_competency_returns(), $result);
     $this->assertGreaterThan(0, $result->timecreated);
     $this->assertGreaterThan(0, $result->timemodified);
     $this->assertEquals($this->creator->id, $result->usermodified);
     $this->assertEquals('shortname2', $result->shortname);
     $this->assertEquals('idnumber2', $result->idnumber);
     $this->assertEquals('description2', $result->description);
     $this->assertEquals(FORMAT_HTML, $result->descriptionformat);
     $this->assertEquals(0, $result->parentid);
     $this->assertEquals($catframework->id, $result->competencyframeworkid);
     try {
         external::read_competency($insystem->id);
         $this->fail('User should not be able to read a competency in system context.');
     } catch (required_capability_exception $e) {
         // All good.
     }
 }