[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Moodle Mobile admin tool external functions tests. 19 * 20 * @package tool_mobile 21 * @category external 22 * @copyright 2016 Juan Leyva 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 * @since Moodle 3.1 25 */ 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 global $CFG; 30 31 require_once($CFG->dirroot . '/webservice/tests/helpers.php'); 32 33 use tool_mobile\external; 34 35 /** 36 * External learning plans webservice API tests. 37 * 38 * @package tool_mobile 39 * @copyright 2016 Juan Leyva 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 * @since Moodle 3.1 42 */ 43 class tool_mobile_external_testcase extends externallib_advanced_testcase { 44 45 /** 46 * Test get_plugins_supporting_mobile. 47 * This is a very basic test because currently there aren't plugins supporting Mobile in core. 48 */ 49 public function test_get_plugins_supporting_mobile() { 50 $result = external::get_plugins_supporting_mobile(); 51 $result = external_api::clean_returnvalue(external::get_plugins_supporting_mobile_returns(), $result); 52 $this->assertCount(0, $result['warnings']); 53 $this->assertArrayHasKey('plugins', $result); 54 $this->assertTrue(is_array($result['plugins'])); 55 } 56 57 public function test_get_site_public_settings() { 58 global $CFG, $SITE; 59 60 $this->resetAfterTest(true); 61 $result = external::get_site_public_settings(); 62 $result = external_api::clean_returnvalue(external::get_site_public_settings_returns(), $result); 63 64 // Test default values. 65 $context = context_system::instance(); 66 $expected = array( 67 'wwwroot' => $CFG->wwwroot, 68 'httpswwwroot' => $CFG->httpswwwroot, 69 'sitename' => external_format_string($SITE->fullname, $context->id, true), 70 'guestlogin' => $CFG->guestloginbutton, 71 'rememberusername' => $CFG->rememberusername, 72 'authloginviaemail' => $CFG->authloginviaemail, 73 'registerauth' => $CFG->registerauth, 74 'forgottenpasswordurl' => $CFG->forgottenpasswordurl, 75 'authinstructions' => format_text($CFG->auth_instructions), 76 'authnoneenabled' => (int) is_enabled_auth('none'), 77 'enablewebservices' => $CFG->enablewebservices, 78 'enablemobilewebservice' => $CFG->enablemobilewebservice, 79 'maintenanceenabled' => $CFG->maintenance_enabled, 80 'maintenancemessage' => format_text($CFG->maintenance_message), 81 'warnings' => array() 82 ); 83 $this->assertEquals($expected, $result); 84 85 // Change a value. 86 set_config('registerauth', 'email'); 87 $authinstructions = 'Something with <b>html tags</b>'; 88 set_config('auth_instructions', $authinstructions); 89 90 $expected['registerauth'] = 'email'; 91 $expected['authinstructions'] = format_text($authinstructions); 92 93 $result = external::get_site_public_settings(); 94 $result = external_api::clean_returnvalue(external::get_site_public_settings_returns(), $result); 95 $this->assertEquals($expected, $result); 96 } 97 98 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |