/** * Test that we can return scale values for a scale with the scale ID. */ public function test_get_scale_values() { global $DB; $this->setUser($this->creator); // Create a scale. $record = new stdClass(); $record->courseid = 0; $record->userid = $this->creator->id; $record->name = 'Test scale'; $record->scale = 'Poor, Not good, Okay, Fine, Excellent'; $record->description = '<p>Test scale description.</p>'; $record->descriptionformat = 1; $record->timemodified = time(); $scaleid = $DB->insert_record('scale', $record); // Expected return value. $expected = array(array('id' => 1, 'name' => 'Poor'), array('id' => 2, 'name' => 'Not good'), array('id' => 3, 'name' => 'Okay'), array('id' => 4, 'name' => 'Fine'), array('id' => 5, 'name' => 'Excellent')); // Call the webservice. $result = external::get_scale_values($scaleid); $this->assertEquals($expected, $result); }