This commit is contained in:
Andrew Nicols 2023-01-19 08:47:51 +08:00
commit 3731f4e263
26 changed files with 120 additions and 179 deletions

View File

@ -33,8 +33,7 @@ class store_test extends \advanced_testcase {
* Tests log writing.
*
* @param bool $jsonformat True to test with JSON format
* @dataProvider test_log_writing_provider
* @throws moodle_exception
* @dataProvider log_writing_provider
*/
public function test_log_writing(bool $jsonformat) {
global $DB, $CFG;
@ -252,9 +251,9 @@ class store_test extends \advanced_testcase {
* Returns different JSON format settings so the test can be run with JSON format either on or
* off.
*
* @return [bool] Array of true/false
* @return bool[] Array of true/false
*/
public static function test_log_writing_provider(): array {
public static function log_writing_provider(): array {
return [
[false],
[true]

View File

@ -38,8 +38,7 @@ class store_test extends \advanced_testcase {
* Tests log writing.
*
* @param bool $jsonformat True to test with JSON format
* @dataProvider test_log_writing_provider
* @throws moodle_exception
* @dataProvider log_writing_provider
*/
public function test_log_writing(bool $jsonformat) {
global $DB;
@ -227,9 +226,9 @@ class store_test extends \advanced_testcase {
* Returns different JSON format settings so the test can be run with JSON format either on or
* off.
*
* @return [bool] Array of true/false
* @return bool[] Array of true/false
*/
public static function test_log_writing_provider(): array {
public static function log_writing_provider(): array {
return [
[false],
[true]
@ -372,7 +371,7 @@ class store_test extends \advanced_testcase {
* Tests the decode_other function can cope with both JSON and PHP serialized format.
*
* @param mixed $value Value to encode and decode
* @dataProvider test_decode_other_provider
* @dataProvider decode_other_provider
*/
public function test_decode_other($value) {
$this->assertEquals($value, \logstore_standard\log\store::decode_other(serialize($value)));
@ -391,7 +390,7 @@ class store_test extends \advanced_testcase {
*
* @return array Array of parameters
*/
public function test_decode_other_provider(): array {
public function decode_other_provider(): array {
return [
[['info' => 'd2819896', 'logurl' => 'discuss.php?d=2819896']],
[null],
@ -404,8 +403,7 @@ class store_test extends \advanced_testcase {
* Checks that backup and restore of log data works correctly.
*
* @param bool $jsonformat True to test with JSON format
* @dataProvider test_log_writing_provider
* @throws moodle_exception
* @dataProvider log_writing_provider
*/
public function test_backup_restore(bool $jsonformat) {
global $DB;

View File

@ -380,7 +380,7 @@ class condition_test extends \advanced_testcase {
/**
* Tests the is_available and get_description functions for previous activity option.
*
* @dataProvider test_previous_activity_data
* @dataProvider previous_activity_data
* @param int $grade the current assign grade (0 for none)
* @param int $condition true for complete, false for incomplete
* @param string $mark activity to mark as complete
@ -469,7 +469,7 @@ class condition_test extends \advanced_testcase {
$this->assertMatchesRegularExpression($description, $information);
}
public function test_previous_activity_data(): array {
public function previous_activity_data(): array {
// Assign grade, condition, activity to complete, activity to test, result, resultnot, description.
return [
'Missing previous activity complete' => [
@ -561,7 +561,7 @@ class condition_test extends \advanced_testcase {
* Tests the is_available and get_description functions for
* previous activity option in course sections.
*
* @dataProvider test_section_previous_activity_data
* @dataProvider section_previous_activity_data
* @param int $condition condition value
* @param bool $mark if Page 1 must be mark as completed
* @param string $section section to add the availability
@ -634,7 +634,7 @@ class condition_test extends \advanced_testcase {
}
public function test_section_previous_activity_data(): array {
public function section_previous_activity_data(): array {
return [
// Condition, Activity completion, section to test, result, resultnot, description.
'Completion complete Section with no previous activity' => [

View File

@ -2795,7 +2795,7 @@ class externallib_test extends externallib_advanced_testcase {
*
* @return array
*/
public function test_get_calendar_event_by_id_prevent_read_other_users_events_data_provider(): array {
public function get_calendar_event_by_id_prevent_read_other_users_events_data_provider(): array {
$syscontext = \context_system::instance();
$managerrole = 'manager';
return [
@ -2810,7 +2810,7 @@ class externallib_test extends externallib_advanced_testcase {
* Prevent user from reading other user's event.
*
* @covers \core_calendar_external::get_calendar_event_by_id
* @dataProvider test_get_calendar_event_by_id_prevent_read_other_users_events_data_provider
* @dataProvider get_calendar_event_by_id_prevent_read_other_users_events_data_provider
*
* @param bool $isadminevent Is admin's event
* @param bool $isadmin Is current user admin user
@ -2866,7 +2866,7 @@ class externallib_test extends externallib_advanced_testcase {
*
* @return array
*/
public function test_edit_or_delete_other_users_events_data_provider(): array {
public function edit_or_delete_other_users_events_data_provider(): array {
$syscontext = \context_system::instance();
$managerrole = 'manager';
return [
@ -2880,7 +2880,7 @@ class externallib_test extends externallib_advanced_testcase {
/**
* Test the behavior of deleting other users' user events.
*
* @dataProvider test_edit_or_delete_other_users_events_data_provider
* @dataProvider edit_or_delete_other_users_events_data_provider
* @covers \core_calendar_external::delete_calendar_events
* @param bool $isadmin Whether the current user is admin.
* @param bool $isadminevent Whether it's an admin event or not.
@ -2927,7 +2927,7 @@ class externallib_test extends externallib_advanced_testcase {
/**
* Test the behavior of editing other users' user events
*
* @dataProvider test_edit_or_delete_other_users_events_data_provider
* @dataProvider edit_or_delete_other_users_events_data_provider
* @covers \core_calendar_external::submit_create_update_form
* @param bool $isadmin Whether the current user is admin.
* @param bool $isadminevent Whether it's an admin event or not.

View File

@ -49,7 +49,7 @@ class std_proxy_test extends \advanced_testcase {
/**
* Test proxying.
*
* @dataProvider test_proxy_testcases()
* @dataProvider proxy_testcases
* @param int $id Object ID.
* @param string $member Object member to retrieve.
* @param mixed $expected Expected value of member.
@ -65,7 +65,7 @@ class std_proxy_test extends \advanced_testcase {
/**
* Test setting values with a base class.
*
* @dataProvider test_proxy_testcases()
* @dataProvider proxy_testcases
* @param int $id Object ID.
* @param string $member Object member to retrieve.
* @param mixed $storedvalue Value as would be stored externally.
@ -86,7 +86,7 @@ class std_proxy_test extends \advanced_testcase {
/**
* Test getting a non existant member.
*
* @dataProvider test_get_set_testcases()
* @dataProvider get_set_testcases
* @param int $id ID of the object being proxied.
*/
public function test_get_invalid_member($id) {
@ -101,7 +101,7 @@ class std_proxy_test extends \advanced_testcase {
/**
* Test get proxied instance.
*
* @dataProvider test_get_set_testcases()
* @dataProvider get_set_testcases
* @param int $id Object ID.
*/
public function test_get_proxied_instance($id) {
@ -115,7 +115,7 @@ class std_proxy_test extends \advanced_testcase {
/**
* Test cases for proxying test.
*/
public function test_proxy_testcases() {
public function proxy_testcases() {
return [
'Object 1 member 1' => [
1,
@ -153,7 +153,7 @@ class std_proxy_test extends \advanced_testcase {
/**
* Test cases for getting and setting tests.
*/
public function test_get_set_testcases() {
public function get_set_testcases() {
return [
'Object 1' => [1],
'Object 2' => [5]

View File

@ -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 the {@link filter_mathjaxloader_filter_testcase} class.
*
* @package filter_mathjaxloader
* @category test
* @copyright 2017 David Mudrák <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace filter_mathjaxloader;
use filter_mathjaxloader;
@ -35,6 +26,8 @@ require_once($CFG->dirroot.'/filter/mathjaxloader/filter.php');
/**
* Unit tests for the MathJax loader filter.
*
* @package filter_mathjaxloader
* @category test
* @copyright 2017 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@ -46,7 +39,7 @@ class filter_test extends \advanced_testcase {
* @param string $moodlelangcode the user's current language
* @param string $mathjaxlangcode the mathjax language to be used for the moodle language
*
* @dataProvider test_map_language_code_expected_mappings
* @dataProvider map_language_code_expected_mappings
*/
public function test_map_language_code($moodlelangcode, $mathjaxlangcode) {
@ -59,7 +52,7 @@ class filter_test extends \advanced_testcase {
*
* @return array of [moodlelangcode, mathjaxcode] tuples
*/
public function test_map_language_code_expected_mappings() {
public function map_language_code_expected_mappings() {
return [
['cz', 'cs'], // Explicit mapping.

View File

@ -38,7 +38,7 @@ class filtermath_test extends \advanced_testcase {
* @param string $inputtext The text given by the user.
* @param string $expected The expected output after filtering.
*
* @dataProvider test_math_filtering_inputs
* @dataProvider math_filtering_inputs
*/
public function test_math_filtering($inputtext, $expected) {
$filter = new filter_mathjaxloader(\context_system::instance(), []);
@ -50,7 +50,7 @@ class filtermath_test extends \advanced_testcase {
*
* @return array of [inputtext, expectedoutput] tuples.
*/
public function test_math_filtering_inputs() {
public function math_filtering_inputs() {
return [
// One inline formula.
['Some inline math \\( y = x^2 \\).',

View File

@ -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/>.
/**
* Testing the H5PFrameworkInterface interface implementation.
*
* @package core_h5p
* @category test
* @copyright 2019 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_h5p;
use core_collator;
@ -34,6 +25,7 @@ use Moodle\H5PDisplayOptionBehaviour;
* Test class covering the H5PFrameworkInterface interface implementation.
*
* @package core_h5p
* @category test
* @copyright 2019 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @runTestsInSeparateProcesses
@ -638,7 +630,7 @@ class framework_test extends \advanced_testcase {
/**
* Test the behaviour of isPatchedLibrary().
*
* @dataProvider test_isPatchedLibrary_provider
* @dataProvider isPatchedLibrary_provider
* @param array $libraryrecords Array containing data for the library creation
* @param array $testlibrary Array containing the test library data
* @param bool $expected The expectation whether the library is patched or not
@ -660,7 +652,7 @@ class framework_test extends \advanced_testcase {
*
* @return array
*/
public function test_isPatchedLibrary_provider(): array {
public function isPatchedLibrary_provider(): array {
return [
'Unpatched library. No different versioning' => [
[
@ -1416,7 +1408,7 @@ class framework_test extends \advanced_testcase {
/**
* Test the behaviour of loadLibrarySemantics().
*
* @dataProvider test_loadLibrarySemantics_provider
* @dataProvider loadLibrarySemantics_provider
* @param array $libraryrecords Array containing data for the library creation
* @param array $testlibrary Array containing the test library data
* @param string $expected The expected semantics value
@ -1439,7 +1431,7 @@ class framework_test extends \advanced_testcase {
*
* @return array
*/
public function test_loadLibrarySemantics_provider(): array {
public function loadLibrarySemantics_provider(): array {
$semantics = json_encode(
[
@ -2208,7 +2200,7 @@ class framework_test extends \advanced_testcase {
/**
* Test the behaviour of test_libraryHasUpgrade().
*
* @dataProvider test_libraryHasUpgrade_provider
* @dataProvider libraryHasUpgrade_provider
* @param array $libraryrecords Array containing data for the library creation
* @param array $testlibrary Array containing the test library data
* @param bool $expected The expectation whether the library is patched or not
@ -2230,7 +2222,7 @@ class framework_test extends \advanced_testcase {
*
* @return array
*/
public function test_libraryHasUpgrade_provider(): array {
public function libraryHasUpgrade_provider(): array {
return [
'Lower major version; Identical lower version' => [
[

View File

@ -14,23 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Test class covering the h5p data generator class.
*
* @package core_h5p
* @category test
* @copyright 2019 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_h5p;
use core_h5p\local\library\autoloader;
defined('MOODLE_INTERNAL') || die();
/**
* Generator testcase for the core_grading generator.
* Test class covering the h5p data generator class.
*
* @package core_h5p
* @category test
@ -165,7 +154,7 @@ class generator_test extends \advanced_testcase {
* Test the behaviour of generate_h5p_data(). Test whether library files are created or not
* on filesystem depending what the method defines.
*
* @dataProvider test_generate_h5p_data_files_creation_provider
* @dataProvider generate_h5p_data_files_creation_provider
* @param bool $createlibraryfiles Whether to create library files on the filesystem
* @param bool $expected The expectation whether the files have been created or not
**/
@ -205,7 +194,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
public function test_generate_h5p_data_files_creation_provider(): array {
public function generate_h5p_data_files_creation_provider(): array {
return [
'Do not create library related files on the filesystem' => [
false,
@ -261,7 +250,7 @@ class generator_test extends \advanced_testcase {
* Test the behaviour of create_h5p_record(). Test whather the h5p content data is
* properly saved in the database.
*
* @dataProvider test_create_h5p_record_provider
* @dataProvider create_h5p_record_provider
* @param array $h5pdata The h5p content data
* @param \stdClass $expected The expected saved data
**/
@ -287,7 +276,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
public function test_create_h5p_record_provider(): array {
public function create_h5p_record_provider(): array {
$createdjsoncontent = json_encode(
array(
'text' => '<p>Created dummy text<\/p>\n',
@ -384,7 +373,7 @@ class generator_test extends \advanced_testcase {
* Test the behaviour of create_contents_libraries_record(). Test whether the contents libraries
* are properly saved in the database.
*
* @dataProvider test_create_contents_libraries_record_provider
* @dataProvider create_contents_libraries_record_provider
* @param array $contentslibrariestdata The h5p contents libraries data.
* @param \stdClass $expected The expected saved data.
**/
@ -408,7 +397,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
public function test_create_contents_libraries_record_provider(): array {
public function create_contents_libraries_record_provider(): array {
return [
'Create h5p content library with set dependency type' => [
[
@ -444,7 +433,7 @@ class generator_test extends \advanced_testcase {
* Test the behaviour of create_library_dependency_record(). Test whether the contents libraries
* are properly saved in the database.
*
* @dataProvider test_create_library_dependency_record_provider
* @dataProvider create_library_dependency_record_provider
* @param array $librarydependencydata The library dependency data.
* @param \stdClass $expected The expected saved data.
**/
@ -468,7 +457,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
*/
public function test_create_library_dependency_record_provider(): array {
public function create_library_dependency_record_provider(): array {
return [
'Create h5p library dependency with set dependency type' => [
[
@ -499,7 +488,7 @@ class generator_test extends \advanced_testcase {
/**
* Test the behaviour of create_content_file(). Test whether a file belonging to a content is created.
*
* @dataProvider test_create_content_file_provider
* @dataProvider create_content_file_provider
* @param array $filedata Data from the file to be created.
* @param array $expecteddata Data expected.Data from the file to be created.
*/
@ -534,7 +523,7 @@ class generator_test extends \advanced_testcase {
*
* @return array
**/
public function test_create_content_file_provider(): array {
public function create_content_file_provider(): array {
return [
'Create file in content with id 4' => [
[

View File

@ -2266,7 +2266,7 @@ class ddl_test extends \database_driver_testcase {
*
* @return array The type-value pair fixture.
*/
public function test_get_enc_quoted_provider() {
public function get_enc_quoted_provider() {
return array(
// Reserved: some examples from SQL-92.
[true, 'from'],
@ -2280,7 +2280,7 @@ class ddl_test extends \database_driver_testcase {
/**
* This is a test for sql_generator::getEncQuoted().
*
* @dataProvider test_get_enc_quoted_provider
* @dataProvider get_enc_quoted_provider
* @param bool $reserved Whether the column name is reserved or not.
* @param string $columnname The column name to be quoted, according to the value of $reserved.
**/
@ -2315,7 +2315,7 @@ class ddl_test extends \database_driver_testcase {
*
* @return array The type-old-new tuple fixture.
*/
public function test_sql_generator_get_rename_field_sql_provider() {
public function sql_generator_get_rename_field_sql_provider() {
return array(
// Reserved: an example from SQL-92.
// Both names should be reserved.
@ -2328,7 +2328,7 @@ class ddl_test extends \database_driver_testcase {
/**
* This is a unit test for sql_generator::getRenameFieldSQL().
*
* @dataProvider test_sql_generator_get_rename_field_sql_provider
* @dataProvider sql_generator_get_rename_field_sql_provider
* @param bool $reserved Whether the column name is reserved or not.
* @param string $oldcolumnname The column name to be renamed.
* @param string $newcolumnname The new column name.

View File

@ -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/>.
/**
* Completion tests.
*
* @package core_completion
* @category phpunit
* @copyright 2008 Sam Marshall
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
@ -33,7 +23,7 @@ require_once($CFG->libdir.'/completionlib.php');
* Completion tests.
*
* @package core_completion
* @category phpunit
* @category test
* @copyright 2008 Sam Marshall
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@ -401,9 +391,8 @@ class completionlib_test extends advanced_testcase {
* Provider for the test_internal_get_state_with_grade_criteria.
*
* @return array
* @covers ::internal_get_state
*/
public function test_internal_get_state_with_grade_criteria_provider() {
public function internal_get_state_with_grade_criteria_provider() {
return [
"Passing grade enabled and achieve. State should be COMPLETION_COMPLETE_PASS" => [
[
@ -451,7 +440,7 @@ class completionlib_test extends advanced_testcase {
/**
* Tests that the right completion state is being set based on the grade criteria.
*
* @dataProvider test_internal_get_state_with_grade_criteria_provider
* @dataProvider internal_get_state_with_grade_criteria_provider
* @param array $completioncriteria The completion criteria to use
* @param int|null $studentgrade Grade to assign to student
* @param int $expectedstate Expected completion state

View File

@ -47,7 +47,7 @@ class primary_test extends \advanced_testcase {
/**
* Test the primary export to confirm we are getting the nodes
*
* @dataProvider test_primary_export_provider
* @dataProvider primary_export_provider
* @param bool $withcustom Setup with custom menu
* @param bool $withlang Setup with langs
* @param string $userloggedin The type of user ('admin' or 'guest') if creating setup with logged in user,
@ -113,7 +113,7 @@ class primary_test extends \advanced_testcase {
*
* @return array
*/
public function test_primary_export_provider(): array {
public function primary_export_provider(): array {
return [
"Export the menu data when: custom menu exists; multiple langs installed; user is not logged in." => [
true, true, '', ['mobileprimarynav', 'moremenu', 'lang', 'user']

View File

@ -35,7 +35,7 @@ class primary_test extends \advanced_testcase {
*
* @param string $usertype The user to setup for - admin, guest, regular user
* @param string $expected The expected nodes
* @dataProvider test_setting_initialise_provider
* @dataProvider setting_initialise_provider
*/
public function test_setting_initialise($usertype, $expected) {
global $PAGE;
@ -59,7 +59,7 @@ class primary_test extends \advanced_testcase {
/**
* Data provider for the test_setting_initialise function
*/
public function test_setting_initialise_provider() {
public function setting_initialise_provider() {
return [
'Testing as a guest user' => ['guest', ['home']],
'Testing as an admin' => ['admin', ['home', 'myhome', 'mycourses', 'siteadminnode']],
@ -107,7 +107,7 @@ class primary_test extends \advanced_testcase {
* @param string|null $key The key of the node to activate.
* @param string|null $seturl Set the url for $PAGE.
* @return void
* @dataProvider test_search_and_set_active_node_provider
* @dataProvider search_and_set_active_node_provider
*/
public function test_search_and_set_active_node(string $expectedkey, ?string $key = null, ?string $seturl = null): void {
global $PAGE;
@ -153,7 +153,7 @@ class primary_test extends \advanced_testcase {
*
* @return array
*/
public function test_search_and_set_active_node_provider(): array {
public function search_and_set_active_node_provider(): array {
return [
'Test by activating node which is part of the tree'
=> ['tenthchild', 'tenthchild'],

View File

@ -90,7 +90,7 @@ class secondary_test extends \advanced_testcase {
* @param string $activenode The expected active node
* @param string $courseformat The used course format (only applicable in the course and module context).
* @return void
* @dataProvider test_setting_initialise_provider
* @dataProvider setting_initialise_provider
*/
public function test_setting_initialise(string $context, string $expectedfirstnode,
string $header, string $activenode, string $courseformat = 'topics'): void {
@ -140,7 +140,7 @@ class secondary_test extends \advanced_testcase {
* Data provider for the test_setting_initialise function
* @return array
*/
public function test_setting_initialise_provider(): array {
public function setting_initialise_provider(): array {
return [
'Testing in a course context' => ['course', 'coursehome', 'courseheader', 'Course'],
'Testing in a course context using a single activity course format' =>
@ -198,7 +198,7 @@ class secondary_test extends \advanced_testcase {
* @param string|null $key The key set by user using set_secondary_active_tab.
* @param string|null $seturl The url set by user.
* @return void
* @dataProvider test_active_node_scan_provider
* @dataProvider active_node_scan_provider
*/
public function test_active_node_scan(string $expectedkey, ?string $key = null, ?string $seturl = null): void {
global $PAGE;
@ -233,7 +233,7 @@ class secondary_test extends \advanced_testcase {
*
* @return array
*/
public function test_active_node_scan_provider(): array {
public function active_node_scan_provider(): array {
return [
'Test by activating node adjacent to root node'
=> ['firstchild', 'firstchild'],
@ -261,7 +261,7 @@ class secondary_test extends \advanced_testcase {
* @param int|null $maxdisplayednodes The maximum limit of navigation nodes displayed in the secondary navigation
* @param array $expecedmoremenunodes The array containing the keys of the expected navigation nodes which are
* forced into the "more" menu
* @dataProvider test_force_nodes_into_more_menu_provider
* @dataProvider force_nodes_into_more_menu_provider
*/
public function test_force_nodes_into_more_menu(array $secondarynavnodesdata, array $defaultmoremenunodes,
?int $maxdisplayednodes, array $expecedmoremenunodes) {
@ -292,7 +292,7 @@ class secondary_test extends \advanced_testcase {
*
* @return array
*/
public function test_force_nodes_into_more_menu_provider(): array {
public function force_nodes_into_more_menu_provider(): array {
return [
'The total number of navigation nodes exceeds the max display limit (5); ' .
'navnode2 and navnode4 are forced into "more" menu by default.' =>
@ -446,7 +446,7 @@ class secondary_test extends \advanced_testcase {
*
* @param string $selectedurl
* @param string $expectednode
* @dataProvider test_nodes_match_current_url_provider
* @dataProvider nodes_match_current_url_provider
*/
public function test_nodes_match_current_url(string $selectedurl, string $expectednode) {
global $PAGE;
@ -476,7 +476,7 @@ class secondary_test extends \advanced_testcase {
*
* @return \string[][]
*/
public function test_nodes_match_current_url_provider(): array {
public function nodes_match_current_url_provider(): array {
return [
"Match url to a node that is a deep nested" => [
'/view/course.php',
@ -496,7 +496,7 @@ class secondary_test extends \advanced_testcase {
*
* @param string $selected
* @param array $expected
* @dataProvider test_get_menu_array_provider
* @dataProvider get_menu_array_provider
*/
public function test_get_menu_array(string $selected, array $expected) {
global $PAGE;
@ -534,7 +534,7 @@ class secondary_test extends \advanced_testcase {
*
* @return array[]
*/
public function test_get_menu_array_provider(): array {
public function get_menu_array_provider(): array {
return [
"Fetch information from a node with action and no children" => [
'child1',
@ -588,7 +588,7 @@ class secondary_test extends \advanced_testcase {
*
* @param string $selectedkey
* @param string|null $expectedkey
* @dataProvider test_get_node_with_first_action_provider
* @dataProvider get_node_with_first_action_provider
*/
public function test_get_node_with_first_action(string $selectedkey, ?string $expectedkey) {
global $PAGE;
@ -640,7 +640,7 @@ class secondary_test extends \advanced_testcase {
*
* @return array
*/
public function test_get_node_with_first_action_provider(): array {
public function get_node_with_first_action_provider(): array {
return [
"Search for action when parent has no action and multiple children with actions" => [
"child3",
@ -807,7 +807,7 @@ class secondary_test extends \advanced_testcase {
* @param string $selectedurl
* @param bool $expectednull
* @param bool $emptynode
* @dataProvider test_get_overflow_menu_data_provider
* @dataProvider get_overflow_menu_data_provider
*/
public function test_get_overflow_menu_data(string $selectedurl, bool $expectednull, bool $emptynode = false) {
global $PAGE;
@ -870,7 +870,7 @@ class secondary_test extends \advanced_testcase {
*
* @return string[]
*/
public function test_get_overflow_menu_data_provider(): array {
public function get_overflow_menu_data_provider(): array {
return [
"Active node is the course home node" => [
'/coursehome.php',
@ -899,7 +899,7 @@ class secondary_test extends \advanced_testcase {
/**
* Test the course administration settings return an overflow menu.
*
* @dataProvider test_get_overflow_menu_data_course_admin_provider
* @dataProvider get_overflow_menu_data_course_admin_provider
* @param string $url Url of the page we are testing.
* @param string $contextidentifier id or contextid or something similar.
* @param bool $expected The expected return. True to return the overflow menu otherwise false for nothing.
@ -936,7 +936,7 @@ class secondary_test extends \advanced_testcase {
*
* @return array Provider information.
*/
public function test_get_overflow_menu_data_course_admin_provider(): array {
public function get_overflow_menu_data_course_admin_provider(): array {
return [
"Backup page returns overflow" => [
'/backup/backup.php',

View File

@ -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/>.
/**
* Unit tests for lib/navigationlib.php
*
* @package core
* @category test
* @copyright 2009 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (5)
*/
namespace core;
use action_link;
@ -570,7 +561,7 @@ class navigationlib_test extends \advanced_testcase {
*
* @param bool $haschildren Whether the navigation node has children nodes
* @param bool $forceintomoremenu Whether to force the navigation node and its children into the "more" menu
* @dataProvider test_set_force_into_more_menu_provider
* @dataProvider set_force_into_more_menu_provider
*/
public function test_set_force_into_more_menu(bool $haschildren, bool $forceintomoremenu) {
// Create a navigation node.
@ -597,7 +588,7 @@ class navigationlib_test extends \advanced_testcase {
*
* @return array
*/
public function test_set_force_into_more_menu_provider(): array {
public function set_force_into_more_menu_provider(): array {
return [
'Navigation node without any children nodes; Force into "more" menu => true.' =>
[
@ -622,7 +613,7 @@ class navigationlib_test extends \advanced_testcase {
*
* @param navigation_node $node The sample navigation node
* @param bool $expected Whether the navigation node contains an action link
* @dataProvider test_is_action_link_provider
* @dataProvider is_action_link_provider
* @covers navigation_node::is_action_link
*/
public function test_is_action_link(navigation_node $node, bool $expected) {
@ -634,7 +625,7 @@ class navigationlib_test extends \advanced_testcase {
*
* @return array
*/
public function test_is_action_link_provider(): array {
public function is_action_link_provider(): array {
return [
'The navigation node has an action link.' =>
[
@ -655,7 +646,7 @@ class navigationlib_test extends \advanced_testcase {
* Test the action_link_actions method.
*
* @param navigation_node $node The sample navigation node
* @dataProvider test_action_link_actions_provider
* @dataProvider action_link_actions_provider
* @covers navigation_node::action_link_actions
*/
public function test_action_link_actions(navigation_node $node) {
@ -687,7 +678,7 @@ class navigationlib_test extends \advanced_testcase {
*
* @return array
*/
public function test_action_link_actions_provider(): array {
public function action_link_actions_provider(): array {
return [
'The navigation node has an action link with an action attached.' =>
[

View File

@ -30,7 +30,7 @@ class activity_header_test extends \advanced_testcase {
/**
* Test the title setter
*
* @dataProvider test_set_title_provider
* @dataProvider set_title_provider
* @param string $value
* @param string $expected
* @covers ::set_title
@ -60,7 +60,7 @@ class activity_header_test extends \advanced_testcase {
* Provider for the test_set_title unit test.
* @return array
*/
public function test_set_title_provider(): array {
public function set_title_provider(): array {
return [
"Set the title with a plain text" => [
"Activity title", "Activity title"

View File

@ -134,7 +134,7 @@ TBC;
/**
* Data provider for the test_load function.
*/
public function test_load_test_cases() {
public function load_test_cases() {
$cache = [
'core' => [
'test' => '{{! a comment }}The rest of the template'
@ -163,7 +163,7 @@ TBC;
/**
* Test the load function.
*
* @dataProvider test_load_test_cases()
* @dataProvider load_test_cases
* @param mustache_template_source_loader $loader The loader
* @param string $component The moodle component
* @param string $name The template name
@ -177,7 +177,7 @@ TBC;
/**
* Data provider for the load_with_dependencies function.
*/
public function test_load_with_dependencies_test_cases() {
public function load_with_dependencies_test_cases() {
// Create a bunch of templates that include one another in various ways. There is
// multiple instances of recursive inclusions to test that the code doensn't get
// stuck in an infinite loop.
@ -330,7 +330,7 @@ TBC;
/**
* Test the load_with_dependencies function.
*
* @dataProvider test_load_with_dependencies_test_cases()
* @dataProvider load_with_dependencies_test_cases
* @param mustache_template_source_loader $loader The loader
* @param string $component The moodle component
* @param string $name The template name
@ -344,7 +344,7 @@ TBC;
/**
* Data provider for the test_load function.
*/
public function test_scan_template_source_for_dependencies_test_cases() {
public function scan_template_source_for_dependencies_test_cases() {
$foo = '{{! a comment }}{{> core/bar }}{{< test/bop }}{{/ test/bop}}{{#str}} help, core {{/str}}';
$bar = '{{! a comment }}{{> core/baz }}';
$baz = '{{! a comment }}{{#str}} hide, core {{/str}}';
@ -488,7 +488,7 @@ TEMPLATE;
/**
* Test the scan_template_source_for_dependencies function.
*
* @dataProvider test_scan_template_source_for_dependencies_test_cases()
* @dataProvider scan_template_source_for_dependencies_test_cases()
* @param mustache_template_source_loader $loader The loader
* @param string $source The template to test
* @param string $expected The expected output

View File

@ -14,6 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
declare(strict_types = 1);
namespace core\plugininfo;
use testable_core_plugin_manager;
use testable_plugininfo_base;
/**
* Unit tests for plugin base class.
*
@ -21,20 +28,6 @@
* @copyright 2019 Andrew Nicols
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
declare(strict_types = 1);
namespace core\plugininfo;
defined('MOODLE_INTERNAL') || die();
use core_plugin_manager;
use testable_core_plugin_manager;
use testable_plugininfo_base;
/**
* Tests of the basic API of the plugin manager.
*/
class base_test extends \advanced_testcase {
/**
@ -172,7 +165,7 @@ class base_test extends \advanced_testcase {
* Test the load_disk_version function to check that it handles a range of correct supported and incompatible field
* definitions.
*
* @dataProvider test_load_disk_version_branch_supports_provider
* @dataProvider load_disk_version_branch_supports_provider
* @param array|null $supported Supported versions to inject
* @param string|int|null $incompatible Incompatible version to inject.
* @param int $version Version to test
@ -204,7 +197,7 @@ class base_test extends \advanced_testcase {
*
* @return array
*/
public function test_load_disk_version_branch_supports_provider(): array {
public function load_disk_version_branch_supports_provider(): array {
return [
'Range, branch in support, lowest' => [
'supported' => [29, 31],

View File

@ -34,7 +34,7 @@ class manager_test extends \advanced_testcase {
*
* @return array
*/
public function test_get_candidate_adhoc_tasks_provider(): array {
public function get_candidate_adhoc_tasks_provider(): array {
return [
[
'concurrencylimit' => 5,
@ -205,7 +205,7 @@ class manager_test extends \advanced_testcase {
/**
* Test that the candidate adhoc tasks are returned in the right order.
*
* @dataProvider test_get_candidate_adhoc_tasks_provider
* @dataProvider get_candidate_adhoc_tasks_provider
*
* @param int $concurrencylimit The max number of runners each task can consume
* @param int $limit SQL limit

View File

@ -5608,7 +5608,7 @@ class api_test extends messagelib_test {
/**
* Data provider for test_get_conversation_counts().
*/
public function test_get_conversation_counts_test_cases() {
public function get_conversation_counts_test_cases() {
$typeindividual = api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL;
$typegroup = api::MESSAGE_CONVERSATION_TYPE_GROUP;
$typeself = api::MESSAGE_CONVERSATION_TYPE_SELF;
@ -5971,7 +5971,7 @@ class api_test extends messagelib_test {
/**
* Test the get_conversation_counts() function.
*
* @dataProvider test_get_conversation_counts_test_cases()
* @dataProvider get_conversation_counts_test_cases
* @param array $conversationconfigs Conversations to create
* @param int $deletemessagesuser The user who is deleting the messages
* @param array $deletemessages The list of messages to delete (by index)
@ -6094,7 +6094,7 @@ class api_test extends messagelib_test {
/**
* Test the get_unread_conversation_counts() function.
*
* @dataProvider test_get_conversation_counts_test_cases()
* @dataProvider get_conversation_counts_test_cases
* @param array $conversationconfigs Conversations to create
* @param int $deletemessagesuser The user who is deleting the messages
* @param array $deletemessages The list of messages to delete (by index)

View File

@ -5136,7 +5136,7 @@ class externallib_test extends externallib_advanced_testcase {
/**
* Data provider for test_get_conversation_counts().
*/
public function test_get_conversation_counts_test_cases() {
public function get_conversation_counts_test_cases() {
$typeindividual = \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL;
$typegroup = \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP;
$typeself = \core_message\api::MESSAGE_CONVERSATION_TYPE_SELF;
@ -5499,7 +5499,7 @@ class externallib_test extends externallib_advanced_testcase {
/**
* Test the get_conversation_counts() function.
*
* @dataProvider test_get_conversation_counts_test_cases()
* @dataProvider get_conversation_counts_test_cases()
* @param array $conversationconfigs Conversations to create
* @param int $deletemessagesuser The user who is deleting the messages
* @param array $deletemessages The list of messages to delete (by index)
@ -5596,7 +5596,7 @@ class externallib_test extends externallib_advanced_testcase {
/**
* Test the get_unread_conversation_counts() function.
*
* @dataProvider test_get_conversation_counts_test_cases()
* @dataProvider get_conversation_counts_test_cases
* @param array $conversationconfigs Conversations to create
* @param int $deletemessagesuser The user who is deleting the messages
* @param array $deletemessages The list of messages to delete (by index)

View File

@ -874,7 +874,7 @@ class locallib_test extends \advanced_testcase {
* We only test combinations of plugins here. Individual plugins are tested
* in their respective test files.
*
* @dataProvider test_new_submission_empty_testcases
* @dataProvider new_submission_empty_testcases
* @param string $data The file submission data
* @param bool $expected The expected return value
*/
@ -914,7 +914,7 @@ class locallib_test extends \advanced_testcase {
*
* @return array of testcases
*/
public function test_new_submission_empty_testcases() {
public function new_submission_empty_testcases() {
return [
'With file and onlinetext' => [
[

View File

@ -68,9 +68,7 @@ class create_template_form_test extends \advanced_testcase {
* @param bool $accessallowed
* @param bool $public
* @param bool $expectedispublicvalue
* @throws \coding_exception
* @throws \dml_exception
* @dataProvider test_createtemplate_form_with_modified_capabilities_provider
* @dataProvider createtemplate_form_with_modified_capabilities_provider
*/
public function test_createtemplate_form_with_modified_capabilities(array $unassignedroles, bool $accessallowed,
bool $public = false, bool $expectedispublicvalue = false) {
@ -104,7 +102,7 @@ class create_template_form_test extends \advanced_testcase {
*
* @return array
*/
public function test_createtemplate_form_with_modified_capabilities_provider(): array {
public function createtemplate_form_with_modified_capabilities_provider(): array {
return [
"Manager without edititems permission cannot create any templates" => [
['mod/feedback:edititems'], false
@ -133,8 +131,7 @@ class create_template_form_test extends \advanced_testcase {
* @param string $loginas
* @param bool $public
* @param bool $accessallowed
* @dataProvider test_createtemplate_form_provider
* @throws \dml_exception
* @dataProvider createtemplate_form_provider
*/
public function test_createtemplate_form(string $loginas, bool $public,
bool $accessallowed = true) {
@ -183,7 +180,7 @@ class create_template_form_test extends \advanced_testcase {
*
* @return array
*/
public function test_createtemplate_form_provider(): array {
public function createtemplate_form_provider(): array {
return [
'Create a private template as an admin' => [
'admin', false

View File

@ -64,7 +64,7 @@ class use_template_form_test extends \advanced_testcase {
* @param string $loginas Which user to log in as
* @param bool $private Whether we are creating a private template
* @param bool $expected Whether or not the form should be validated
* @dataProvider test_usetemplate_form_provider
* @dataProvider usetemplate_form_provider
*/
public function test_usetemplate_form(string $loginas, bool $private, bool $expected) {
[$user, $feedback] = $this->setup_instance();
@ -100,7 +100,7 @@ class use_template_form_test extends \advanced_testcase {
*
* @return array
*/
public function test_usetemplate_form_provider() {
public function usetemplate_form_provider() {
return [
'Test submission with a private template as an admin' => [
'admin', true, true

View File

@ -115,7 +115,7 @@ class entities_discussion_test extends \advanced_testcase {
* Test the display period settings for discussions.
* This covers each individual date function as well as the combination of the 2.
*
* @dataProvider test_diplay_period_options_provider
* @dataProvider diplay_period_options_provider
* @param string $testdescription A basic description of the base assertions.
* @param int $startoffset Start time offset with current time in seconds.
* @param int $endoffset End time offset with current time in seconds.
@ -159,7 +159,7 @@ class entities_discussion_test extends \advanced_testcase {
*
* @return array start/end time offsets and the expected results.
*/
public function test_diplay_period_options_provider() {
public function diplay_period_options_provider() {
return array(
["No dates set", 0, 0, true, false, true],
["Only started date in the future", 100, 0, false, false, false],

View File

@ -260,7 +260,7 @@ class locallib_test extends \advanced_testcase {
*
* @return array
*/
public function test_get_last_attempt_dataprovider() {
public function get_last_attempt_dataprovider() {
return [
[0, [(object)['id' => 1], (object)['id' => 2], (object)['id' => 3]], (object)['id' => 3]],
[1, [(object)['id' => 1], (object)['id' => 2], (object)['id' => 3]], (object)['id' => 1]],
@ -273,7 +273,7 @@ class locallib_test extends \advanced_testcase {
/**
* Test the get_last_attempt() method.
*
* @dataProvider test_get_last_attempt_dataprovider
* @dataProvider get_last_attempt_dataprovider
* @param int $maxattempts Lesson setting.
* @param array $attempts The list of student attempts.
* @param object $expected Expected result.