/.project
/.buildpath
/.cache
+.phpunit.result.cache
phpunit.xml
# Composer support. Do not ignore composer.json, or composer.lock. These should be shipped by us.
composer.phar
$mform = $this->_form;
// Recipient.
- $options = ['maxlength' => '100', 'size' => '25'];
+ $options = ['maxlength' => '100', 'size' => '25', 'autocomplete' => 'email'];
$mform->addElement('text', 'recipient', get_string('testoutgoingmailconf_toemail', 'admin'), $options);
$mform->setType('recipient', PARAM_EMAIL);
$mform->addRule('recipient', get_string('required'), 'required');
'id' => $this->get_id(),
'name' => $this->get_full_name(),
'value' => $data['v'],
+ 'readonly' => $this->is_readonly(),
'options' => array_map(function($unit, $title) use ($data, $defaultunit) {
return [
'value' => $unit,
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Payment gateway admin setting.
+ *
+ * @package core_admin
+ * @copyright 2020 Shamim Rezaie <shamim@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace core_admin\local\settings;
+
+/**
+ * Generic class for managing plugins in a table that allows re-ordering and enable/disable of each plugin.
+ */
+class manage_payment_gateway_plugins extends \admin_setting_manage_plugins {
+ /**
+ * Get the admin settings section title (use get_string).
+ *
+ * @return string
+ */
+ public function get_section_title() {
+ return get_string('type_paygw_plural', 'plugin');
+ }
+
+ /**
+ * Get the type of plugin to manage.
+ *
+ * @return string
+ */
+ public function get_plugin_type() {
+ return 'paygw';
+ }
+
+ /**
+ * Get the name of the second column.
+ *
+ * @return string
+ */
+ public function get_info_column_name() {
+ return get_string('supportedcurrencies', 'core_payment');
+ }
+
+ /**
+ * Get the type of plugin to manage.
+ *
+ * @param plugininfo The plugin info class.
+ * @return string
+ */
+ public function get_info_column($plugininfo) {
+ $codes = $plugininfo->get_supported_currencies();
+
+ $currencies = [];
+ foreach ($codes as $c) {
+ $currencies[$c] = new \lang_string($c, 'core_currencies');
+ }
+
+ return implode(get_string('listsep', 'langconfig') . ' ', $currencies);
+ }
+}
$user1->id,
$admin->id
];
- $this->assertEquals($expected, $userlist2->get_userids(), '', 0.0, 10, true);
+ $this->assertEqualsCanonicalizing($expected, $userlist2->get_userids());
// The user list for coursecontext1 should user1, user2 and admin (role creator).
$userlist3 = new \core_privacy\local\request\userlist($coursecontext1, $component);
$user2->id,
$admin->id
];
- $this->assertEquals($expected, $userlist3->get_userids(), '', 0.0, 10, true);
+ $this->assertEqualsCanonicalizing($expected, $userlist3->get_userids());
// The user list for coursecatcontext should user2 and admin (role creator).
$userlist4 = new \core_privacy\local\request\userlist($coursecatcontext, $component);
$user2->id,
$admin->id
];
- $this->assertEquals($expected, $userlist4->get_userids(), '', 0.0, 10, true);
+ $this->assertEqualsCanonicalizing($expected, $userlist4->get_userids());
// The user list for systemcontext should user1 and admin (role creator).
$userlist6 = new \core_privacy\local\request\userlist($systemcontext, $component);
$user1->id,
$admin->id
];
- $this->assertEquals($expected, $userlist6->get_userids(), '', 0.0, 10, true);
+ $this->assertEqualsCanonicalizing($expected, $userlist6->get_userids());
// The user list for cmcontext should user1, user2 and admin (role creator).
$userlist7 = new \core_privacy\local\request\userlist($cmcontext, $component);
$user2->id,
$admin->id
];
- $this->assertEquals($expected, $userlist7->get_userids(), '', 0.0, 10, true);
+ $this->assertEqualsCanonicalizing($expected, $userlist7->get_userids());
// The user list for blockcontext should user1 and admin (role creator).
$userlist8 = new \core_privacy\local\request\userlist($blockcontext, $component);
$user1->id,
$admin->id
];
- $this->assertEquals($expected, $userlist8->get_userids(), '', 0.0, 10, true);
+ $this->assertEqualsCanonicalizing($expected, $userlist8->get_userids());
}
/**
}
return $rolesnames;
}
-}
\ No newline at end of file
+}
$timesplittingdefaults, $timesplittingoptions)
);
- // Predictions processor output dir.
- $defaultmodeloutputdir = rtrim($CFG->dataroot, '/') . DIRECTORY_SEPARATOR . 'models';
- if (empty(get_config('analytics', 'modeloutputdir')) && !file_exists($defaultmodeloutputdir) &&
- is_writable($defaultmodeloutputdir)) {
- // Automatically create the dir for them so users don't see the invalid value red cross.
- mkdir($defaultmodeloutputdir, $CFG->directorypermissions, true);
- }
+ // Predictions processor output dir - specify default in setting description (used if left blank).
+ $defaultmodeloutputdir = \core_analytics\model::default_output_dir();
$settings->add(new admin_setting_configdirectory('analytics/modeloutputdir', new lang_string('modeloutputdir', 'analytics'),
- new lang_string('modeloutputdirinfo', 'analytics'), $defaultmodeloutputdir));
+ new lang_string('modeloutputdirwithdefaultinfo', 'analytics', $defaultmodeloutputdir), ''));
// Disable web interface evaluation and get predictions.
$settings->add(new admin_setting_configcheckbox('analytics/onlycli', new lang_string('onlycli', 'analytics'),
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+use core_admin\local\settings\filesize;
+
$capabilities = array(
'moodle/backup:backupcourse',
'moodle/category:manage',
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
1, $choices));
+ // Enable/disable download course content.
+ $choices = [
+ DOWNLOAD_COURSE_CONTENT_DISABLED => new lang_string('no'),
+ DOWNLOAD_COURSE_CONTENT_ENABLED => new lang_string('yes'),
+ ];
+ $downloadcontentsitedefault = new admin_setting_configselect('moodlecourse/downloadcontentsitedefault',
+ new lang_string('enabledownloadcoursecontent', 'course'),
+ new lang_string('downloadcoursecontent_help', 'course'), 0, $choices);
+ $downloadcontentsitedefault->add_dependent_on('downloadcoursecontentallowed');
+ $temp->add($downloadcontentsitedefault);
+
// Course format.
$temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
$ADMIN->add('courses', $temp);
+ // Download course content.
+ $downloadcoursedefaulturl = new moodle_url('/admin/settings.php', ['section' => 'coursesettings']);
+ $temp = new admin_settingpage('downloadcoursecontent', new lang_string('downloadcoursecontent', 'course'));
+ $temp->add(new admin_setting_configcheckbox('downloadcoursecontentallowed',
+ new lang_string('downloadcoursecontentallowed', 'admin'),
+ new lang_string('downloadcoursecontentallowed_desc', 'admin', $downloadcoursedefaulturl->out()), 0));
+
+ // 50MB default maximum size per file when downloading course content.
+ $defaultmaxdownloadsize = 50 * filesize::UNIT_MB;
+ $temp->add(new filesize('maxsizeperdownloadcoursefile', new lang_string('maxsizeperdownloadcoursefile', 'admin'),
+ new lang_string('maxsizeperdownloadcoursefile_desc', 'admin'), $defaultmaxdownloadsize, filesize::UNIT_MB));
+ $temp->hide_if('maxsizeperdownloadcoursefile', 'downloadcoursecontentallowed');
+
+ $ADMIN->add('courses', $temp);
+
// "courserequests" settingpage.
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
$temp->add(new admin_setting_configcheckbox('enablecourserequests',
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Adds payments links to the admin tree
+ *
+ * @package core
+ * @copyright 2020 Marina Glancy
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$ADMIN->add('payment', new admin_externalpage(
+ 'paymentaccounts',
+ new lang_string('paymentaccounts', 'payment'),
+ new moodle_url("/payment/accounts.php"),
+ ['moodle/payment:manageaccounts', 'moodle/payment:viewpayments']));
$plugin->load_settings($ADMIN, 'mediaplayers', $hassiteconfig);
}
+ // Payment gateway plugins.
+ $ADMIN->add('modules', new admin_category('paymentgateways', new lang_string('type_paygw_plural', 'plugin')));
+ $temp = new admin_settingpage('managepaymentgateways', new lang_string('type_paygwmanage', 'plugin'));
+ $temp->add(new \core_admin\local\settings\manage_payment_gateway_plugins());
+ $temp->add(new admin_setting_description(
+ 'managepaymentgatewayspostfix',
+ '',
+ new lang_string('gotopaymentaccounts', 'payment',
+ html_writer::link(new moodle_url('/payment/accounts.php'), get_string('paymentaccounts', 'payment')))
+ ));
+ $ADMIN->add('paymentgateways', $temp);
+
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('paygw');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
+ /** @var \core\plugininfo\paygw $plugin */
+ $plugin->load_settings($ADMIN, 'paymentgateways', $hassiteconfig);
+ }
+
// Data format settings.
$ADMIN->add('modules', new admin_category('dataformatsettings', new lang_string('dataformats')));
$temp = new admin_settingpage('managedataformats', new lang_string('managedataformats'));
new lang_string('divertallemailsexcept_desc', 'admin'),
'', PARAM_RAW, '50', '4'));
+ $noreplyaddress = isset($CFG->noreplyaddress) ? $CFG->noreplyaddress : 'noreply@example.com';
+ $dkimdomain = substr(strrchr($noreplyaddress, "@"), 1);
+ $dkimselector = empty($CFG->emaildkimselector) ? '[selector]' : $CFG->emaildkimselector;
+ $pempath = "\$CFG->dataroot/dkim/{$dkimdomain}/{$dkimselector}.private";
+ $temp->add(new admin_setting_heading('emaildkim', new lang_string('emaildkim', 'admin'),
+ new lang_string('emaildkiminfo', 'admin', ['path' => $pempath, 'docs' => \get_docs_url('Mail_configuration#DKIM')])));
+ $temp->add(new admin_setting_configtext('emaildkimselector', new lang_string('emaildkimselector', 'admin'),
+ new lang_string('configemaildkimselector', 'admin'), '', PARAM_FILE));
+
$url = new moodle_url('/admin/testoutgoingmailconf.php');
$link = html_writer::link($url, get_string('testoutgoingmailconf', 'admin'));
$temp->add(new admin_setting_heading('testoutgoinmailc', new lang_string('testoutgoingmailconf', 'admin'),
$ADMIN->add('root', new admin_category('location', new lang_string('location','admin')));
$ADMIN->add('root', new admin_category('language', new lang_string('language')));
$ADMIN->add('root', new admin_category('messaging', new lang_string('messagingcategory', 'admin')));
+$ADMIN->add('root', new admin_category('payment', new lang_string('payments', 'payment')));
$ADMIN->add('root', new admin_category('modules', new lang_string('plugins', 'admin')));
$ADMIN->add('root', new admin_category('security', new lang_string('security','admin')));
$ADMIN->add('root', new admin_category('appearance', new lang_string('appearance','admin')));
* value - yes value
* id - element id
* checked - boole
+ * readonly - bool
Example context (json):
{
"no": "False",
"value": "True",
"id": "test0",
- "checked": "checked"
+ "checked": "checked",
+ "readonly": false
}
}}
<div class="form-checkbox defaultsnext">
<input type="hidden" name="{{name}}" value="{{no}}">
- <input type="checkbox" name="{{name}}" value="{{value}}" id="{{id}}" {{#checked}}checked{{/checked}}>
+ <input {{#readonly}}disabled{{/readonly}} type="checkbox" name="{{name}}" value="{{value}}" id="{{id}}" {{#checked}}checked{{/checked}}>
</div>
* id - element id
* value - element value
* haspreviewconfig - show preview of selected color
+ * readonly - bool
Example context (json):
{
"name": "name0",
"id": "id0",
"value": "#555655",
+ "readonly": false,
"haspreviewconfig": false
}
}}
{{>core/pix_icon}}
{{/icon}}
</div>
- <input type="text" name="{{name}}" id="{{id}}" value="{{value}}" size="12" class="form-control text-ltr">
+ <input type="text" name="{{name}}" id="{{id}}" value="{{value}}" size="12" class="form-control text-ltr" {{#readonly}}disabled{{/readonly}}>
{{#haspreviewconfig}}
<input type="button" id="{{id}}_preview" value={{#quote}}{{#str}}preview{{/str}}{{/quote}} class="admin_colourpicker_preview">
{{/haspreviewconfig}}
"name": "test",
"value": "/my-super-secret-path/",
"id": "test0",
- "readonly": true,
+ "readonly": false,
"showvalidity": true,
"valid": false
}
* name - form element name
* options - list of options for units containing name, value, selected
* value - yes
+ * readonly - bool
* id - element id
Example context (json):
"name": "test",
"value": "5",
"id": "test0",
+ "readonly": false,
"options": [ { "name": "Minutes", "value": "mins", "selected": true } ]
}
}}
}}
<div class="form-duration defaultsnext">
<div class="form-inline">
- <input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr">
+ <input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr" {{#readonly}}disabled{{/readonly}}>
<label class="sr-only" for="{{id}}u">{{#str}}durationunits, admin{{/str}}</label>
- <select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select">
+ <select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select" {{#readonly}}disabled{{/readonly}}>
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/options}}
"name": "test",
"value": "/usr/bin/cowsay",
"id": "test0",
- "readonly": true,
+ "readonly": false,
"showvalidity": true,
"valid": false
}
* readonly - Make the field readonly
* value - value
* showvalidity - Show a green check if the path is readable
+ * readonly - bool
* valid - True if the path is readable
Example context (json):
"name": "test",
"value": "/my-super-secret-path/file",
"id": "test0",
- "readonly": true,
+ "readonly": false,
"showvalidity": true,
+ "readonly": false,
"valid": false
}
}}
* options - list of options for units containing name, value, selected
* value - yes
* id - element id
+ * readonly - bool
Example context (json):
{
"name": "test",
"value": "5",
"id": "test0",
+ "readonly": false,
"options": [ { "name": "KB", "value": "1024", "selected": true } ]
}
}}
}}
<div class="form-filesize defaultsnext">
<div class="form-inline">
- <input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr">
+ <input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr" {{#readonly}}disabled{{/readonly}}>
<label class="sr-only" for="{{id}}u">{{#str}}filesizeunits, admin{{/str}}</label>
- <select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select">
+ <select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select" {{#readonly}}disabled{{/readonly}}>
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/options}}
* id - element id
* size - element size
* options - list of options containing name, value, selected
+ * readonly - bool
Example context (json):
{
"name": "test",
"id": "test0",
+ "readonly": false,
"size": "3",
"options": [ { "name": "Option 1", "value": "V", "selected": true },
{ "name": "Option 2", "value": "V", "selected": true } ]
}}
<div class="form-select">
<input type="hidden" name="{{name}}[xxxxx]" value="1">
- <select id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
+ <select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/options}}
* size - element size
* options - list of options not grouped
* optgroups - list of options grouped containing the group label and for each option: name, value, selected
+ * readonly - bool
Example context (json):
{
"name": "test",
"id": "test0",
+ "readonly": false,
"size": "3",
"options": [
{ "name": "Option 1", "value": "V", "selected": false },
}}
<div class="form-select">
<input type="hidden" name="{{name}}[xxxxx]" value="1">
- <select id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
+ <select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/options}}
* size - form element size
* value - form element value
* id - element id
- * forced - has value been defined in config.php
+ * readonly - has value been defined in config.php
Example context (json):
{
"id": "test0",
"size": "8",
"value": "secret",
- "forced": false
+ "readonly": false
}
}}
-{{#forced}}
+{{#readonly}}
<div class="form-password">
<input type="text"
name = "{{ name }}"
disabled
>
</div>
-{{/forced}}
-{{^forced}}
+{{/readonly}}
+{{^readonly}}
<div class="form-password">
<span data-passwordunmask="wrapper" data-passwordunmaskid="{{ id }}">
<span data-passwordunmask="editor">
new PasswordUnmask("{{ id }}");
});
{{/js}}
-{{/forced}}
+{{/readonly}}
* name - form element name
* id - element id
* options - list of options containing name, value, selected
+ * readonly - bool
Example context (json):
{
"name": "test",
"id": "test0",
+ "readonly": false,
"options": [
{ "name": "Option 1", "value": "V", "selected": true },
{ "name": "Option 2", "value": "V", "selected": true }
Setting configselect.
}}
<div class="form-select defaultsnext">
- <select id="{{id}}" name="{{name}}" class="custom-select">
+ <select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}" class="custom-select">
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/options}}
Context variables required for this template:
* name - form element name
* id - element id
+ * readonly - bool
* options - list of options (not grouped)
* optgroups - list of options grouped containing the group label and for each option: name, value, selected
{
"name": "test",
"id": "test0",
+ "readonly": false,
"options": [
{ "name": "Option 1", "value": "V", "selected": false },
{ "name": "Option 2", "value": "V", "selected": false }
Setting configselect with optgroup support.
}}
<div class="form-select defaultsnext">
- <select id="{{id}}" name="{{name}}" class="custom-select">
+ <select {{#readonly}}disabled{{/readonly}} id="{{id}}" name="{{name}}" class="custom-select">
{{#options}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/options}}
* size - element size
* forceltr - always display as ltr
* attributes - list of additional attributes containing name, value
+ * readonly - bool
Example context (json):
{
"value": "A tall, dark stranger will have more fun than you.",
"size": "21",
"forceltr": false,
+ "readonly": false,
"attributes": [ { "name": "readonly", "value": "readonly" } ]
}
}}
Setting configtext.
}}
<div class="form-text defaultsnext">
- <input type="text" name="{{name}}" value="{{value}}" size="{{size}}" id="{{id}}" class="form-control {{#forceltr}}text-ltr{{/forceltr}}">
+ <input type="text" name="{{name}}" value="{{value}}" size="{{size}}" id="{{id}}" class="form-control {{#forceltr}}text-ltr{{/forceltr}}" {{#readonly}}disabled{{/readonly}}>
</div>
"cols": "30",
"rows": "3",
"value": "Excellent day for putting Slinkies on an escalator.",
+ "readonly": false,
"id": "test0"
}
}}
Setting configtextarea.
}}
<div class="form-textarea">
- <textarea rows="{{rows}}" cols="{{cols}}" id="{{id}}" name="{{name}}" spellcheck="true" class="form-control {{#forceltr}}text-ltr{{/forceltr}}">{{value}}</textarea>
+ <textarea {{#readonly}}disabled{{/readonly}} rows="{{rows}}" cols="{{cols}}" id="{{id}}" name="{{name}}" spellcheck="true" class="form-control {{#forceltr}}text-ltr{{/forceltr}}">{{value}}</textarea>
</div>
* id - element id
* hours - list of valid hour options containing name, value, selected
* minutes - list of valid minute options containing name, value, selected
+ * readonly - bool
Example context (json):
{
"name": "test",
"id": "test0",
+ "readonly": false,
"minutes": [
{ "name": "00", "value": "0", "selected": true },
{ "name": "01", "value": "1", "selected": false }
<div class="form-time defaultsnext">
<div class="form-inline text-ltr">
<label class="sr-only" for="{{id}}h">{{#str}}hours{{/str}}</label>
- <select id="{{id}}h" name="{{name}}[h]" class="custom-select">
+ <select id="{{id}}h" name="{{name}}[h]" class="custom-select" {{#readonly}}disabled{{/readonly}}>
{{#hours}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/hours}}
</select>:
<label class="sr-only" for="{{id}}m">{{#str}}minutes{{/str}}</label>
- <select id="{{id}}m" name="{{name}}[m]" class="custom-select">
+ <select id="{{id}}m" name="{{name}}[m]" class="custom-select" {{#readonly}}disabled{{/readonly}}>
{{#minutes}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
{{/minutes}}
--- /dev/null
+@core @core_admin
+Feature: Configure language settings for the site
+ In order to configure language settings for the site
+ As an admin
+ I want to set language settings relevant to my site users
+
+ Scenario: Set languages on language menu
+ Given I log in as "admin"
+ And I navigate to "Language > Language settings" in site administration
+ When I set the field "Languages on language menu" to "en"
+ And I press "Save changes"
+ Then I should not see "Invalid language code"
+
+ Scenario: Reset languages on language menu
+ Given I log in as "admin"
+ And I navigate to "Language > Language settings" in site administration
+ When I set the field "Languages on language menu" to ""
+ And I press "Save changes"
+ Then I should not see "Invalid language code"
+
+ Scenario Outline: Set languages on language menu with invalid language
+ Given I log in as "admin"
+ And I navigate to "Language > Language settings" in site administration
+ When I set the field "Languages on language menu" to "<fieldvalue>"
+ And I press "Save changes"
+ Then I should see "Invalid language code: <invalidlang>"
+ Examples:
+ | fieldvalue | invalidlang |
+ | xx | xx |
+ | xx\|Bad | xx |
+ | en,qq | qq |
+ | en,qq\|Bad | qq |
+ | en$$ | en$$ |
+ | en$$\|Bad | en$$ |
/**
* test_potential_contexts description
- *
- * @expectedException required_capability_exception
*/
public function test_potential_contexts_no_manager() {
$this->resetAfterTest();
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
+ $this->expectException(required_capability_exception::class);
$this->assertCount(2, \tool_analytics\external::potential_contexts());
}
}
/**
* Setup test.
*/
- public function setup() {
+ public function setUp(): void {
global $CFG;
$this->resetAfterTest();
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
// Check contexts.
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
$this->assertCount(count($paths), $suites[$themename]['paths']);
foreach ($paths as $key => $feature) {
- $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+ $this->assertStringContainsString($feature, $suites[$themename]['paths'][$key]);
}
}
}
/**
* Setup testcase.
*/
- public function setUp() {
+ public function setUp(): void {
$this->setAdminUser();
$this->resetAfterTest();
}
/**
* Setup function- we will create a course and add an assign instance to it.
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->resetAfterTest(true);
// Create some users.
cohort_add_member($this->cohort->id, $this->userassignover->id);
}
- /**
- * @expectedException required_capability_exception
- */
public function test_create_cohort_role_assignment_without_permission() {
$this->setUser($this->userassignto);
$params = (object) array(
'roleid' => $this->roleid,
'cohortid' => $this->cohort->id
);
+ $this->expectException(required_capability_exception::class);
api::create_cohort_role_assignment($params);
}
- /**
- * @expectedException core_competency\invalid_persistent_exception
- */
public function test_create_cohort_role_assignment_with_invalid_data() {
$this->setAdminUser();
$params = (object) array(
'roleid' => -8,
'cohortid' => $this->cohort->id
);
+ $this->expectException(\core_competency\invalid_persistent_exception::class);
api::create_cohort_role_assignment($params);
}
$this->assertEquals($result->get('cohortid'), $this->cohort->id);
}
- /**
- * @expectedException required_capability_exception
- */
public function test_delete_cohort_role_assignment_without_permission() {
$this->setAdminUser();
$params = (object) array(
);
$result = api::create_cohort_role_assignment($params);
$this->setUser($this->userassignto);
+ $this->expectException(required_capability_exception::class);
api::delete_cohort_role_assignment($result->get('id'));
}
- /**
- * @expectedException dml_missing_record_exception
- */
public function test_delete_cohort_role_assignment_with_invalid_data() {
$this->setAdminUser();
$params = (object) array(
'cohortid' => $this->cohort->id
);
$result = api::create_cohort_role_assignment($params);
+ $this->expectException(dml_missing_record_exception::class);
api::delete_cohort_role_assignment($result->get('id') + 1);
}
/**
* Overriding setUp() function to always reset after tests.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
}
CONTEXT_COURSECAT
];
// Test the User's contexts equal the system and course category context.
- $this->assertEquals($expected, $contextlevels, '', 0, 10, true);
+ $this->assertEqualsCanonicalizing($expected, $contextlevels);
}
/**
$string['cliexportfileexists'] = 'File for {$a->lang} already exists, skipping. If you want to overwrite add the --override=true option.';
$string['cliexportheading'] = 'Starting to export lang files.';
$string['cliexportnofilefoundforlang'] = 'No file found to export. Skipping export for this language.';
-$string['cliexportfilenotfoundforcomponent'] = 'File {$a->filepath} not found for language {$a->lang}.Skipping this file.';
-$string['cliexportstartexport'] = 'Exporting language "{$a}"';
+$string['cliexportfilenotfoundforcomponent'] = 'File {$a->filepath} not found for language {$a->lang}. Skipping this file.';
+$string['cliexportstartexport'] = 'Exporting language {$a}';
$string['cliexportzipdone'] = 'Zip created: {$a}';
$string['cliexportzipfail'] = 'Cannot create zip {$a}';
$string['clifiles'] = 'Files to import into {$a}';
$this->assertEquals($subject, $message->subject);
$this->assertEquals('tool_dataprivacy', $message->component);
$this->assertEquals('contactdataprotectionofficer', $message->eventtype);
- $this->assertContains(fullname($dpo), $message->fullmessage);
- $this->assertContains(fullname($user1), $message->fullmessage);
+ $this->assertStringContainsString(fullname($dpo), $message->fullmessage);
+ $this->assertStringContainsString(fullname($user1), $message->fullmessage);
}
/**
/**
* Test tearDown.
*/
- public function tearDown() {
+ public function tearDown(): void {
\core_privacy\local\request\writer::reset();
}
return $message->useridto;
}, $messages);
- $this->assertEquals(array_keys($dpos), $messageusers, '', 0.0, 0, true);
+ $this->assertEqualsCanonicalizing(array_keys($dpos), $messageusers);
}
/**
$this->assertEquals($strs->statusrejected, $data[1]->status);
$this->assertEquals($strs->creationmanual, $data[1]->creationmethod);
$this->assertEmpty($data[1]->comments);
- $this->assertContains('Nope', $data[1]->dpocomment);
+ $this->assertStringContainsString('Nope', $data[1]->dpocomment);
$this->assertNotEmpty($data[1]->timecreated);
}
$this->assertEquals(6, $preferences[helper::PREF_REQUEST_PERPAGE]->value);
}
-}
\ No newline at end of file
+}
/**
* Test tearDown.
*/
- public function tearDown() {
+ public function tearDown(): void {
\core_privacy\local\request\writer::reset();
}
$finder->upgrade_http_links();
$summary = $DB->get_field('course', 'summary', ['id' => $course->id]);
- $this->assertContains($expectedcontent, $summary);
+ $this->assertStringContainsString($expectedcontent, $summary);
}
/**
$this->assertCount(0, $results);
$summary = $DB->get_field('course', 'summary', ['id' => $course->id]);
- $this->assertContains('http://intentionally.unavailable/page.php', $summary);
- $this->assertContains('http://other.unavailable/page.php', $summary);
- $this->assertNotContains('https://intentionally.unavailable', $summary);
- $this->assertNotContains('https://other.unavailable', $summary);
+ $this->assertStringContainsString('http://intentionally.unavailable/page.php', $summary);
+ $this->assertStringContainsString('http://other.unavailable/page.php', $summary);
+ $this->assertStringNotContainsString('https://intentionally.unavailable', $summary);
+ $this->assertStringNotContainsString('https://other.unavailable', $summary);
}
/**
$finder->upgrade_http_links();
$summary = $DB->get_field('course', 'summary', ['id' => $course->id]);
- $this->assertContains($CFG->wwwroot, $summary);
+ $this->assertStringContainsString($CFG->wwwroot, $summary);
}
/**
$output = ob_get_contents();
ob_end_clean();
$this->assertTrue($results);
- $this->assertNotContains('https://somesite', $output);
+ $this->assertStringNotContainsString('https://somesite', $output);
$testconf = get_config('core', 'test_upgrade_http_links');
- $this->assertContains('http://somesite', $testconf);
- $this->assertNotContains('https://somesite', $testconf);
+ $this->assertStringContainsString('http://somesite', $testconf);
+ $this->assertStringNotContainsString('https://somesite', $testconf);
}
/**
$finder->upgrade_http_links();
$summary = $DB->get_field('course', 'summary', ['id' => $course->id]);
- $this->assertContains('https://secure.example.com', $summary);
- $this->assertNotContains('http://example.com', $summary);
+ $this->assertStringContainsString('https://secure.example.com', $summary);
+ $this->assertStringNotContainsString('http://example.com', $summary);
$this->assertEquals('<script src="https://secure.example.com/test.js">' .
'<img src="https://secure.example.com/someimage.png">', $summary);
}
$finder->upgrade_http_links();
$record = $DB->get_record('reserved_words_temp', []);
- $this->assertContains($expectedcontent, $record->where);
+ $this->assertStringContainsString($expectedcontent, $record->where);
$dbman->drop_table($table);
}
$this->assertEquals(1, preg_match('~^site=(.+)$~', $query, $matches));
$site = rawurldecode($matches[1]);
$site = json_decode(base64_decode($site), true);
- $this->assertInternalType('array', $site);
+ $this->assertIsArray($site);
$this->assertEquals(3, count($site));
$this->assertSame('Nasty site', $site['fullname']);
$this->assertSame('file:///etc/passwd', $site['url']);
/**
* Setup testcase.
*/
- public function setUp() {
+ public function setUp(): void {
$this->setAdminUser();
$this->resetAfterTest();
}
$this->assertEquals(context_system::instance(), $event->get_context());
}
- /**
- * @expectedException coding_exception
- * @expectedExceptionMessage The 'langcode' value must be set to a valid language code
- */
public function test_langpack_updated_validation() {
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code");
\tool_langimport\event\langpack_updated::event_with_langcode('broken langcode');
}
$this->assertEquals(context_system::instance(), $event->get_context());
}
- /**
- * @expectedException coding_exception
- * @expectedExceptionMessage The 'langcode' value must be set to a valid language code
- */
public function test_langpack_installed_validation() {
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code");
\tool_langimport\event\langpack_imported::event_with_langcode('broken langcode');
}
$this->assertEquals(context_system::instance(), $event->get_context());
}
- /**
- * @expectedException coding_exception
- * @expectedExceptionMessage The 'langcode' value must be set to a valid language code
- */
public function test_langpack_removed_validation() {
+ $this->expectException('coding_exception');
+ $this->expectExceptionMessage("The 'langcode' value must be set to a valid language code");
\tool_langimport\event\langpack_removed::event_with_langcode('broken langcode');
}
}
*/
class logstore_database_privacy_testcase extends provider_testcase {
- public function setUp() {
+ public function setUp(): void {
global $CFG;
$this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
*/
class logstore_legacy_privacy_testcase extends provider_testcase {
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest();
}
*/
class logstore_standard_privacy_testcase extends provider_testcase {
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
}
/**
* Reset any garbage collector changes to the previous state at the end of the test.
*/
- public function tearDown() {
+ public function tearDown(): void {
if ($this->wedisabledgc) {
gc_enable();
}
$this->assertInstanceOf('core\log\manager', $manager);
$stores = $manager->get_readers();
- $this->assertInternalType('array', $stores);
+ $this->assertIsArray($stores);
$this->assertCount(0, $stores);
$this->assertFileExists("$CFG->dirroot/$CFG->admin/tool/log/store/standard/version.php");
$this->assertInstanceOf('core\log\manager', $manager);
$stores = $manager->get_readers();
- $this->assertInternalType('array', $stores);
+ $this->assertIsArray($stores);
$this->assertCount(2, $stores);
foreach ($stores as $key => $store) {
- $this->assertInternalType('string', $key);
+ $this->assertIsString($key);
$this->assertInstanceOf('core\log\sql_reader', $store);
}
$stores = $manager->get_readers('core\log\sql_internal_table_reader');
- $this->assertInternalType('array', $stores);
+ $this->assertIsArray($stores);
$this->assertCount(1, $stores);
foreach ($stores as $key => $store) {
- $this->assertInternalType('string', $key);
+ $this->assertIsString($key);
$this->assertSame('logstore_standard', $key);
$this->assertInstanceOf('core\log\sql_internal_table_reader', $store);
}
$stores = $manager->get_readers('core\log\sql_reader');
- $this->assertInternalType('array', $stores);
+ $this->assertIsArray($stores);
$this->assertCount(2, $stores);
foreach ($stores as $key => $store) {
- $this->assertInternalType('string', $key);
+ $this->assertIsString($key);
$this->assertInstanceOf('core\log\sql_reader', $store);
}
}
*/
class tool_log_privacy_testcase extends provider_testcase {
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest();
$this->preventResetByRollback(); // Logging waits till the transaction gets committed.
}
/**
* Setup function- we will create a course and add an assign instance to it.
*/
- protected function setUp() {
+ protected function setUp(): void {
global $DB, $CFG;
$this->resetAfterTest(true);
* Then we create 2 courses, and in each 1 CM.
* Then we attach some competencies from the first framework to courses and CM.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('core_competency');
*/
class tool_messageinbound_manager_testcase extends provider_testcase {
- public function setUp() {
+ public function setUp(): void {
global $CFG;
$this->resetAfterTest();
*/
class tool_messageinbound_privacy_testcase extends provider_testcase {
- public function setUp() {
+ public function setUp(): void {
global $CFG;
$this->resetAfterTest();
$timenow = time();
$expectedissuer = null;
foreach ($info['certinfo'] as $cert) {
+
+ // Due to a bug in certain curl/openssl versions the signature algorithm isn't always correctly parsed.
+ // See https://github.com/curl/curl/issues/3706 for reference.
+ if (!array_key_exists('Signature Algorithm', $cert)) {
+ // The malformed field that does contain the algorithm we're looking for looks like the following:
+ // <WHITESPACE>Signature Algorithm: <ALGORITHM><CRLF><ALGORITHM>.
+ preg_match('/\s+Signature Algorithm: (?<algorithm>[^\s]+)/', $cert['Public Key Algorithm'], $matches);
+
+ $signaturealgorithm = $matches['algorithm'] ?? '';
+ } else {
+ $signaturealgorithm = $cert['Signature Algorithm'];
+ }
+
// Check if the signature algorithm is weak (Android won't work with SHA-1).
- if ($cert['Signature Algorithm'] == 'sha1WithRSAEncryption' || $cert['Signature Algorithm'] == 'sha1WithRSA') {
+ if ($signaturealgorithm == 'sha1WithRSAEncryption' || $signaturealgorithm == 'sha1WithRSA') {
$warnings[] = ['insecurealgorithmwarning', 'tool_mobile'];
}
// Check certificate start date.
$string['enablesmartappbanners'] = 'Enable App Banners';
$string['enablesmartappbanners_desc'] = 'If enabled, a banner promoting the mobile app will be displayed when accessing the site using a mobile browser.';
$string['filetypeexclusionlist'] = 'File type exclusion list';
-$string['filetypeexclusionlist_desc'] = 'List of file types that we don\'t want users to try and open in the app. These files will still be listed on the app\'s course screen, but attempting to open them on iOS or Android would display a warning to the user indicating that this file type is not intended for use on a mobile device. They can then either cancel the open, or ignore the warning and open anyway.';
+$string['filetypeexclusionlist_desc'] = 'Select all file types which are not for use on a mobile device. Such files will be listed in the course, then if a user attempts to open them, a warning will be displayed advising that the file type is not intended for use on a mobile device. The user can then cancel or ignore the warning and open the file anyway.';
$string['filetypeexclusionlistplaceholder'] = 'Mobile file type exclusion list';
$string['forcedurlscheme'] = 'If you want to allow only your custom branded app to be opened via a browser window, then specify its URL scheme here. If you want to allow only the official app, then set the default value. Leave the field empty if you want to allow any app.';
$string['forcedurlscheme_key'] = 'URL scheme';
$email = reset($emails);
// Check we got the promotion text.
- $this->assertContains($mobileappdownloadpage, quoted_printable_decode($email->body));
+ $this->assertStringContainsString($mobileappdownloadpage, quoted_printable_decode($email->body));
$sink->clear();
// Disable mobile so we don't get mobile promotions.
$this->assertCount(1, $emails);
$email = reset($emails);
// Check we don't get the promotion text.
- $this->assertNotContains($mobileappdownloadpage, quoted_printable_decode($email->body));
+ $this->assertStringNotContainsString($mobileappdownloadpage, quoted_printable_decode($email->body));
$sink->clear();
// Enable mobile again and set current user mobile token so we don't get mobile promotions.
$this->assertCount(1, $emails);
$email = reset($emails);
// Check we don't get the promotion text.
- $this->assertNotContains($mobileappdownloadpage, quoted_printable_decode($email->body));
+ $this->assertStringNotContainsString($mobileappdownloadpage, quoted_printable_decode($email->body));
$sink->clear();
$sink->close();
}
$this->assertEquals('Google', $identityproviders[0]['name']);
$this->assertEquals($irecord->image, $identityproviders[0]['iconurl']);
- $this->assertContains($CFG->wwwroot, $identityproviders[0]['url']);
+ $this->assertStringContainsString($CFG->wwwroot, $identityproviders[0]['url']);
$this->assertEquals('CAS', $identityproviders[1]['name']);
$this->assertEmpty($identityproviders[1]['iconurl']);
- $this->assertContains($CFG->wwwroot, $identityproviders[1]['url']);
+ $this->assertStringContainsString($CFG->wwwroot, $identityproviders[1]['url']);
$this->assertEquals($expected, $result);
set_config('auth_logo', $newurl, 'auth_cas');
$result = external::get_public_config();
$result = external_api::clean_returnvalue(external::get_public_config_returns(), $result);
- $this->assertContains($newurl, $result['identityproviders'][1]['iconurl']);
+ $this->assertStringContainsString($newurl, $result['identityproviders'][1]['iconurl']);
}
/**
/**
* Basic setup for these tests.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
}
/**
* Set up method.
*/
- public function setUp() {
+ public function setUp(): void {
// Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor');
}
$this->assertRegExp('~<h2>.*' . preg_quote($event->get_url()->out(), '~') . '.*</h2>~', $msg->fullmessagehtml);
$this->assertRegExp('~<li>.*' . preg_quote($modurl->out(), '~') . '.*</li>~', $msg->fullmessagehtml);
- $this->assertContains('<li><strong>'.$rule->get_name($context).'</strong></li>', $msg->fullmessagehtml);
- $this->assertContains('<li>'.$rule->get_description($context).'</li>', $msg->fullmessagehtml);
- $this->assertContains('<li>'.$rule->get_event_name().'</li>', $msg->fullmessagehtml);
+ $this->assertStringContainsString('<li><strong>'.$rule->get_name($context).'</strong></li>', $msg->fullmessagehtml);
+ $this->assertStringContainsString('<li>'.$rule->get_description($context).'</li>', $msg->fullmessagehtml);
+ $this->assertStringContainsString('<li>'.$rule->get_event_name().'</li>', $msg->fullmessagehtml);
$this->assertEquals(FORMAT_PLAIN, $msg->fullmessageformat);
- $this->assertNotContains('<h2>', $msg->fullmessage);
- $this->assertNotContains('##', $msg->fullmessage);
- $this->assertContains(strtoupper($event->get_url()->out()), $msg->fullmessage);
- $this->assertContains('* '.$modurl->out(), $msg->fullmessage);
- $this->assertContains('* '.strtoupper($rule->get_name($context)), $msg->fullmessage);
- $this->assertContains('* '.$rule->get_description($context), $msg->fullmessage);
- $this->assertContains('* '.$rule->get_event_name(), $msg->fullmessage);
+ $this->assertStringNotContainsString('<h2>', $msg->fullmessage);
+ $this->assertStringNotContainsString('##', $msg->fullmessage);
+ $this->assertStringContainsString(strtoupper($event->get_url()->out()), $msg->fullmessage);
+ $this->assertStringContainsString('* '.$modurl->out(), $msg->fullmessage);
+ $this->assertStringContainsString('* '.strtoupper($rule->get_name($context)), $msg->fullmessage);
+ $this->assertStringContainsString('* '.$rule->get_description($context), $msg->fullmessage);
+ $this->assertStringContainsString('* '.$rule->get_event_name(), $msg->fullmessage);
}
/**
/**
* Tests set up.
*/
- public function setUp() {
+ public function setUp(): void {
set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest();
}
/**
* Set up method.
*/
- public function setUp() {
+ public function setUp(): void {
// Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor');
}
$this->assertEquals(1, $historydata->userid);
$this->assertEquals(1, $historydata->sid);
}
-}
\ No newline at end of file
+}
/**
* Set up method.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest();
// Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor');
/**
* Set up method.
*/
- public function setUp() {
+ public function setUp(): void {
// Enable monitor.
set_config('enablemonitor', 1, 'tool_monitor');
}
$this->assertEmpty(array_diff(array_keys($ruledata), $ruleids));
$this->assertCount(10, $ruledata);
}
-}
\ No newline at end of file
+}
/**
* Test set up.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
// Create the mock subscription.
/**
* Test for the magic __get method.
- *
- * @expectedException coding_exception
*/
public function test_magic_get() {
$this->assertEquals(20, $this->subscription->courseid);
+ $this->expectException(coding_exception::class);
$this->subscription->ruleid;
}
}
/**
* Test set up.
*/
- public function setUp() {
+ public function setUp(): void {
global $DB;
set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest(true);