diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php
index b1651797d04..b909276550d 100644
--- a/course/tests/externallib_test.php
+++ b/course/tests/externallib_test.php
@@ -37,8 +37,7 @@ require_once($CFG->dirroot . '/webservice/tests/helpers.php');
* @copyright 2012 Jerome Mouneyrac
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class externallib_test extends externallib_advanced_testcase {
- //core_course_externallib_testcase
+final class externallib_test extends externallib_advanced_testcase {
/**
* Tests set up
@@ -598,7 +597,7 @@ class externallib_test extends externallib_advanced_testcase {
*
* @return array
*/
- public function course_empty_field_provider(): array {
+ public static function course_empty_field_provider(): array {
return [
[[
'fullname' => '',
@@ -3092,7 +3091,7 @@ class externallib_test extends externallib_advanced_testcase {
/**
* Test cases for the get_enrolled_courses_by_timeline_classification test.
*/
- public function get_get_enrolled_courses_by_timeline_classification_test_cases():array {
+ public static function get_get_enrolled_courses_by_timeline_classification_test_cases(): array {
$now = time();
$day = 86400;
@@ -3349,16 +3348,6 @@ class externallib_test extends externallib_advanced_testcase {
'expectednextoffset' => 0,
'expectedexception' => 'Invalid $sort parameter in enrol_get_my_courses()',
],
- 'all limit and offset with wrong sort direction' => [
- 'coursedata' => $coursedata,
- 'classification' => 'all',
- 'limit' => 5,
- 'offset' => 5,
- 'sort' => "ul.timeaccess abcdasc",
- 'expectedcourses' => [],
- 'expectednextoffset' => 0,
- 'expectedexception' => 'Invalid sort direction in $sort parameter in enrol_get_my_courses()',
- ],
'all limit and offset with wrong sort direction' => [
'coursedata' => $coursedata,
'classification' => 'all',
@@ -3379,16 +3368,6 @@ class externallib_test extends externallib_advanced_testcase {
'expectednextoffset' => 0,
'expectedexception' => 'Invalid $sort parameter in enrol_get_my_courses()',
],
- 'all limit and offset with wrong field name' => [
- 'coursedata' => $coursedata,
- 'classification' => 'all',
- 'limit' => 5,
- 'offset' => 5,
- 'sort' => "ul.foobar",
- 'expectedcourses' => [],
- 'expectednextoffset' => 0,
- 'expectedexception' => 'Invalid $sort parameter in enrol_get_my_courses()',
- ],
'all limit and offset with wrong field separator' => [
'coursedata' => $coursedata,
'classification' => 'all',
diff --git a/enrol/lti/tests/local/ltiadvantage/entity/user_test.php b/enrol/lti/tests/local/ltiadvantage/entity/user_test.php
index ae594f9c8ce..0e8fbb6ff33 100644
--- a/enrol/lti/tests/local/ltiadvantage/entity/user_test.php
+++ b/enrol/lti/tests/local/ltiadvantage/entity/user_test.php
@@ -24,7 +24,7 @@ namespace enrol_lti\local\ltiadvantage\entity;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass \enrol_lti\local\ltiadvantage\entity\user
*/
-class user_test extends \advanced_testcase {
+final class user_test extends \advanced_testcase {
/**
* Test creation of a user instance using the factory method.
@@ -64,7 +64,7 @@ class user_test extends \advanced_testcase {
*
* @return array the data for testing.
*/
- public function create_data_provider(): array {
+ public static function create_data_provider(): array {
global $CFG;
return [
'Valid create, only required args provided' => [
@@ -272,7 +272,7 @@ class user_test extends \advanced_testcase {
*
* @return array the data for testing.
*/
- public function create_from_resource_link_data_provider(): array {
+ public static function create_from_resource_link_data_provider(): array {
global $CFG;
return [
'Valid creation, all args provided explicitly' => [
@@ -511,7 +511,7 @@ class user_test extends \advanced_testcase {
*
* @return array the array of test data.
*/
- public function setters_getters_data_provider(): array {
+ public static function setters_getters_data_provider(): array {
global $CFG;
return [
'Testing set_resourcelinkid with valid id' => [
@@ -620,12 +620,12 @@ class user_test extends \advanced_testcase {
],
'Testing set_maildisplay with a valid int: 2' => [
'methodname' => 'maildisplay',
- 'arg' => '1',
+ 'arg' => '2',
'expectations' => [
'valid' => true,
]
],
- 'Testing set_maildisplay with invalid int' => [
+ 'Testing set_maildisplay with invalid int: -1' => [
'methodname' => 'maildisplay',
'arg' => '-1',
'expectations' => [
@@ -634,7 +634,7 @@ class user_test extends \advanced_testcase {
'exceptionmessage' => "Invalid maildisplay value '-1'. Must be in the range {0..2}."
]
],
- 'Testing set_maildisplay with invalid int' => [
+ 'Testing set_maildisplay with invalid int: 3' => [
'methodname' => 'maildisplay',
'arg' => '3',
'expectations' => [
@@ -659,7 +659,7 @@ class user_test extends \advanced_testcase {
'exceptionmessage' => 'Invalid lang value. Cannot be an empty string.'
]
],
- 'Testing set_lang with an empty string' => [
+ 'Testing set_lang with invalid lang code' => [
'methodname' => 'lang',
'arg' => 'ff',
'expectations' => [
diff --git a/enrol/tests/externallib_test.php b/enrol/tests/externallib_test.php
index db511e5258d..9319d5002cd 100644
--- a/enrol/tests/externallib_test.php
+++ b/enrol/tests/externallib_test.php
@@ -37,12 +37,12 @@ require_once($CFG->dirroot . '/enrol/externallib.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.4
*/
-class externallib_test extends externallib_advanced_testcase {
+final class externallib_test extends externallib_advanced_testcase {
/**
* dataProvider for test_get_enrolled_users_visibility().
*/
- public function get_enrolled_users_visibility_provider() {
+ public static function get_enrolled_users_visibility_provider(): array {
return array(
'Course without groups, default behavior (not filtering by cap, group, active)' =>
array(
@@ -231,7 +231,7 @@ class externallib_test extends externallib_advanced_testcase {
),
),
- 'Course with separate groups, filtering by withcapability (having moodle/role:review)' =>
+ 'Course with separate groups, filtering by withcapability (having moodle/role:review & moodle/course:bulkmessaging)' =>
array(
'settings' => array(
'coursegroupmode' => SEPARATEGROUPS,
@@ -1106,7 +1106,7 @@ class externallib_test extends externallib_advanced_testcase {
/**
* dataProvider for test_submit_user_enrolment_form().
*/
- public function submit_user_enrolment_form_provider() {
+ public static function submit_user_enrolment_form_provider(): array {
$now = new \DateTime();
$nextmonth = clone($now);
diff --git a/filter/multilang/tests/filter_test.php b/filter/multilang/tests/filter_test.php
index e00ea99af52..30dad039ff0 100644
--- a/filter/multilang/tests/filter_test.php
+++ b/filter/multilang/tests/filter_test.php
@@ -14,26 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+namespace filter_multilang;
+
/**
- * Unit tests.
+ * Tests for filter_multilang.
*
* @package filter_multilang
* @category test
* @copyright 2019 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-
-namespace filter_multilang;
-
-use filter_multilang;
-
-/**
- * Tests for filter_multilang.
- *
- * @copyright 2019 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class filter_test extends \advanced_testcase {
+final class filter_test extends \advanced_testcase {
public function setUp(): void {
parent::setUp();
@@ -62,7 +53,7 @@ class filter_test extends \advanced_testcase {
/**
* Data provider for multi-language filtering tests.
*/
- public function multilang_testcases() {
+ public static function multilang_testcases(): array {
return [
'Basic case EN' => [
'English',
@@ -79,7 +70,7 @@ class filter_test extends \advanced_testcase {
'FrançaisEnglish',
'en',
],
- 'Reversed input order EN' => [
+ 'Reversed input order FR' => [
'Français',
'FrançaisEnglish',
'fr',
diff --git a/filter/urltolink/tests/filter_test.php b/filter/urltolink/tests/filter_test.php
index 48e87668192..28175e19224 100644
--- a/filter/urltolink/tests/filter_test.php
+++ b/filter/urltolink/tests/filter_test.php
@@ -14,14 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-/**
- * Unit test for the filter_urltolink
- *
- * @package filter_urltolink
- * @category phpunit
- * @copyright 2010 David Mudrak
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
namespace filter_urltolink;
@@ -32,10 +24,22 @@ defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/filter/urltolink/filter.php'); // Include the code to test
+/**
+ * Unit test for the filter_urltolink
+ *
+ * @package filter_urltolink
+ * @category test
+ * @copyright 2010 David Mudrak
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+final class filter_test extends \basic_testcase {
-class filter_test extends \basic_testcase {
-
- function get_convert_urls_into_links_test_cases() {
+ /**
+ * Data provider for {@see test_convert_urls_into_links}
+ *
+ * @return array
+ */
+ public static function get_convert_urls_into_links_test_cases(): array {
// Create a 4095 and 4096 long URLs.
$superlong4095 = str_pad('http://www.superlong4095.com?this=something', 4095, 'a');
$superlong4096 = str_pad('http://www.superlong4096.com?this=something', 4096, 'a');
@@ -165,7 +169,6 @@ class filter_test extends \basic_testcase {
'URL: my link to http://google.com ' => 'URL: my link to http://google.com',
// Nested tags test.
'www.google.com' => 'www.google.com',
- '' => '',
// Test realistic content.
'
Lorem ipsum amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut http://google.com aliquip ex ea commodo consequat. Duis aute irure in reprehenderit in excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing mollit anim id est laborum.
'
=>
diff --git a/grade/report/history/tests/report_test.php b/grade/report/history/tests/report_test.php
index d10e101484a..75d14ab460b 100644
--- a/grade/report/history/tests/report_test.php
+++ b/grade/report/history/tests/report_test.php
@@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2014 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class report_test extends \advanced_testcase {
+final class report_test extends \advanced_testcase {
/**
* Create some grades.
@@ -251,7 +251,7 @@ class report_test extends \advanced_testcase {
*
* @return array List of data sets (test cases)
*/
- public function get_users_with_profile_fields_provider(): array {
+ public static function get_users_with_profile_fields_provider(): array {
return [
// User identity check boxes, 'email', 'profile_field_lang' and 'profile_field_height' are checked.
'show email,lang and height;search for all users' =>
@@ -264,24 +264,18 @@ class report_test extends \advanced_testcase {
['email,profile_field_lang,profile_field_height', '.uk', ['u3']],
'show email,lang and height,search for Spanish speakers' =>
['email,profile_field_lang,profile_field_height', 'spanish', ['u1', 'u4']],
- 'show email,lang and height,search for Spanish speakers' =>
+ 'show email,lang and height,search for Spanish speakers (using spa)' =>
['email,profile_field_lang,profile_field_height', 'spa', ['u1', 'u4']],
'show email,lang and height,search for German speakers' =>
['email,profile_field_lang,profile_field_height', 'german', ['u2']],
- 'show email,lang and height,search for German speakers' =>
+ 'show email,lang and height,search for German speakers (using ger)' =>
['email,profile_field_lang,profile_field_height', 'ger', ['u2']],
'show email,lang and height,search for English speakers' =>
['email,profile_field_lang,profile_field_height', 'english', ['u3']],
- 'show email,lang and height,search for English speakers' =>
+ 'show email,lang and height,search for English speakers (using eng)' =>
['email,profile_field_lang,profile_field_height', 'eng', ['u3']],
- 'show email,lang and height,search for English speakers' =>
- ['email,profile_field_lang,profile_field_height', 'ish', ['u3']],
- 'show email,lang and height,search for users with height 180cm' =>
- ['email,profile_field_lang,profile_field_height', '180cm', ['u2', 'u3', 'u4']],
'show email,lang and height,search for users with height 180cm' =>
['email,profile_field_lang,profile_field_height', '180', ['u2', 'u3', 'u4']],
- 'show email,lang and height,search for users with height 170cm' =>
- ['email,profile_field_lang,profile_field_height', '170cm', ['u1']],
'show email,lang and height,search for users with height 170cm' =>
['email,profile_field_lang,profile_field_height', '170', ['u1']],
@@ -292,25 +286,15 @@ class report_test extends \advanced_testcase {
['email,profile_field_height', '.com', []],
'show email and height;search for users on .co' =>
['email,profile_field_height', '.co', ['u3']],
- 'show email and height,search for Spanish/German/English speakers' =>
+ 'show email and height,search for Spanish speakers' =>
['email,profile_field_height', 'spanish', []],
- 'show email and height,search for Spanish/German/English speakers' =>
+ 'show email and height,search for German speakers' =>
['email,profile_field_height', 'german', []],
- 'show email and height,search for Spanish/German/English speakers' =>
- ['email,profile_field_height', 'english', []],
- 'show email,lang and height,search for English speakers' =>
- ['email,profile_field_height', 'english', []],
'show email and height,search for English speakers' =>
- ['email,profile_field_height', 'eng', []],
- 'show email and height,search for English speakers' =>
- ['email,profile_field_height', 'ish', []],
+ ['email,profile_field_height', 'english', []],
'show email and height,search for users with height 180cm' =>
- ['email,profile_field_height', '180cm', ['u2', 'u3', 'u4']],
- 'show email,lang and height,search for users with height 180cm' =>
['email,profile_field_height', '180', ['u2', 'u3', 'u4']],
- 'show email,lang and height,search for users with height 170cm' =>
- ['email,profile_field_height', '170cm', ['u1']],
- 'show email,lang and height,search for users with height 170cm' =>
+ 'show email and height,search for users with height 170cm' =>
['email,profile_field_height', '170', ['u1']],
// User identity check boxes, only 'email' is checked.
@@ -322,9 +306,7 @@ class report_test extends \advanced_testcase {
'show email only;search for Spanish speakers' => ['email', 'spanish', []],
'show email only;search for German speakers' => ['email', 'german', []],
'show email only;search for English speakers' => ['email', 'english', []],
- 'show email only;search for users with height 180cm' => ['email', '180cm', []],
'show email only;search for users with height 180cm' => ['email', '180', []],
- 'show email only;search for users with height 170cm' => ['email', '170cm', []],
'show email only;search for users with height 170cm' => ['email', '170', []],
];
}
@@ -401,7 +383,7 @@ class report_test extends \advanced_testcase {
/**
* Data provider method for \gradereport_history_report_testcase::test_get_users_with_groups()
*/
- public function get_users_provider() {
+ public static function get_users_provider(): array {
return [
'Visible groups, non-editing teacher, not in any group' => [
VISIBLEGROUPS, 'teacher', ['g1', 'g2'], ['s1', 's2', 's3', 's4', 's5']
diff --git a/lib/editor/tinymce/tests/editor_test.php b/lib/editor/tinymce/tests/editor_test.php
index a60d9ed7072..e52325fb7b2 100644
--- a/lib/editor/tinymce/tests/editor_test.php
+++ b/lib/editor/tinymce/tests/editor_test.php
@@ -14,15 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-/**
- * TinyMCE tests.
- *
- * @package editor_tinymce
- * @category test
- * @copyright 2012 Petr Skoda {@link http://skodak.org}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
namespace editor_tinymce;
use editor_tinymce_plugin;
@@ -38,7 +29,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class editor_test extends \advanced_testcase {
+final class editor_test extends \advanced_testcase {
public function test_autoloading() {
// Note: This test core_frankestyle calssloader.
@@ -79,7 +70,6 @@ class editor_test extends \advanced_testcase {
'gecko_spellcheck' => true,
'theme_advanced_font_sizes' => "1,2,3,4,5,6,7",
'moodle_plugin_base' => "$CFG->wwwroot/lib/editor/tinymce/plugins/",
- 'theme_advanced_font_sizes' => "1,2,3,4,5,6,7",
'theme_advanced_layout_manager' => "SimpleLayout",
'theme_advanced_buttons1' => 'one,two,|,three,four',
'theme_advanced_buttons2' => 'five,six',
diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php
index ccaa3f6bdcb..081adc996c0 100644
--- a/lib/tests/moodlelib_test.php
+++ b/lib/tests/moodlelib_test.php
@@ -27,7 +27,7 @@ use lang_string;
* @author T.J.Hunt@open.ac.uk
* @author nicolas@moodle.com
*/
-class moodlelib_test extends \advanced_testcase {
+final class moodlelib_test extends \advanced_testcase {
/**
* Define a local decimal separator.
@@ -860,13 +860,15 @@ class moodlelib_test extends \advanced_testcase {
'-13.5' => '',
'0.2' => '',
'' => '',
- null => '',
);
foreach ($testvalues as $testvalue => $expectedvalue) {
$actualvalue = clean_param($testvalue, PARAM_TIMEZONE);
$this->assertEquals($expectedvalue, $actualvalue);
}
+
+ // Test for null.
+ $this->assertEquals('', clean_param(null, PARAM_TIMEZONE));
}
public function test_clean_param_null_argument() {
@@ -3712,9 +3714,9 @@ EOF;
/**
* Data provider for test_generate_confirmation_link
- * @return Array of confirmation urls and expected resultant confirmation links
+ * @return array Confirmation urls and expected resultant confirmation links
*/
- public function generate_confirmation_link_provider() {
+ public static function generate_confirmation_link_provider(): array {
global $CFG;
return [
"Simple name" => [
@@ -3782,7 +3784,7 @@ EOF;
"confirmationurl" => "http://moodle.org/ext.php?with=some¶m=eters",
"expected" => "http://moodle.org/ext.php?with=some¶m=eters&data=/many_-%2E%40characters%40_%40-%2E%2E-%2E%2E"
],
- "Custom external confirmation url with parameters" => [
+ "Custom external confirmation url with parameters (again)" => [
"username" => "many_-.@characters@_@-..-..",
"confirmationurl" => "http://moodle.org/ext.php?with=some&data=test",
"expected" => "http://moodle.org/ext.php?with=some&data=/many_-%2E%40characters%40_%40-%2E%2E-%2E%2E"
diff --git a/mod/chat/tests/dates_test.php b/mod/chat/tests/dates_test.php
index 86a19b1bde0..ac6eebd2941 100644
--- a/mod/chat/tests/dates_test.php
+++ b/mod/chat/tests/dates_test.php
@@ -14,15 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-/**
- * Contains unit tests for mod_chat\dates.
- *
- * @package mod_chat
- * @category test
- * @copyright 2021 Dongsheng Cai
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
declare(strict_types=1);
namespace mod_chat;
@@ -33,14 +24,19 @@ use core\activity_dates;
/**
* Class for unit testing mod_chat\dates.
+ *
+ * @package mod_chat
+ * @category test
+ * @copyright 2021 Dongsheng Cai
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class dates_test extends advanced_testcase {
+final class dates_test extends advanced_testcase {
/**
* Data provider for get_dates_for_module().
* @return array[]
*/
- public function get_dates_for_module_provider(): array {
+ public static function get_dates_for_module_provider(): array {
global $CFG;
require_once($CFG->dirroot . '/mod/chat/lib.php');
@@ -52,10 +48,10 @@ class dates_test extends advanced_testcase {
$weeklynextchattime = $past + 7 * DAYSECS;
$label = get_string('nextchattime', 'mod_chat');
return [
- 'chattime in the past' => [
+ 'chattime in the past (no schedule)' => [
$past, CHAT_SCHEDULE_NONE, []
],
- 'chattime in the past' => [
+ 'chattime in the past (single schedule)' => [
$past, CHAT_SCHEDULE_SINGLE, []
],
'chattime in the future' => [
diff --git a/mod/feedback/tests/external/external_test.php b/mod/feedback/tests/external/external_test.php
index 67242cb3d1d..9d99dfa0948 100644
--- a/mod/feedback/tests/external/external_test.php
+++ b/mod/feedback/tests/external/external_test.php
@@ -14,16 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-/**
- * Feedback module external functions tests
- *
- * @package mod_feedback
- * @category external
- * @copyright 2017 Juan Leyva
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since Moodle 3.3
- */
-
namespace mod_feedback\external;
use externallib_advanced_testcase;
@@ -48,7 +38,7 @@ require_once($CFG->dirroot . '/mod/feedback/lib.php');
* @since Moodle 3.3
* @covers \mod_feedback_external
*/
-class external_test extends externallib_advanced_testcase {
+final class external_test extends externallib_advanced_testcase {
// TODO These should be removed.
// Testcase classes should not have any properties or store state.
@@ -458,7 +448,7 @@ class external_test extends externallib_advanced_testcase {
*
* @return array
*/
- public function items_provider(): array {
+ public static function items_provider(): array {
return [
'Valid feedback (as student)' => [
'role' => 'student',
@@ -475,11 +465,6 @@ class external_test extends externallib_advanced_testcase {
'info' => ['empty' => true],
'warning' => get_string('no_items_available_yet', 'feedback'),
],
- 'Closed feedback (as student)' => [
- 'role' => 'student',
- 'info' => ['closed' => true],
- 'warning' => get_string('feedback_is_not_open', 'feedback'),
- ],
'Cannot complete feedback (as student)' => [
'role' => 'student',
'info' => ['complete' => false],
@@ -500,11 +485,6 @@ class external_test extends externallib_advanced_testcase {
'info' => ['empty' => true],
'warning' => null,
],
- 'Closed feedback (as teacher)' => [
- 'role' => 'teacher',
- 'info' => ['closed' => true],
- 'warning' => null,
- ],
'Cannot complete feedback (as teacher)' => [
'role' => 'teacher',
'info' => ['complete' => false],
diff --git a/mod/h5pactivity/tests/generator_test.php b/mod/h5pactivity/tests/generator_test.php
index 5e67438bc2d..17fd78f17ba 100644
--- a/mod/h5pactivity/tests/generator_test.php
+++ b/mod/h5pactivity/tests/generator_test.php
@@ -26,7 +26,7 @@ use mod_h5pactivity\local\manager;
* @copyright 2020 Ferran Recio
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class generator_test extends \advanced_testcase {
+final class generator_test extends \advanced_testcase {
/**
* Test on H5P activity creation.
@@ -158,7 +158,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
- public function create_attempt_data(): array {
+ public static function create_attempt_data(): array {
return [
'Compound statement' => [
[
@@ -224,14 +224,6 @@ class generator_test extends \advanced_testcase {
],
], 1, 1, false,
],
- 'Other statement' => [
- [
- [
- 'interactiontype' => 'other', 'attempt' => 1, 'rawscore' => 2,
- 'maxscore' => 2, 'duration' => 1, 'completion' => 1, 'success' => 0
- ],
- ], 1, 1, false,
- ],
'No graded statement' => [
[
[
@@ -351,7 +343,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
- public function create_attempt_exceptions_data(): array {
+ public static function create_attempt_exceptions_data(): array {
return [
'Invalid user' => [true, false],
'Invalid activity' => [false, true],
diff --git a/mod/h5pactivity/tests/xapi/handler_test.php b/mod/h5pactivity/tests/xapi/handler_test.php
index 481a9383178..67d9fbed87a 100644
--- a/mod/h5pactivity/tests/xapi/handler_test.php
+++ b/mod/h5pactivity/tests/xapi/handler_test.php
@@ -43,7 +43,7 @@ use stdClass;
* @copyright 2020 Ferran Recio
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class handler_test extends \advanced_testcase {
+final class handler_test extends \advanced_testcase {
/**
* Generate a valid scenario for each tests.
@@ -202,7 +202,7 @@ class handler_test extends \advanced_testcase {
*
* @return array
*/
- public function xapi_handler_errors_data(): array {
+ public static function xapi_handler_errors_data(): array {
return [
// Invalid Definitions and results possibilities.
'Invalid definition and result' => [
@@ -221,17 +221,17 @@ class handler_test extends \advanced_testcase {
'Invalid verb and result' => [
false, true, false, true, true, false
],
- 'Invalid verb and result' => [
+ 'Invalid verb and definition' => [
false, false, true, true, true, false
],
// Invalid context possibilities.
'Invalid definition, result and context' => [
true, false, false, false, true, false
],
- 'Invalid result' => [
+ 'Invalid result and context' => [
true, true, false, false, true, false
],
- 'Invalid result and context' => [
+ 'Invalid definition and context' => [
true, false, true, false, true, false
],
'Invalid verb, definition result and context' => [
@@ -240,7 +240,7 @@ class handler_test extends \advanced_testcase {
'Invalid verb, result and context' => [
false, true, false, false, true, false
],
- 'Invalid verb, result and context' => [
+ 'Invalid verb, definition and context' => [
false, false, true, false, true, false
],
// Invalid user possibilities.
@@ -259,7 +259,7 @@ class handler_test extends \advanced_testcase {
'Invalid verb, result and user' => [
false, true, false, true, false, false
],
- 'Invalid verb, result and user' => [
+ 'Invalid verb, definition and user' => [
false, false, true, true, false, false
],
'Invalid definition, result, context and user' => [
@@ -277,7 +277,7 @@ class handler_test extends \advanced_testcase {
'Invalid verb, result, context and user' => [
false, true, false, false, false, false
],
- 'Invalid verb, result, context and user' => [
+ 'Invalid verb, definition, context and user' => [
false, false, true, false, false, false
],
];
diff --git a/mod/lesson/tests/custom_completion_test.php b/mod/lesson/tests/custom_completion_test.php
index 4ad90941e42..a345c844efb 100644
--- a/mod/lesson/tests/custom_completion_test.php
+++ b/mod/lesson/tests/custom_completion_test.php
@@ -36,14 +36,14 @@ require_once($CFG->libdir . '/completionlib.php');
* @copyright 2021 Michael Hawkins
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class custom_completion_test extends advanced_testcase {
+final class custom_completion_test extends advanced_testcase {
/**
* Data provider for get_state().
*
* @return array[]
*/
- public function get_state_provider(): array {
+ public static function get_state_provider(): array {
return [
'Undefined completion requirement' => [
'somenonexistentrule', COMPLETION_ENABLED, 3, null, coding_exception::class
@@ -66,7 +66,7 @@ class custom_completion_test extends advanced_testcase {
'User must reach end of lesson, has not met completion requirement' => [
'completionendreached', 1, false, COMPLETION_INCOMPLETE, null
],
- 'User must reach end of lesson, has not met completion requirement' => [
+ 'User must reach end of lesson, has met completion requirement' => [
'completionendreached', 1, true, COMPLETION_COMPLETE, null
],
];
@@ -197,7 +197,7 @@ class custom_completion_test extends advanced_testcase {
*
* @return array[]
*/
- public function get_available_custom_rules_provider(): array {
+ public static function get_available_custom_rules_provider(): array {
return [
'No completion conditions enabled' => [
[
diff --git a/question/type/ddimageortext/tests/question_test.php b/question/type/ddimageortext/tests/question_test.php
index bf7f521ad07..d36c476aff5 100644
--- a/question/type/ddimageortext/tests/question_test.php
+++ b/question/type/ddimageortext/tests/question_test.php
@@ -26,7 +26,6 @@ global $CFG;
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
require_once($CFG->dirroot . '/question/type/ddimageortext/tests/helper.php');
-
/**
* Unit tests for the matching question definition class.
*
@@ -35,7 +34,7 @@ require_once($CFG->dirroot . '/question/type/ddimageortext/tests/helper.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers qtype_ddimageortext_question
*/
-class question_test extends \basic_testcase {
+final class question_test extends \basic_testcase {
public function test_get_question_summary() {
$dd = \test_question_maker::make_question('ddimageortext');
@@ -224,7 +223,7 @@ class question_test extends \basic_testcase {
$this->assertFalse($dd->is_gradable_response(array()));
$this->assertFalse($dd->is_gradable_response(
- array('p1' => '', 'p2' => '', 'p3' => '', 'p3' => '')));
+ array('p1' => '', 'p2' => '', 'p3' => '')));
$this->assertTrue($dd->is_gradable_response(
array('p1' => '1', 'p2' => '1', 'p3' => '')));
$this->assertTrue($dd->is_gradable_response(array('p1' => '1')));
diff --git a/question/type/ddmarker/tests/question_test.php b/question/type/ddmarker/tests/question_test.php
index 2aba2d663de..1f8057f880c 100644
--- a/question/type/ddmarker/tests/question_test.php
+++ b/question/type/ddmarker/tests/question_test.php
@@ -26,7 +26,6 @@ global $CFG;
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
require_once($CFG->dirroot . '/question/type/ddmarker/tests/helper.php');
-
/**
* Unit tests for the drag-and-drop markers question definition class.
*
@@ -34,7 +33,7 @@ require_once($CFG->dirroot . '/question/type/ddmarker/tests/helper.php');
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class question_test extends \basic_testcase {
+final class question_test extends \basic_testcase {
public function test_get_question_summary() {
$dd = \test_question_maker::make_question('ddmarker');
@@ -242,7 +241,7 @@ class question_test extends \basic_testcase {
$this->assertFalse($dd->is_gradable_response(array()));
$this->assertFalse($dd->is_gradable_response(
- array('c1' => '', 'c2' => '', 'c3' => '', 'c3' => '')));
+ array('c1' => '', 'c2' => '', 'c3' => '')));
$this->assertTrue($dd->is_gradable_response(
array('c1' => '300,300', 'c2' => '300,300', 'c3' => '')));
$this->assertTrue($dd->is_gradable_response(array('c1' => '300,300')));
diff --git a/question/type/multichoice/tests/upgrade_old_attempt_data_test.php b/question/type/multichoice/tests/upgrade_old_attempt_data_test.php
index fafac81ad8b..c544642317d 100644
--- a/question/type/multichoice/tests/upgrade_old_attempt_data_test.php
+++ b/question/type/multichoice/tests/upgrade_old_attempt_data_test.php
@@ -21,7 +21,6 @@ defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
-
/**
* Testing the upgrade of multichoice question attempts.
*
@@ -29,7 +28,7 @@ require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
+final class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
public function test_multichoice_deferredfeedback_history960() {
$quiz = (object) array(
@@ -37,13 +36,10 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base
'course' => '3',
'name' => 'Test quiz 1',
'intro' => '',
- 'introformat' => FORMAT_HTML,
- 'questiondecimalpoints' => '-1',
- 'showuserpicture' => '1',
+ 'introformat' => FORMAT_MOODLE,
'showblocks' => '1',
'timeopen' => '0',
'timeclose' => '0',
- 'preferredbehaviour' => 'deferredfeedback',
'attempts' => '0',
'attemptonlast' => '0',
'grademethod' => '1',
@@ -63,7 +59,6 @@ class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base
'grade' => '10.00000',
'questiondecimalpoints' => '-1',
'showuserpicture' => '0',
- 'introformat' => '0',
'preferredbehaviour' => 'deferredfeedback',
'reviewattempt' => '69904',
'reviewcorrectness' => '69904',
diff --git a/question/type/numerical/tests/privacy/provider_test.php b/question/type/numerical/tests/privacy/provider_test.php
index d5fd8fd3059..2d0552a5f9e 100644
--- a/question/type/numerical/tests/privacy/provider_test.php
+++ b/question/type/numerical/tests/privacy/provider_test.php
@@ -41,7 +41,7 @@ require_once($CFG->dirroot . '/question/type/numerical/questiontype.php');
* @copyright 2021 The Open university
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class provider_test extends \core_privacy\tests\provider_testcase {
+final class provider_test extends \core_privacy\tests\provider_testcase {
// Include the privacy helper which has assertions on it.
public function test_get_metadata() {
@@ -91,7 +91,7 @@ class provider_test extends \core_privacy\tests\provider_testcase {
*
* @return array Array of valid user preferences.
*/
- public function user_preference_provider() {
+ public static function user_preference_provider(): array {
return [
'default mark 1.5' => ['defaultmark', 1.5, 1.5],
'penalty 20%' => ['penalty', 0.2000000, '20%'],
@@ -113,7 +113,7 @@ class provider_test extends \core_privacy\tests\provider_testcase {
'multichoice display select menu' => ['multichoicedisplay', \qtype_numerical::UNITSELECT,
get_string('unitselect', 'qtype_numerical')],
'unitsleft left example' => ['unitsleft', '1', get_string('leftexample', 'qtype_numerical')],
- 'unitsleft left example' => ['unitsleft', '0', get_string('rightexample', 'qtype_numerical')]
+ 'unitsleft right example' => ['unitsleft', '0', get_string('rightexample', 'qtype_numerical')],
];
}
}
diff --git a/user/tests/table/participants_search_test.php b/user/tests/table/participants_search_test.php
index 5d3a96b6d6b..d3470db902d 100644
--- a/user/tests/table/participants_search_test.php
+++ b/user/tests/table/participants_search_test.php
@@ -14,15 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-/**
- * Provides {@link core_user_table_participants_search_test} class.
- *
- * @package core_user
- * @category test
- * @copyright 2020 Andrew Nicols
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
declare(strict_types=1);
namespace core_user\table;
@@ -41,10 +32,12 @@ use stdClass;
/**
* Tests for the implementation of {@link core_user_table_participants_search} class.
*
+ * @package core_user
+ * @category test
* @copyright 2020 Andrew Nicols
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class participants_search_test extends advanced_testcase {
+final class participants_search_test extends advanced_testcase {
/**
* Helper to convert a moodle_recordset to an array of records.
@@ -190,7 +183,7 @@ class participants_search_test extends advanced_testcase {
*
* @return array
*/
- public function role_provider(): array {
+ public static function role_provider(): array {
$tests = [
// Users who only have one role each.
'Users in each role' => (object) [
@@ -693,16 +686,15 @@ class participants_search_test extends advanced_testcase {
'NONE: Filter on student, teacher' => (object) [
'roles' => ['student', 'teacher'],
'jointype' => filter::JOINTYPE_NONE,
- 'count' => 5,
+ 'count' => 4,
'expectedusers' => [
'c',
'd',
- 'e',
'g',
'h',
],
],
- 'NONE: Filter on student, teacher' => (object) [
+ 'NONE: Filter on teacher, editingteacher' => (object) [
'roles' => ['teacher', 'editingteacher'],
'jointype' => filter::JOINTYPE_NONE,
'count' => 3,