Merge branch 'MDL-54857-master' of git://github.com/jleyva/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 5 Jul 2016 22:03:39 +0000 (00:03 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 5 Jul 2016 22:03:39 +0000 (00:03 +0200)
1  2 
admin/tool/mobile/tests/externallib_test.php

@@@ -50,8 -50,48 +50,49 @@@ class tool_mobile_external_testcase ext
          $result = external::get_plugins_supporting_mobile();
          $result = external_api::clean_returnvalue(external::get_plugins_supporting_mobile_returns(), $result);
          $this->assertCount(0, $result['warnings']);
 -        $this->assertCount(0, $result['plugins']);
 +        $this->assertArrayHasKey('plugins', $result);
 +        $this->assertTrue(is_array($result['plugins']));
      }
  
+     public function test_get_site_public_settings() {
+         global $CFG, $SITE;
+         $this->resetAfterTest(true);
+         $result = external::get_site_public_settings();
+         $result = external_api::clean_returnvalue(external::get_site_public_settings_returns(), $result);
+         // Test default values.
+         $context = context_system::instance();
+         $expected = array(
+             'wwwroot' => $CFG->wwwroot,
+             'httpswwwroot' => $CFG->httpswwwroot,
+             'sitename' => external_format_string($SITE->fullname, $context->id, true),
+             'guestlogin' => $CFG->guestloginbutton,
+             'rememberusername' => $CFG->rememberusername,
+             'authloginviaemail' => $CFG->authloginviaemail,
+             'registerauth' => $CFG->registerauth,
+             'forgottenpasswordurl' => $CFG->forgottenpasswordurl,
+             'authinstructions' => format_text($CFG->auth_instructions),
+             'authnoneenabled' => (int) is_enabled_auth('none'),
+             'enablewebservices' => $CFG->enablewebservices,
+             'enablemobilewebservice' => $CFG->enablemobilewebservice,
+             'maintenanceenabled' => $CFG->maintenance_enabled,
+             'maintenancemessage' => format_text($CFG->maintenance_message),
+             'warnings' => array()
+         );
+         $this->assertEquals($expected, $result);
+         // Change a value.
+         set_config('registerauth', 'email');
+         $authinstructions = 'Something with <b>html tags</b>';
+         set_config('auth_instructions', $authinstructions);
+         $expected['registerauth'] = 'email';
+         $expected['authinstructions'] = format_text($authinstructions);
+         $result = external::get_site_public_settings();
+         $result = external_api::clean_returnvalue(external::get_site_public_settings_returns(), $result);
+         $this->assertEquals($expected, $result);
+     }
  }