コード例 #1
0
 /**
  * Test we can list and count competencies with read permissions.
  */
 public function test_list_and_count_competencies_with_read_permissions()
 {
     $this->setUser($this->creator);
     $framework = $this->create_competency_framework(1, true);
     $result = $this->create_competency(1, $framework->id);
     $result = $this->create_competency(2, $framework->id);
     $result = $this->create_competency(3, $framework->id);
     $this->setUser($this->user);
     $result = external::count_competencies(array());
     $result = external_api::clean_returnvalue(external::count_competencies_returns(), $result);
     $this->assertEquals($result, 3);
     array('id' => $result = external::list_competencies(array(), 'shortname', 'ASC', 0, 10, context_system::instance()->id));
     $result = external_api::clean_returnvalue(external::list_competencies_returns(), $result);
     $this->assertEquals(count($result), 3);
     $result = (object) $result[0];
     $this->assertGreaterThan(0, $result->timecreated);
     $this->assertGreaterThan(0, $result->timemodified);
     $this->assertEquals($this->creator->id, $result->usermodified);
     $this->assertEquals('shortname1', $result->shortname);
     $this->assertEquals('idnumber1', $result->idnumber);
     $this->assertEquals('description1', $result->description);
 }