/.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,
$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'),
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'),
* 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);
}
/**
$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();
$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);
/**
* Test set up.
*/
- public function setUp() {
+ public function setUp(): void {
set_config('enablemonitor', 1, 'tool_monitor');
$this->resetAfterTest(true);
}
/**
* Setup function- we will create some policy docs.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
$this->setAdminUser();
/**
* Setup function. Will create a user.
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->resetAfterTest();
$generator = $this->getDataGenerator();
// Request export for the manager.
$contextlist = provider::get_contexts_for_userid($this->manager->id);
$this->assertCount(3, $contextlist);
- $this->assertEquals(
+ $this->assertEqualsCanonicalizing(
[$managercontext->id, $usercontext->id, $systemcontext->id],
- $contextlist->get_contextids(),
- '',
- 0.0,
- 1,
- true
+ $contextlist->get_contextids()
);
$approvedcontextlist = new approved_contextlist($this->user, 'tool_policy', [$usercontext->id]);
// Agree to the policies for oneself.
$contextlist = provider::get_contexts_for_userid($this->manager->id);
$this->assertCount(2, $contextlist);
- $this->assertEquals([$managercontext->id, $systemcontext->id], $contextlist->get_contextids(), '', 0.0, 1, true);
+ $this->assertEqualsCanonicalizing([$managercontext->id, $systemcontext->id], $contextlist->get_contextids());
$approvedcontextlist = new approved_contextlist($this->manager, 'tool_policy', $contextlist->get_contextids());
provider::export_user_data($approvedcontextlist);
/**
* Setup for each test.
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->resetAfterTest();
$this->setAdminUser();
/**
* Setup for each test.
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->resetAfterTest(true);
$this->setAdminUser();
*
* This is executed before running any test in this file.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest();
// We want the category and course bin to be enabled.
$template = external::load_canonical_template('core', 'notification_error');
// Only the base template should contain the docs.
- $this->assertContains('@template core/notification_error', $template);
+ $this->assertStringContainsString('@template core/notification_error', $template);
// Restore the original theme.
$CFG->theme = $originaltheme;
*/
class tool_uploadcourse_course_testcase extends advanced_testcase {
- /**
- * @expectedException coding_exception
- */
public function test_proceed_without_prepare() {
$this->resetAfterTest(true);
$mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
$updatemode = tool_uploadcourse_processor::UPDATE_NOTHING;
$data = array();
$co = new tool_uploadcourse_course($mode, $updatemode, $data);
+ $this->expectException(coding_exception::class);
$co->proceed();
}
- /**
- * @expectedException moodle_exception
- */
public function test_proceed_when_prepare_failed() {
$this->resetAfterTest(true);
$mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
$data = array();
$co = new tool_uploadcourse_course($mode, $updatemode, $data);
$this->assertFalse($co->prepare());
+ $this->expectException(moodle_exception::class);
$co->proceed();
}
// Confirm presence of course custom fields.
$data = \core_course\customfield\course_handler::create()->export_instance_data_object($course->id);
- $this->assertEquals('Wednesday, 1 April 2020, 4:00 PM', $data->mydatefield, '', 0.0, 10, false, true);
+ $this->assertEqualsIgnoringCase('Wednesday, 1 April 2020, 4:00 PM', $data->mydatefield);
$this->assertEquals($dataupload['customfield_mytextfield'], $data->mytextfield);
- $this->assertContains($dataupload['customfield_mytextareafield'], $data->mytextareafield);
+ $this->assertStringContainsString($dataupload['customfield_mytextareafield'], $data->mytextareafield);
}
/**
'configdata' => $configdata,
]);
}
-}
\ No newline at end of file
+}
$this->assertEquals('ID123: Course 1', $c->shortname);
}
- /**
- * @expectedException moodle_exception
- */
public function test_empty_csv() {
$this->resetAfterTest(true);
$cir->init();
$options = array('mode' => tool_uploadcourse_processor::MODE_CREATE_NEW);
+ $this->expectException(moodle_exception::class);
$p = new tool_uploadcourse_processor($cir, $options, array());
}
- /**
- * @expectedException moodle_exception
- */
public function test_not_enough_columns() {
$this->resetAfterTest(true);
$cir->init();
$options = array('mode' => tool_uploadcourse_processor::MODE_CREATE_NEW);
+ $this->expectException(moodle_exception::class);
$p = new tool_uploadcourse_processor($cir, $options, array());
}
*/
class tool_usertours_accessdate_filter_test extends advanced_testcase {
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
}
$tour = $this->helper_create_tour((object)['enabled' => false]);
$data = \tool_usertours\cache::get_stepdata($tour->get_id());
- $this->assertInternalType('array', $data);
+ $this->assertIsArray($data);
$this->assertEmpty($data);
}
$tour2 = $this->helper_create_tour((object)['enabled' => false]);
$data = \tool_usertours\cache::get_stepdata($tour1->get_id());
- $this->assertInternalType('array', $data);
+ $this->assertIsArray($data);
$this->assertCount(3, $data);
$data = \tool_usertours\cache::get_stepdata($tour2->get_id());
- $this->assertInternalType('array', $data);
+ $this->assertIsArray($data);
$this->assertEmpty($data);
}
$steps[0]->set_sortorder(10)->persist();
$data = \tool_usertours\cache::get_stepdata($tour->get_id());
- $this->assertInternalType('array', $data);
+ $this->assertIsArray($data);
$this->assertCount(4, $data);
// Re-order the steps.
/**
* Setup to store the DB reference.
*/
- public function setUp() {
+ public function setUp(): void {
global $DB;
$this->db = $DB;
/**
* Tear down to restore the original DB reference.
*/
- public function tearDown() {
+ public function tearDown(): void {
global $DB;
$DB = $this->db;
$this->assertCount(1, (array) $prefs);
// The preference should be related to the first tour.
- $this->assertContains($tour1->get_name(), reset($prefs)->description);
+ $this->assertStringContainsString($tour1->get_name(), reset($prefs)->description);
}
}
*/
protected $roles;
- public function setUp() {
+ public function setUp(): void {
global $DB;
$this->resetAfterTest(true);
/**
* Setup to store the DB reference.
*/
- public function setUp() {
+ public function setUp(): void {
global $DB;
$this->db = $DB;
/**
* Tear down to restore the original DB reference.
*/
- public function tearDown() {
+ public function tearDown(): void {
global $DB;
$DB = $this->db;
/**
* Setup to store the DB reference.
*/
- public function setUp() {
+ public function setUp(): void {
global $DB;
$this->db = $DB;
/**
* Tear down to restore the original DB reference.
*/
- public function tearDown() {
+ public function tearDown(): void {
global $DB;
$DB = $this->db;
$prediction->get_prediction_data()->contextid, $prediction->get_sample_data());
}
+ /**
+ * Returns the default output directory for prediction processors
+ *
+ * @return string
+ */
+ public static function default_output_dir(): string {
+ global $CFG;
+
+ return $CFG->dataroot . DIRECTORY_SEPARATOR . 'models';
+ }
+
/**
* Returns the output directory for prediction processors.
*
* @return string
*/
public function get_output_dir($subdirs = array(), $onlymodelid = false) {
- global $CFG;
-
$subdirstr = '';
foreach ($subdirs as $subdir) {
$subdirstr .= DIRECTORY_SEPARATOR . $subdir;
$outputdir = get_config('analytics', 'modeloutputdir');
if (empty($outputdir)) {
// Apply default value.
- $outputdir = rtrim($CFG->dataroot, '/') . DIRECTORY_SEPARATOR . 'models';
+ $outputdir = self::default_output_dir();
}
// Append model id.
*/
class core_analytics_course_testcase extends advanced_testcase {
- public function setUp() {
+ public function setUp(): void {
global $DB;
$this->course = $this->getDataGenerator()->create_course(['startdate' => 0]);
*
* @return null
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
$this->sharedtoprows = array(
$f1 = $dataset1->store($dataset1data);
$f1contents = $f1->get_content();
- $this->assertContains('yeah', $f1contents);
- $this->assertContains('var1', $f1contents);
- $this->assertContains('value1', $f1contents);
- $this->assertContains('header1', $f1contents);
+ $this->assertStringContainsString('yeah', $f1contents);
+ $this->assertStringContainsString('var1', $f1contents);
+ $this->assertStringContainsString('value1', $f1contents);
+ $this->assertStringContainsString('header1', $f1contents);
}
/**
\core_analytics\dataset_manager::LABELLED_FILEAREA);
$mergedfilecontents = $merged->get_content();
- $this->assertContains('yeah', $mergedfilecontents);
- $this->assertContains('no', $mergedfilecontents);
- $this->assertContains('var1', $mergedfilecontents);
- $this->assertContains('value1', $mergedfilecontents);
- $this->assertContains('header1', $mergedfilecontents);
+ $this->assertStringContainsString('yeah', $mergedfilecontents);
+ $this->assertStringContainsString('no', $mergedfilecontents);
+ $this->assertStringContainsString('var1', $mergedfilecontents);
+ $this->assertStringContainsString('value1', $mergedfilecontents);
+ $this->assertStringContainsString('header1', $mergedfilecontents);
}
/**
* @param string $indicatorclass
* @param string $willreturn
* @dataProvider validate_calculated_value_exceptions
- * @expectedException \coding_exception
* @return null
*/
public function test_validate_calculated_value_exceptions($indicatorclass, $willreturn) {
->setMethods(['calculate_sample'])
->getMock();
$indicatormock->method('calculate_sample')->willReturn($willreturn);
+ $this->expectException(coding_exception::class);
list($values, $unused) = $indicatormock->calculate([1], 'notrelevanthere');
}
*/
class analytics_model_testcase extends advanced_testcase {
- public function setUp() {
+ public function setUp(): void {
$this->setAdminUser();
$modeldata = $method->invoke($modelconfig);
$this->assertArrayHasKey('core', $modeldata->dependencies);
- $this->assertInternalType('float', $modeldata->dependencies['core']);
+ $this->assertIsFloat($modeldata->dependencies['core']);
$this->assertNotEmpty($modeldata->target);
$this->assertNotEmpty($modeldata->timesplitting);
$this->assertCount(3, $modeldata->indicators);
/**
* Common startup tasks
*/
- public function setUp() {
+ public function setUp(): void {
global $DB;
$this->setAdminUser();
*
* @return null
*/
- public function tearDown() {
+ public function tearDown(): void {
$this->setAdminUser();
$models = \core_analytics\manager::get_all_models();
*/
class core_analytics_privacy_model_testcase extends \core_privacy\tests\provider_testcase {
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
$this->setAdminUser();
/**
* Set up the test environment.
*/
- public function setUp() {
+ public function setUp(): void {
$this->setAdminUser();
}
/**
* Set up for every test
*/
- public function setUp() {
+ public function setUp(): void {
global $CFG, $DB;
$this->resetAfterTest(true);
/**
* Setup test data.
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->resetAfterTest(true);
$this->authplugin = new auth_plugin_manual();
set_config('expiration', '1', 'auth_manual');
/**
* Basic setup for these tests.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest(true);
$this->authplugin = new auth_plugin_manual();
}
/**
* Set up method.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest();
$this->setAdminUser();
}
$auth = get_auth_plugin($user->auth);
$info = $auth->get_password_change_info($user);
- $this->assertEquals(
- ['subject', 'message'],
- array_keys($info),
- '', 0.0, 10, true);
- $this->assertContains(
+ $this->assertEqualsCanonicalizing(['subject', 'message'], array_keys($info));
+ $this->assertStringContainsString(
'your password cannot be reset because you are using your account on another site to log in',
$info['message']);
}
-}
\ No newline at end of file
+}
/**
* Set up method.
*/
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest();
$this->setAdminUser();
}
/**
* Set up for every test
*/
- public function setUp() {
+ public function setUp(): void {
global $CFG;
$this->resetAfterTest(true);
/**
* Tear down to restore old logging..
*/
- protected function tearDown() {
+ protected function tearDown(): void {
ini_set('error_log', $this->oldlog);
parent::tearDown();
}
*/
class core_auth_privacy_testcase extends provider_testcase {
- public function setUp() {
+ public function setUp(): void {
$this->resetAfterTest();
}
/**
* Load required classes.
*/
- public function setUp() {
+ public function setUp(): void {
availability_completion\condition::wipe_static_cache();
}
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->cm', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->cm', $e->getMessage());
}
// Invalid $cm.
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->cm', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->cm', $e->getMessage());
}
// Missing $e.
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->e', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->e', $e->getMessage());
}
// Invalid $e.
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->e', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->e', $e->getMessage());
}
// Successful construct & display with all different expected values.
/**
* Load required classes.
*/
- public function setUp() {
+ public function setUp(): void {
// Load the mock info class so that it can be used.
global $CFG;
require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php');
$date = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->d', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->d', $e->getMessage());
}
// Invalid ->d.
$date = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->d', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->d', $e->getMessage());
}
// Missing ->t.
$date = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->t', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->t', $e->getMessage());
}
// Invalid ->t.
$date = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->t', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->t', $e->getMessage());
}
// Valid conditions of both types.
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->id', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->id', $e->getMessage());
}
// Invalid id (not int).
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->id', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->id', $e->getMessage());
}
// Invalid min (not number).
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->min', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->min', $e->getMessage());
}
// Invalid max (not number).
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->max', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->max', $e->getMessage());
}
// All valid.
/**
* Load required classes.
*/
- public function setUp() {
+ public function setUp(): void {
// Load the mock info class so that it can be used.
global $CFG;
require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php');
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Invalid ->id', $e->getMessage());
+ $this->assertStringContainsString('Invalid ->id', $e->getMessage());
}
// Valid (with id).
/**
* Load required classes.
*/
- public function setUp() {
+ public function setUp(): void {
// Load the mock info class so that it can be used.
global $CFG;
require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php');
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing ->id / ->activity', $e->getMessage());
+ $this->assertStringContainsString('Missing ->id / ->activity', $e->getMessage());
}
// Invalid id (not int).
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Invalid ->id', $e->getMessage());
+ $this->assertStringContainsString('Invalid ->id', $e->getMessage());
}
// Invalid activity option (not bool).
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Invalid ->activity', $e->getMessage());
+ $this->assertStringContainsString('Invalid ->activity', $e->getMessage());
}
// Invalid activity option (false).
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Invalid ->activity', $e->getMessage());
+ $this->assertStringContainsString('Invalid ->activity', $e->getMessage());
}
// Valid with id.
/** @var \core_availability\info Current info */
private $info;
- public function setUp() {
+ public function setUp(): void {
global $DB, $CFG;
$this->resetAfterTest();
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->op', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->op', $e->getMessage());
}
// Invalid op.
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->op', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->op', $e->getMessage());
}
// Missing value.
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->v', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->v', $e->getMessage());
}
// Invalid value (not string).
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Missing or invalid ->v', $e->getMessage());
+ $this->assertStringContainsString('Missing or invalid ->v', $e->getMessage());
}
// Unexpected value.
$cond = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
- $this->assertContains('Unex