Línea 33... |
Línea 33... |
33 |
* @package tool_mobile
|
33 |
* @package tool_mobile
|
34 |
* @copyright 2016 Juan Leyva
|
34 |
* @copyright 2016 Juan Leyva
|
35 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
35 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
36 |
* @since Moodle 3.1
|
36 |
* @since Moodle 3.1
|
37 |
*/
|
37 |
*/
|
38 |
class externallib_test extends externallib_advanced_testcase {
|
38 |
final class externallib_test extends externallib_advanced_testcase {
|
Línea 39... |
Línea 39... |
39 |
|
39 |
|
40 |
/**
|
40 |
/**
|
41 |
* Test get_plugins_supporting_mobile.
|
41 |
* Test get_plugins_supporting_mobile.
|
42 |
* This is a very basic test because currently there aren't plugins supporting Mobile in core.
|
42 |
* This is a very basic test because currently there aren't plugins supporting Mobile in core.
|
Línea 100... |
Línea 100... |
100 |
'tool_mobile_androidappid' => get_config('tool_mobile', 'androidappid'),
|
100 |
'tool_mobile_androidappid' => get_config('tool_mobile', 'androidappid'),
|
101 |
'tool_mobile_setuplink' => get_config('tool_mobile', 'setuplink'),
|
101 |
'tool_mobile_setuplink' => get_config('tool_mobile', 'setuplink'),
|
102 |
'tool_mobile_qrcodetype' => get_config('tool_mobile', 'qrcodetype'),
|
102 |
'tool_mobile_qrcodetype' => get_config('tool_mobile', 'qrcodetype'),
|
103 |
'supportpage' => $CFG->supportpage,
|
103 |
'supportpage' => $CFG->supportpage,
|
104 |
'supportavailability' => $CFG->supportavailability,
|
104 |
'supportavailability' => $CFG->supportavailability,
|
105 |
'warnings' => array()
|
105 |
'warnings' => [],
|
- |
|
106 |
'showloginform' => (int) get_config('core', 'showloginform'),
|
106 |
);
|
107 |
);
|
107 |
$this->assertEquals($expected, $result);
|
108 |
$this->assertEquals($expected, $result);
|
Línea 108... |
Línea 109... |
108 |
|
109 |
|
109 |
$this->setAdminUser();
|
110 |
$this->setAdminUser();
|
Línea 121... |
Línea 122... |
121 |
set_config('disabledfeatures', 'myoverview', 'tool_mobile');
|
122 |
set_config('disabledfeatures', 'myoverview', 'tool_mobile');
|
122 |
set_config('minimumversion', '3.8.0', 'tool_mobile');
|
123 |
set_config('minimumversion', '3.8.0', 'tool_mobile');
|
123 |
set_config('supportemail', 'test@test.com');
|
124 |
set_config('supportemail', 'test@test.com');
|
124 |
set_config('supportavailability', CONTACT_SUPPORT_ANYONE);
|
125 |
set_config('supportavailability', CONTACT_SUPPORT_ANYONE);
|
Línea 125... |
Línea 126... |
125 |
|
126 |
|
126 |
// Enable couple of issuers.
|
127 |
// Enable an issuer.
|
127 |
$issuer = \core\oauth2\api::create_standard_issuer('google');
|
128 |
$issuer = \core\oauth2\api::create_standard_issuer('google');
|
128 |
$irecord = $issuer->to_record();
|
129 |
$irecord = $issuer->to_record();
|
129 |
$irecord->clientid = 'mock';
|
130 |
$irecord->clientid = 'mock';
|
130 |
$irecord->clientsecret = 'mock';
|
131 |
$irecord->clientsecret = 'mock';
|
Línea 131... |
Línea -... |
131 |
\core\oauth2\api::update_issuer($irecord);
|
- |
|
132 |
|
- |
|
133 |
set_config('hostname', 'localhost', 'auth_cas');
|
- |
|
134 |
set_config('auth_logo', 'http://invalidurl.com//invalid/', 'auth_cas');
|
132 |
\core\oauth2\api::update_issuer($irecord);
|
Línea 135... |
Línea 133... |
135 |
set_config('auth_name', 'CAS', 'auth_cas');
|
133 |
|
136 |
set_config('auth', 'oauth2,cas');
|
134 |
set_config('auth', 'oauth2');
|
137 |
|
135 |
|
138 |
list($authinstructions, $notusedformat) = \core_external\util::format_text($authinstructions, FORMAT_MOODLE, $context->id);
|
136 |
list($authinstructions, $notusedformat) = \core_external\util::format_text($authinstructions, FORMAT_MOODLE, $context->id);
|
Línea 156... |
Línea 154... |
156 |
$expected['compactlogourl'] = $compactlogourl->out(false);
|
154 |
$expected['compactlogourl'] = $compactlogourl->out(false);
|
157 |
}
|
155 |
}
|
Línea 158... |
Línea 156... |
158 |
|
156 |
|
159 |
$result = external::get_public_config();
|
157 |
$result = external::get_public_config();
|
160 |
$result = external_api::clean_returnvalue(external::get_public_config_returns(), $result);
|
- |
|
161 |
// First check providers.
|
- |
|
162 |
$identityproviders = $result['identityproviders'];
|
- |
|
Línea 163... |
Línea 158... |
163 |
unset($result['identityproviders']);
|
158 |
$result = external_api::clean_returnvalue(external::get_public_config_returns(), $result);
|
164 |
|
- |
|
165 |
$this->assertEquals('Google', $identityproviders[0]['name']);
|
- |
|
166 |
$this->assertEquals($irecord->image, $identityproviders[0]['iconurl']);
|
- |
|
167 |
$this->assertStringContainsString($CFG->wwwroot, $identityproviders[0]['url']);
|
159 |
|
168 |
|
160 |
// First check the provider.
|
169 |
$this->assertEquals('CAS', $identityproviders[1]['name']);
|
- |
|
Línea -... |
Línea 161... |
- |
|
161 |
$identityprovider = $result['identityproviders'];
|
- |
|
162 |
unset($result['identityproviders']);
|
- |
|
163 |
|
170 |
$this->assertEmpty($identityproviders[1]['iconurl']);
|
164 |
$this->assertEquals('Google', $identityprovider[0]['name']);
|
171 |
$this->assertStringContainsString($CFG->wwwroot, $identityproviders[1]['url']);
|
- |
|
172 |
|
- |
|
173 |
$this->assertEquals($expected, $result);
|
- |
|
174 |
|
- |
|
175 |
// Change providers img.
|
- |
|
176 |
$newurl = 'validimage.png';
|
- |
|
177 |
set_config('auth_logo', $newurl, 'auth_cas');
|
- |
|
178 |
$result = external::get_public_config();
|
165 |
$this->assertEquals($irecord->image, $identityprovider[0]['iconurl']);
|
Línea 179... |
Línea 166... |
179 |
$result = external_api::clean_returnvalue(external::get_public_config_returns(), $result);
|
166 |
$this->assertStringContainsString($CFG->wwwroot, $identityprovider[0]['url']);
|
180 |
$this->assertStringContainsString($newurl, $result['identityproviders'][1]['iconurl']);
|
167 |
$this->assertEquals($expected, $result);
|
181 |
}
|
168 |
}
|