MDL-45131 enrol: Add validation for returned parameters in WS tests
authorJuan Leyva <juanleyvadelgado@gmail.com>
Mon, 13 Apr 2015 14:37:49 +0000 (16:37 +0200)
committerJuan Leyva <juanleyvadelgado@gmail.com>
Thu, 16 Apr 2015 08:25:25 +0000 (10:25 +0200)
enrol/self/tests/externallib_test.php
enrol/tests/externallib_test.php

index 343af57..d4abbe2 100644 (file)
@@ -69,6 +69,7 @@ class enrol_self_external_testcase extends externallib_advanced_testcase {
         $this->assertCount(3, $enrolmentmethods);
 
         $instanceinfo1 = enrol_self_external::get_instance_info($instanceid1);
+        $instanceinfo1 = external_api::clean_returnvalue(enrol_self_external::get_instance_info_returns(), $instanceinfo1);
 
         $this->assertEquals($instanceid1, $instanceinfo1['id']);
         $this->assertEquals($course->id, $instanceinfo1['courseid']);
@@ -78,6 +79,7 @@ class enrol_self_external_testcase extends externallib_advanced_testcase {
         $this->assertFalse(isset($instanceinfo1['enrolpassword']));
 
         $instanceinfo2 = enrol_self_external::get_instance_info($instanceid2);
+        $instanceinfo2 = external_api::clean_returnvalue(enrol_self_external::get_instance_info_returns(), $instanceinfo2);
         $this->assertEquals($instanceid2, $instanceinfo2['id']);
         $this->assertEquals($course->id, $instanceinfo2['courseid']);
         $this->assertEquals('self', $instanceinfo2['type']);
@@ -86,6 +88,7 @@ class enrol_self_external_testcase extends externallib_advanced_testcase {
         $this->assertFalse(isset($instanceinfo2['enrolpassword']));
 
         $instanceinfo3 = enrol_self_external::get_instance_info($instanceid3);
+        $instanceinfo3 = external_api::clean_returnvalue(enrol_self_external::get_instance_info_returns(), $instanceinfo3);
         $this->assertEquals($instanceid3, $instanceinfo3['id']);
         $this->assertEquals($course->id, $instanceinfo3['courseid']);
         $this->assertEquals('self', $instanceinfo3['type']);
index 40c0917..170d064 100644 (file)
@@ -271,6 +271,8 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
 
         // Check if information is returned.
         $enrolmentmethods = core_enrol_external::get_course_enrolment_methods($course1->id);
+        $enrolmentmethods = external_api::clean_returnvalue(core_enrol_external::get_course_enrolment_methods_returns(),
+                                                            $enrolmentmethods);
         // Enrolment information is currently returned by self enrolment plugin, so count == 1.
         // This should be changed as we implement get_enrol_info() for other enrolment plugins.
         $this->assertCount(1, $enrolmentmethods);
@@ -287,6 +289,8 @@ class core_enrol_externallib_testcase extends externallib_advanced_testcase {
                                                                 'customint6' => 1,
                                                                 'password' => 'test'));
         $enrolmentmethods = core_enrol_external::get_course_enrolment_methods($course2->id);
+        $enrolmentmethods = external_api::clean_returnvalue(core_enrol_external::get_course_enrolment_methods_returns(),
+                                                            $enrolmentmethods);
         $this->assertCount(1, $enrolmentmethods);
 
         $enrolmentmethod = $enrolmentmethods[0];