mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 05:28:30 +01:00
MDL-79717 phpunit: ensure unique data provider keys in tests.
Duplicate data provider keys were overwriting and/or duplicating one another, leading to some cases being skipped. Other "duplicate array key" errors were picked up by `phpcs` in this dragnet across all tests, which have also been fixed.
This commit is contained in:
parent
9557a52569
commit
2196813e1e
@ -36,7 +36,7 @@ require_once($CFG->libdir . '/completionlib.php');
|
||||
* @copyright 2014 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class moodle2_test extends \advanced_testcase {
|
||||
final class moodle2_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Tests the availability field on modules and sections is correctly
|
||||
@ -1146,7 +1146,6 @@ class moodle2_test extends \advanced_testcase {
|
||||
'filearea' => 'package',
|
||||
'itemid' => 0,
|
||||
'filepath' => '/',
|
||||
'filepath' => '/',
|
||||
'filename' => 'dummy.h5p',
|
||||
'addxapistate' => true,
|
||||
];
|
||||
|
@ -39,8 +39,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
|
||||
@ -608,7 +607,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' => '',
|
||||
@ -3303,7 +3302,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;
|
||||
|
||||
@ -3560,16 +3559,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',
|
||||
@ -3590,16 +3579,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',
|
||||
|
@ -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' => [
|
||||
|
@ -38,12 +38,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(
|
||||
@ -232,7 +232,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,
|
||||
@ -1125,7 +1125,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);
|
||||
|
@ -14,26 +14,17 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 {
|
||||
'<span lang="fr" class="multilang">Français</span><span class="multilang" lang="en">English</span>',
|
||||
'en',
|
||||
],
|
||||
'Reversed input order EN' => [
|
||||
'Reversed input order FR' => [
|
||||
'Français',
|
||||
'<span lang="fr" class="multilang">Français</span><span class="multilang" lang="en">English</span>',
|
||||
'fr',
|
||||
|
@ -14,14 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit test for the filter_urltolink
|
||||
*
|
||||
* @package filter_urltolink
|
||||
* @category phpunit
|
||||
* @copyright 2010 David Mudrak <david@moodle.com>
|
||||
* @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 <david@moodle.com>
|
||||
* @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: <span style="kasd"> my link to http://google.com </span>' => 'URL: <span style="kasd"> my link to <a href="http://google.com" class="_blanktarget">http://google.com</a> </span>',
|
||||
// Nested tags test.
|
||||
'<b><i>www.google.com</i></b>' => '<b><i><a href="http://www.google.com" class="_blanktarget">www.google.com</a></i></b>',
|
||||
'<input type="submit" value="Go to http://moodle.org">' => '<input type="submit" value="Go to http://moodle.org">',
|
||||
// Test realistic content.
|
||||
'<p><span style="color: rgb(37, 37, 37); font-family: sans-serif; line-height: 22.3999996185303px;">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 <a href="http://google.com">commodo consequat</a>. 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.</span><br></p>'
|
||||
=>
|
||||
|
@ -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']
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3577,9 +3579,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" => [
|
||||
@ -3647,7 +3649,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"
|
||||
|
@ -14,15 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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,8 +24,13 @@ 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 {
|
||||
|
||||
/**
|
||||
* Setup testcase.
|
||||
@ -49,7 +45,7 @@ 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');
|
||||
|
||||
@ -61,10 +57,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' => [
|
||||
|
24
mod/feedback/tests/external/external_test.php
vendored
24
mod/feedback/tests/external/external_test.php
vendored
@ -14,16 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Feedback module external functions tests
|
||||
*
|
||||
* @package mod_feedback
|
||||
* @category external
|
||||
* @copyright 2017 Juan Leyva <juan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
|
||||
namespace mod_feedback\external;
|
||||
|
||||
use core_external\external_api;
|
||||
@ -49,7 +39,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.
|
||||
@ -459,7 +449,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',
|
||||
@ -476,11 +466,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],
|
||||
@ -501,11 +486,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],
|
||||
|
@ -26,7 +26,7 @@ use mod_h5pactivity\local\manager;
|
||||
* @copyright 2020 Ferran Recio <ferran@moodle.com>
|
||||
* @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],
|
||||
|
@ -27,7 +27,7 @@ use mod_h5pactivity\local\manager;
|
||||
* @copyright 2021 Ilya Tregubov <ilya@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class lib_test extends advanced_testcase {
|
||||
final class lib_test extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Load required test libraries
|
||||
@ -79,7 +79,6 @@ class lib_test extends advanced_testcase {
|
||||
'filearea' => 'package',
|
||||
'itemid' => 0,
|
||||
'filepath' => '/',
|
||||
'filepath' => '/',
|
||||
'filename' => 'dummy.h5p',
|
||||
'addxapistate' => true,
|
||||
];
|
||||
@ -373,7 +372,6 @@ class lib_test extends advanced_testcase {
|
||||
'filearea' => 'package',
|
||||
'itemid' => 0,
|
||||
'filepath' => '/',
|
||||
'filepath' => '/',
|
||||
'filename' => 'dummy.h5p',
|
||||
'addxapistate' => true,
|
||||
];
|
||||
|
@ -35,7 +35,7 @@ use stdClass;
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \mod_h5pactivity\xapi\handler
|
||||
*/
|
||||
class handler_test extends \advanced_testcase {
|
||||
final class handler_test extends \advanced_testcase {
|
||||
|
||||
/**
|
||||
* Setup to ensure that fixtures are loaded.
|
||||
@ -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
|
||||
],
|
||||
];
|
||||
|
@ -36,14 +36,14 @@ require_once($CFG->libdir . '/completionlib.php');
|
||||
* @copyright 2021 Michael Hawkins <michaelh@moodle.com>
|
||||
* @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' => [
|
||||
[
|
||||
|
@ -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(): void {
|
||||
$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')));
|
||||
|
@ -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(): void {
|
||||
$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')));
|
||||
|
@ -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(): void {
|
||||
$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',
|
||||
|
@ -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(): void {
|
||||
@ -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')],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -14,15 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Provides {@link core_user_table_participants_search_test} class.
|
||||
*
|
||||
* @package core_user
|
||||
* @category test
|
||||
* @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @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 <andrew@nicols.co.uk>
|
||||
* @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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user