Merge branch 'MDL-35593-master' of git://github.com/mouneyrac/moodle
authorSam Hemelryk <sam@moodle.com>
Tue, 11 Dec 2012 20:38:43 +0000 (09:38 +1300)
committerSam Hemelryk <sam@moodle.com>
Tue, 11 Dec 2012 20:38:43 +0000 (09:38 +1300)
webservice/externallib.php
webservice/tests/externallib_test.php

index 0956386..a51b213 100644 (file)
@@ -189,7 +189,7 @@ class core_webservice_external extends external_api {
                     new external_single_structure(
                         array(
                             'name' => new external_value(PARAM_RAW, 'function name'),
-                            'version' => new external_value(PARAM_FLOAT,
+                            'version' => new external_value(PARAM_TEXT,
                                         'The version number of the component to which the function belongs')
                         ), 'functions that are available')
                     ),
index 3868087..eb34d39 100644 (file)
@@ -64,6 +64,10 @@ class core_webservice_external_testcase extends externallib_advanced_testcase {
         $webservice->downloadfiles = true;
         $externalserviceid = $DB->insert_record('external_services', $webservice);
 
+        // Add a function to the service
+        $DB->insert_record('external_services_functions', array('externalserviceid' => $externalserviceid,
+            'functionname' => 'core_course_get_contents'));
+
         $_POST['wstoken'] = 'testtoken';
         $externaltoken = new stdClass();
         $externaltoken->token = 'testtoken';
@@ -86,6 +90,10 @@ class core_webservice_external_testcase extends externallib_advanced_testcase {
         $this->assertEquals($CFG->release, $siteinfo['release']);
         $this->assertEquals($CFG->version, $siteinfo['version']);
         $this->assertEquals(get_config('admin', 'mobilecssurl'), $siteinfo['mobilecssurl']);
+        $this->assertEquals(count($siteinfo['functions']), 1);
+        $function = array_pop($siteinfo['functions']);
+        $this->assertEquals($function['name'], 'core_course_get_contents');
+        $this->assertEquals($function['version'], $siteinfo['version']);
     }
 
 }