MDL-70070 phpunit: correct data provider method names.

They should not be prefixed `test_` because that's how actual
test methods containing assertions are identified by PHPUnit.
This commit is contained in:
Paul Holden 2022-12-13 11:22:33 +00:00
parent fc01a52823
commit 1d74ef1255
17 changed files with 76 additions and 112 deletions

View file

@ -32,8 +32,7 @@ class logstore_database_store_testcase extends advanced_testcase {
* Tests log writing. * Tests log writing.
* *
* @param bool $jsonformat True to test with JSON format * @param bool $jsonformat True to test with JSON format
* @dataProvider test_log_writing_provider * @dataProvider log_writing_provider
* @throws moodle_exception
*/ */
public function test_log_writing(bool $jsonformat) { public function test_log_writing(bool $jsonformat) {
global $DB, $CFG; global $DB, $CFG;
@ -251,9 +250,9 @@ class logstore_database_store_testcase extends advanced_testcase {
* Returns different JSON format settings so the test can be run with JSON format either on or * Returns different JSON format settings so the test can be run with JSON format either on or
* off. * 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 [ return [
[false], [false],
[true] [true]

View file

@ -37,8 +37,7 @@ class logstore_standard_store_testcase extends advanced_testcase {
* Tests log writing. * Tests log writing.
* *
* @param bool $jsonformat True to test with JSON format * @param bool $jsonformat True to test with JSON format
* @dataProvider test_log_writing_provider * @dataProvider log_writing_provider
* @throws moodle_exception
*/ */
public function test_log_writing(bool $jsonformat) { public function test_log_writing(bool $jsonformat) {
global $DB; global $DB;
@ -222,9 +221,9 @@ class logstore_standard_store_testcase extends advanced_testcase {
* Returns different JSON format settings so the test can be run with JSON format either on or * Returns different JSON format settings so the test can be run with JSON format either on or
* off. * 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 [ return [
[false], [false],
[true] [true]
@ -367,7 +366,7 @@ class logstore_standard_store_testcase extends advanced_testcase {
* Tests the decode_other function can cope with both JSON and PHP serialized format. * Tests the decode_other function can cope with both JSON and PHP serialized format.
* *
* @param mixed $value Value to encode and decode * @param mixed $value Value to encode and decode
* @dataProvider test_decode_other_provider * @dataProvider decode_other_provider
*/ */
public function test_decode_other($value) { public function test_decode_other($value) {
$this->assertEquals($value, \logstore_standard\log\store::decode_other(serialize($value))); $this->assertEquals($value, \logstore_standard\log\store::decode_other(serialize($value)));
@ -386,7 +385,7 @@ class logstore_standard_store_testcase extends advanced_testcase {
* *
* @return array Array of parameters * @return array Array of parameters
*/ */
public function test_decode_other_provider(): array { public function decode_other_provider(): array {
return [ return [
[['info' => 'd2819896', 'logurl' => 'discuss.php?d=2819896']], [['info' => 'd2819896', 'logurl' => 'discuss.php?d=2819896']],
[null], [null],
@ -399,8 +398,7 @@ class logstore_standard_store_testcase extends advanced_testcase {
* Checks that backup and restore of log data works correctly. * Checks that backup and restore of log data works correctly.
* *
* @param bool $jsonformat True to test with JSON format * @param bool $jsonformat True to test with JSON format
* @dataProvider test_log_writing_provider * @dataProvider log_writing_provider
* @throws moodle_exception
*/ */
public function test_backup_restore(bool $jsonformat) { public function test_backup_restore(bool $jsonformat) {
global $DB; global $DB;

View file

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

View file

@ -2643,7 +2643,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
* Prevent user from reading other user's event. * Prevent user from reading other user's event.
* *
* @covers \core_calendar_external::get_calendar_event_by_id * @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 $isadminevent Is admin's event
* @param bool $isadmin Is current user admin user * @param bool $isadmin Is current user admin user
@ -2713,7 +2713,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
/** /**
* Test the behavior of deleting other users' user events. * 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 * @covers \core_calendar_external::delete_calendar_events
* @param bool $isadmin Whether the current user is admin. * @param bool $isadmin Whether the current user is admin.
* @param bool $isadminevent Whether it's an admin event or not. * @param bool $isadminevent Whether it's an admin event or not.
@ -2760,7 +2760,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
/** /**
* Test the behavior of editing other users' user events * 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 * @covers \core_calendar_external::submit_create_update_form
* @param bool $isadmin Whether the current user is admin. * @param bool $isadmin Whether the current user is admin.
* @param bool $isadminevent Whether it's an admin event or not. * @param bool $isadminevent Whether it's an admin event or not.

View file

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

View file

@ -14,15 +14,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // 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
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
global $CFG; global $CFG;
@ -31,6 +22,8 @@ require_once($CFG->dirroot.'/filter/mathjaxloader/filter.php');
/** /**
* Unit tests for the MathJax loader filter. * Unit tests for the MathJax loader filter.
* *
* @package filter_mathjaxloader
* @category test
* @copyright 2017 David Mudrak <david@moodle.com> * @copyright 2017 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
@ -42,7 +35,7 @@ class filter_mathjaxloader_filter_testcase extends advanced_testcase {
* @param string $moodlelangcode the user's current language * @param string $moodlelangcode the user's current language
* @param string $mathjaxlangcode the mathjax language to be used for the moodle 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) { public function test_map_language_code($moodlelangcode, $mathjaxlangcode) {
@ -55,7 +48,7 @@ class filter_mathjaxloader_filter_testcase extends advanced_testcase {
* *
* @return array of [moodlelangcode, mathjaxcode] tuples * @return array of [moodlelangcode, mathjaxcode] tuples
*/ */
public function test_map_language_code_expected_mappings() { public function map_language_code_expected_mappings() {
return [ return [
['cz', 'cs'], // Explicit mapping. ['cz', 'cs'], // Explicit mapping.

View file

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

View file

@ -14,15 +14,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // 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; namespace core_h5p;
use core_collator; use core_collator;
@ -32,6 +23,7 @@ use core_collator;
* Test class covering the H5PFrameworkInterface interface implementation. * Test class covering the H5PFrameworkInterface interface implementation.
* *
* @package core_h5p * @package core_h5p
* @category test
* @copyright 2019 Mihail Geshoski <mihail@moodle.com> * @copyright 2019 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
@ -587,7 +579,7 @@ class framework_testcase extends \advanced_testcase {
/** /**
* Test the behaviour of isPatchedLibrary(). * Test the behaviour of isPatchedLibrary().
* *
* @dataProvider test_isPatchedLibrary_provider * @dataProvider isPatchedLibrary_provider
* @param array $libraryrecords Array containing data for the library creation * @param array $libraryrecords Array containing data for the library creation
* @param array $testlibrary Array containing the test library data * @param array $testlibrary Array containing the test library data
* @param bool $expected The expectation whether the library is patched or not * @param bool $expected The expectation whether the library is patched or not
@ -609,7 +601,7 @@ class framework_testcase extends \advanced_testcase {
* *
* @return array * @return array
*/ */
public function test_isPatchedLibrary_provider(): array { public function isPatchedLibrary_provider(): array {
return [ return [
'Unpatched library. No different versioning' => [ 'Unpatched library. No different versioning' => [
[ [
@ -1365,7 +1357,7 @@ class framework_testcase extends \advanced_testcase {
/** /**
* Test the behaviour of loadLibrarySemantics(). * Test the behaviour of loadLibrarySemantics().
* *
* @dataProvider test_loadLibrarySemantics_provider * @dataProvider loadLibrarySemantics_provider
* @param array $libraryrecords Array containing data for the library creation * @param array $libraryrecords Array containing data for the library creation
* @param array $testlibrary Array containing the test library data * @param array $testlibrary Array containing the test library data
* @param string $expected The expected semantics value * @param string $expected The expected semantics value
@ -1388,7 +1380,7 @@ class framework_testcase extends \advanced_testcase {
* *
* @return array * @return array
*/ */
public function test_loadLibrarySemantics_provider(): array { public function loadLibrarySemantics_provider(): array {
$semantics = json_encode( $semantics = json_encode(
[ [
@ -2157,7 +2149,7 @@ class framework_testcase extends \advanced_testcase {
/** /**
* Test the behaviour of test_libraryHasUpgrade(). * 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 $libraryrecords Array containing data for the library creation
* @param array $testlibrary Array containing the test library data * @param array $testlibrary Array containing the test library data
* @param bool $expected The expectation whether the library is patched or not * @param bool $expected The expectation whether the library is patched or not
@ -2179,7 +2171,7 @@ class framework_testcase extends \advanced_testcase {
* *
* @return array * @return array
*/ */
public function test_libraryHasUpgrade_provider(): array { public function libraryHasUpgrade_provider(): array {
return [ return [
'Lower major version; Identical lower version' => [ 'Lower major version; Identical lower version' => [
[ [

View file

@ -14,23 +14,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // 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; namespace core_h5p;
use core_h5p\local\library\autoloader; 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 * @package core_h5p
* @category test * @category test
@ -165,7 +154,7 @@ class generator_testcase extends \advanced_testcase {
* Test the behaviour of generate_h5p_data(). Test whether library files are created or not * Test the behaviour of generate_h5p_data(). Test whether library files are created or not
* on filesystem depending what the method defines. * 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 $createlibraryfiles Whether to create library files on the filesystem
* @param bool $expected The expectation whether the files have been created or not * @param bool $expected The expectation whether the files have been created or not
**/ **/
@ -205,7 +194,7 @@ class generator_testcase extends \advanced_testcase {
* *
* @return array * @return array
*/ */
public function test_generate_h5p_data_files_creation_provider(): array { public function generate_h5p_data_files_creation_provider(): array {
return [ return [
'Do not create library related files on the filesystem' => [ 'Do not create library related files on the filesystem' => [
false, false,
@ -256,7 +245,7 @@ class generator_testcase extends \advanced_testcase {
* Test the behaviour of create_h5p_record(). Test whather the h5p content data is * Test the behaviour of create_h5p_record(). Test whather the h5p content data is
* properly saved in the database. * properly saved in the database.
* *
* @dataProvider test_create_h5p_record_provider * @dataProvider create_h5p_record_provider
* @param array $h5pdata The h5p content data * @param array $h5pdata The h5p content data
* @param \stdClass $expected The expected saved data * @param \stdClass $expected The expected saved data
**/ **/
@ -282,7 +271,7 @@ class generator_testcase extends \advanced_testcase {
* *
* @return array * @return array
*/ */
public function test_create_h5p_record_provider(): array { public function create_h5p_record_provider(): array {
$createdjsoncontent = json_encode( $createdjsoncontent = json_encode(
array( array(
'text' => '<p>Created dummy text<\/p>\n', 'text' => '<p>Created dummy text<\/p>\n',
@ -379,7 +368,7 @@ class generator_testcase extends \advanced_testcase {
* Test the behaviour of create_contents_libraries_record(). Test whether the contents libraries * Test the behaviour of create_contents_libraries_record(). Test whether the contents libraries
* are properly saved in the database. * 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 array $contentslibrariestdata The h5p contents libraries data.
* @param \stdClass $expected The expected saved data. * @param \stdClass $expected The expected saved data.
**/ **/
@ -403,7 +392,7 @@ class generator_testcase extends \advanced_testcase {
* *
* @return array * @return array
*/ */
public function test_create_contents_libraries_record_provider(): array { public function create_contents_libraries_record_provider(): array {
return [ return [
'Create h5p content library with set dependency type' => [ 'Create h5p content library with set dependency type' => [
[ [
@ -439,7 +428,7 @@ class generator_testcase extends \advanced_testcase {
* Test the behaviour of create_library_dependency_record(). Test whether the contents libraries * Test the behaviour of create_library_dependency_record(). Test whether the contents libraries
* are properly saved in the database. * 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 array $librarydependencydata The library dependency data.
* @param \stdClass $expected The expected saved data. * @param \stdClass $expected The expected saved data.
**/ **/
@ -463,7 +452,7 @@ class generator_testcase extends \advanced_testcase {
* *
* @return array * @return array
*/ */
public function test_create_library_dependency_record_provider(): array { public function create_library_dependency_record_provider(): array {
return [ return [
'Create h5p library dependency with set dependency type' => [ 'Create h5p library dependency with set dependency type' => [
[ [
@ -494,7 +483,7 @@ class generator_testcase extends \advanced_testcase {
/** /**
* Test the behaviour of create_content_file(). Test whether a file belonging to a content is created. * 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 $filedata Data from the file to be created.
* @param array $expecteddata Data expected.Data from the file to be created. * @param array $expecteddata Data expected.Data from the file to be created.
*/ */
@ -529,7 +518,7 @@ class generator_testcase extends \advanced_testcase {
* *
* @return array * @return array
**/ **/
public function test_create_content_file_provider(): array { public function create_content_file_provider(): array {
return [ return [
'Create file in content with id 4' => [ 'Create file in content with id 4' => [
[ [

View file

@ -2258,7 +2258,7 @@ class core_ddl_testcase extends database_driver_testcase {
* *
* @return array The type-value pair fixture. * @return array The type-value pair fixture.
*/ */
public function test_get_enc_quoted_provider() { public function get_enc_quoted_provider() {
return array( return array(
// Reserved: some examples from SQL-92. // Reserved: some examples from SQL-92.
[true, 'from'], [true, 'from'],
@ -2272,7 +2272,7 @@ class core_ddl_testcase extends database_driver_testcase {
/** /**
* This is a test for sql_generator::getEncQuoted(). * 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 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. * @param string $columnname The column name to be quoted, according to the value of $reserved.
**/ **/
@ -2307,7 +2307,7 @@ class core_ddl_testcase extends database_driver_testcase {
* *
* @return array The type-old-new tuple fixture. * @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( return array(
// Reserved: an example from SQL-92. // Reserved: an example from SQL-92.
// Both names should be reserved. // Both names should be reserved.
@ -2320,7 +2320,7 @@ class core_ddl_testcase extends database_driver_testcase {
/** /**
* This is a unit test for sql_generator::getRenameFieldSQL(). * 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 bool $reserved Whether the column name is reserved or not.
* @param string $oldcolumnname The column name to be renamed. * @param string $oldcolumnname The column name to be renamed.
* @param string $newcolumnname The new column name. * @param string $newcolumnname The new column name.

View file

@ -142,7 +142,7 @@ TBC;
/** /**
* Data provider for the test_load function. * Data provider for the test_load function.
*/ */
public function test_load_test_cases() { public function load_test_cases() {
$cache = [ $cache = [
'core' => [ 'core' => [
'test' => '{{! a comment }}The rest of the template' 'test' => '{{! a comment }}The rest of the template'
@ -171,7 +171,7 @@ TBC;
/** /**
* Test the load function. * Test the load function.
* *
* @dataProvider test_load_test_cases() * @dataProvider load_test_cases
* @param mustache_template_source_loader $loader The loader * @param mustache_template_source_loader $loader The loader
* @param string $component The moodle component * @param string $component The moodle component
* @param string $name The template name * @param string $name The template name
@ -185,7 +185,7 @@ TBC;
/** /**
* Data provider for the load_with_dependencies function. * 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 // 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 // multiple instances of recursive inclusions to test that the code doensn't get
// stuck in an infinite loop. // stuck in an infinite loop.
@ -338,7 +338,7 @@ TBC;
/** /**
* Test the load_with_dependencies function. * 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 mustache_template_source_loader $loader The loader
* @param string $component The moodle component * @param string $component The moodle component
* @param string $name The template name * @param string $name The template name
@ -352,7 +352,7 @@ TBC;
/** /**
* Data provider for the test_load function. * 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}}'; $foo = '{{! a comment }}{{> core/bar }}{{< test/bop }}{{/ test/bop}}{{#str}} help, core {{/str}}';
$bar = '{{! a comment }}{{> core/baz }}'; $bar = '{{! a comment }}{{> core/baz }}';
$baz = '{{! a comment }}{{#str}} hide, core {{/str}}'; $baz = '{{! a comment }}{{#str}} hide, core {{/str}}';
@ -496,7 +496,7 @@ TEMPLATE;
/** /**
* Test the scan_template_source_for_dependencies function. * 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 mustache_template_source_loader $loader The loader
* @param string $source The template to test * @param string $source The template to test
* @param string $expected The expected output * @param string $expected The expected output

View file

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

View file

@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die();
*/ */
class core_task_manager_testcase extends advanced_testcase { class core_task_manager_testcase extends advanced_testcase {
public function test_ensure_adhoc_task_qos_provider() { public function ensure_adhoc_task_qos_provider() {
return [ return [
[ [
[], [],
@ -176,7 +176,7 @@ class core_task_manager_testcase extends advanced_testcase {
/** /**
* Test that the Quality of Service reordering works. * Test that the Quality of Service reordering works.
* *
* @dataProvider test_ensure_adhoc_task_qos_provider * @dataProvider ensure_adhoc_task_qos_provider
* *
* @param array $input array of tasks * @param array $input array of tasks
* @param array $expected array of reordered tasks * @param array $expected array of reordered tasks

View file

@ -6806,7 +6806,7 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
/** /**
* Test the get_conversation_counts() function. * 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 array $conversationconfigs Conversations to create
* @param int $deletemessagesuser The user who is deleting the messages * @param int $deletemessagesuser The user who is deleting the messages
* @param array $deletemessages The list of messages to delete (by index) * @param array $deletemessages The list of messages to delete (by index)
@ -6929,7 +6929,7 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
/** /**
* Test the get_unread_conversation_counts() function. * 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 array $conversationconfigs Conversations to create
* @param int $deletemessagesuser The user who is deleting the messages * @param int $deletemessagesuser The user who is deleting the messages
* @param array $deletemessages The list of messages to delete (by index) * @param array $deletemessages The list of messages to delete (by index)

View file

@ -6803,7 +6803,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
/** /**
* Data provider for test_get_conversation_counts(). * 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; $typeindividual = \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL;
$typegroup = \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP; $typegroup = \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP;
$typeself = \core_message\api::MESSAGE_CONVERSATION_TYPE_SELF; $typeself = \core_message\api::MESSAGE_CONVERSATION_TYPE_SELF;
@ -7166,7 +7166,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
/** /**
* Test the get_conversation_counts() function. * 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 array $conversationconfigs Conversations to create
* @param int $deletemessagesuser The user who is deleting the messages * @param int $deletemessagesuser The user who is deleting the messages
* @param array $deletemessages The list of messages to delete (by index) * @param array $deletemessages The list of messages to delete (by index)
@ -7263,7 +7263,7 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
/** /**
* Test the get_unread_conversation_counts() function. * 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 array $conversationconfigs Conversations to create
* @param int $deletemessagesuser The user who is deleting the messages * @param int $deletemessagesuser The user who is deleting the messages
* @param array $deletemessages The list of messages to delete (by index) * @param array $deletemessages The list of messages to delete (by index)

View file

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

View file

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