252 Commits

Author SHA1 Message Date
Andrew Nicols
55126be4ad
MDL-81520 core: Fix test finality 2024-12-11 12:30:21 +08:00
Andrew Nicols
c6942c9bb7
MDL-81521 core: Update all possibly data providers to be static
Note: Some data providers could not be automatically be converted to
being static. These will be handled in a separate issue.
2024-11-18 10:24:55 +08:00
Eloy Lafuente (stronk7)
1093256560
MDL-81522 phpunit: Add missing void return type to all tests
While this change is not 100% required now, it's good habit
and we are checking for it since Moodle 4.4.

All the changes in this commit have been applied automatically
using the moodle.PHPUnit.TestReturnType sniff and are, exclusively
adding the ": void" return types when missing.
2024-06-11 12:18:04 +02:00
Jordan Tomkinson
c1b4ccc4c6 MDL-81751 ddl: new reserved keywords in Aurora MySQL database engine 2024-05-16 13:41:29 +01:00
Eloy Lafuente (stronk7)
361dfe8145
MDL-75952 general: Since php81, refection->setAccessible() is no-op
Refereces:
- https://wiki.php.net/rfc/make-reflection-setaccessible-no-op
- https://www.php.net/manual/en/reflectionproperty.setaccessible.php
- https://www.php.net/manual/en/reflectionmethod.setaccessible.php

As of PHP 8.1.0, calling this method has no effect; all methods are
invokable by default. So, let's remove all uses from core, they are
no-op.
2024-03-10 21:15:00 +01:00
Eloy Lafuente (stronk7)
29a541724f
MDL-65292 style: Fix all the function declaration ordering
This has been generated running the following Sniff,
part of the Moodle's CodeSniffer standard:
- PSR2.Methods.MethodDeclaration

It just ensures all the function declarations have
the correct order for:
- abstract and final.
- visibility (public, protected, private).
- static.

So, all the lines modified by this commit are function declarations
and the only changes are in the positions of those keywords.
2024-02-28 23:47:47 +01:00
Eloy Lafuente (stronk7)
ba1f804ffa
MDL-65292 style: Fix all function declarations white space
This has been generated running the following Sniffs, all
them part of the Moodle's CodeSniffer standard:
- PSR12.Functions.ReturnTypeDeclaration
- PSR12.Functions.NullableTypeDeclaration
- moodle.Methods.MethodDeclarationSpacing
- Squiz.Whitespace.ScopeKeywordSpacing

All them are, exclusively, about correct spacing, so the changes
are, all them, only white space changes.

Only exceptions to the above are 3 changes what were setting the
return type in a new line, and, when that happens, the closing
parenthesis (bracket) has to go to the same line than the colon.
2024-02-28 23:33:26 +01:00
Marina Glancy
8fc1486d36 MDL-77164 various: fix incorrect phpdocs 2023-04-13 11:35:06 +01:00
Paul Holden
af8da7c737 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.
2023-01-16 08:28:37 +00:00
Eloy Lafuente (stronk7)
83b490a594 MDL-75111 phpunit: Move tests to use correct names and ns (take#4)
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- The following task tests have been moved within the level2 directory:
  - \core\adhoc_task_test => \core\task\adhoc_task_test
  - \core\scheduled_task_test => \core\task\scheduled_task_test
  - \core\calendar_cron_task_test => \core\task\calendar_cron_task_test
  - \core\h5p_get_content_types_task_test => \core\task\h5p_get_content_types_task_test
  - \core\task_database_logger_test => \core\task\database_logger_test
  - \core\task_logging_test => \core\task\logging_test

- The following event tests have been moved within level2 directory:
  - \core\event_context_locked_test => \core\event\context_locked_test
  - \core\event_deprecated_test => \core\event\deprecated_test
  - \core\event_grade_deleted_test => \core\event\grade_deleted_test
  - \core\event_profile_field_test => \core\event\profile_field_test
  - \core\event_unknown_logged_test => \core\event\unknown_logged_test
  - \core\event_user_graded_test => \core\event\user_graded_test
  - \core\event_user_password_updated_test => \core\event\user_password_updated_test

- The following output tests have been moved within level2 directory:
  - \core\mustache_template_finder_test => \core\output\mustache_template_finder_test
  - \core\mustache_template_source_loader_test => \core\output\mustache_template_source_loader_test
  - \core\output_mustache_helper_collection_test => \core\output\mustache_helper_collection_test

- The following tests have been moved to their correct tests directories:
  - lib/tests/time_splittings_test.php => analytics/tests/time_splittings_test.php

- All the classes and tests under lib/filebrowser and lib/filestorage
  belong to core, not to core_files. Some day we should move
  them to their correct subsystem.
- All the classes and tests under lib/grade belong to core, not
  to core_grades. Some day we should move them to their correct
  subsystem.
- The core_grades_external class and its \core\grades_external_test
  unit test should belong to the grades subsystem or, alternatively,
  to \core\external, they both should be moved together.
- The core_grading_external class and its \core\grading_external_test
  unit test should belong to the grading subsystem or, alternatively,
  to \core\external, they both should be moved together.
- The \core\message\message and \core\message\inbound (may be others)
  classes, and their associated tests should go to the core_message
  subsystem.
- The core_user class, and its associated tests should go to the
  core_user subsystem.
- The \core\update namespace is plain wrong (update is not valid API)
  and needs action 1) create it or 2) move elsewhere.
2022-08-26 16:34:20 +02:00
Tomo Tsuyuki
cb4e37c462 MDL-73095 core_ddl: Fix binary type field check 2021-11-18 17:53:00 +11:00
Eloy Lafuente (stronk7)
ba5b6089d5 MDL-71036 phpunit: Renamed various regexp-related assertions
In PHPUnit 9.1, the following regexp-related assertions
have been deprecated and there are new alternatives for
all them:
    - assertRegExp()     -> assertMatchesRegularExpression()
    - assertNotRegExp()  -> assertDoesNotMatchRegularExpression()

This is about to, simply, move all cases to the new alternatives.

Source: https://github.com/sebastianbergmann/phpunit/blob/9.1.0/ChangeLog-9.1.md

Regexp to find all them:

    ag 'assertRegExp|assertNotRegExp' -li
2021-03-11 19:22:24 +01:00
Marina Glancy
f4fb91aecb MDL-70920 core: prevent calls to call_user_fun_array() with assoc array 2021-02-21 22:22:21 +01:00
Eloy Lafuente (stronk7)
3a5641cb74 MDL-67673 phpunit: Remove deprecated assertEquals() params
The optional parameters of assertEquals() and assertNotEquals()
are deprecated in PHPUnit 8 (to be removed in PHPUnit 9):

- delta => use assertEqualsWithDelta()
- canonicalize => use assertEqualsCanonicalizing()
- ignoreCase => use assertEqualsIgnoringCase
- maxDepth => removed without replacement.

More info @ https://github.com/sebastianbergmann/phpunit/issues/3341

Initial search done with:

ag 'assert(Not)?Equals\(.*,.*,' --php

Then, running tests and fixing remaining cases.
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
f6711bb394 MDL-67673 phpunit: Fix the return type of template methods
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.

At the same time, fix a few wrong function names,
provider data and param types, return statements...
2020-10-21 12:45:59 +02:00
Eloy Lafuente (stronk7)
d584d34967 MDL-67886 phpunit: Make tests cross-db
The suggested SQL in some of the assertions was not cross-db
but db-dependent. Now we just keep that part out from the
assertions, because it's not important to verify the
errors that are being asserted.
2020-04-23 13:03:03 +02:00
Mark Nelson
47f3fa131a MDL-67886 core: check_database_schema() checks for extra indexes 2020-04-23 00:45:43 +02:00
Mark Nelson
a8c38ce85b MDL-67886 core: check_database_schema() checks for missing indexes 2020-04-22 23:22:18 +02:00
Shamim Rezaie
94e25092b2 MDL-58584 core_ddl: delete te loft over table in the test 2020-02-04 23:15:32 +11:00
Shamim Rezaie
934c2ee1b6 MDL-58584 core_ddl: getDropTableSQL should not do more than what it says 2020-02-03 15:07:15 +11:00
Brendan Heywood
97f63b4180 MDL-65311 core: Fixed regression caused by MDL-65130 2019-04-09 22:39:02 +10:00
Andrew Nicols
09d02b3914 MDL-65130 privacy: Fix memory hungry test 2019-03-21 09:52:24 +08:00
Tim Hunt
5abc431335 MDL-63020 ddl: fix nullable unique indexes in OCI and MS SQL
This works-around the default non-standard behaviour of these DB engines.
2018-09-20 17:41:22 +01:00
Tim Hunt
54b2b1d27f MDL-63020 xmldb: Improve PHPdoc comments for better IDE autocomplete 2018-09-20 17:41:22 +01:00
Matteo Scaramuccia
211d04f43e MDL-63319 ddl: Added getRenameFieldSQL() coverage 2018-09-14 22:41:18 +02:00
Matteo Scaramuccia
66c34d3578 MDL-63319 ddl: Improved rename_field() coverage
DB API should allow to rename fields, including renaming
those columns named using a reserved word.
2018-09-14 22:41:18 +02:00
Matteo Scaramuccia
12b6041aac MDL-63319 ddl: MSSQL should rename reserved words 2018-09-14 22:31:39 +02:00
Matteo Scaramuccia
0fb34e9108 MDL-63319 ddl: MySQL should rename reserved words 2018-09-14 22:31:39 +02:00
Matteo Scaramuccia
1f8d943461 MDL-59596 ddl: Support MariaDB 10.2.4+ SQL_MODE new default value. 2018-03-26 23:12:36 +02:00
Jake Dallimore
fa2a9cc933 MDL-23887 database: fix use of deprecated system tables for mssql
Catalog views are available which we should use instead.
2018-01-02 17:19:17 +08:00
David Mudrák
7cdb4266e0 MDL-32113 xmldb: Fix and extend unit tests for XMLDB_TYPE_NUMBER
These tests describe the new behaviour of the XMLDB_TYPE_NUMBER fields.
2017-12-21 19:48:04 +01:00
David Mudrák
457eaef9ec MDL-32113 xmldb: Remove hard-coded exceptions for long number fields
We are going to unify the maximum supported precision of all numeric
fields to 38 digits (which are the current Oracle and MSSQL limits). Get
rid of hard-coded exceptions for longer fields.
2017-12-21 15:37:08 +01:00
Matteo Scaramuccia
e8be9e7646 MDL-60793 core_ddl: Added the new MySQL 8 reserved words 2017-12-14 22:46:48 +01:00
Matteo Scaramuccia
596f4e6a23 MDL-59635 ddl: Added test_get_enc_quoted(). 2017-09-04 11:46:54 +02:00
Dan Poltawski
23e1ce7d52 Merge branch 'wip-MDL-59476-master-2' of git://github.com/marinaglancy/moodle 2017-07-31 10:21:32 +01:00
Dan Poltawski
afa752eb12 Merge branch 'MDL-57698-master' of https://github.com/xow/moodle 2017-07-25 11:48:09 +01:00
Marina Glancy
c07c8c6e3e MDL-59476 dml: temporary mysql tables should not use compressed rows 2017-07-25 13:49:53 +08:00
John Okely
469ffa6893 MDL-57698 mssql: Update reserve word list for generator 2017-07-21 14:41:55 +08:00
Adrian Greeve
3a8c989137 MDL-59561 database: Update to creating new indexes in mysql.
When updating the mysql system to utf8mb4 not all tables are
converted to the row format of compressed or dynamic. If a new
index is created there is a possibility that the table could be
using compact or redundant and then an error will be shown saying
that the index size is too large. This fix handles this exception
and converts the table over to compressed.
2017-07-21 09:27:08 +08:00
Eric Merrill
cd729dc905 MDL-58593 database: More efficiently track issued key names 2017-04-13 12:21:13 -04:00
Adrian Greeve
8c1288dbdb MDL-48228 database: Unit test addition and update. 2017-03-01 09:03:12 +08:00
Adrian Greeve
0bbefd81cd MDL-48228 database: Make utf8mb4 the default character set for mysql.
Thanks to Jetha Chan for providing the initial patch that this is
based on.
2017-03-01 09:03:12 +08:00
Russell Smith
848d212e7a MDL-53495 database xmldb: Ensure field tests use constant.
Some tests were still using hard coded values which break
if the constants are changed.
2016-07-06 14:45:00 +10:00
Russell Smith
0b768e744f MDL-53495 database xmldb: Use real length restriction. 2016-06-08 11:06:16 +10:00
Simey Lameze
87a3e50192 MDL-51374 core_dml: change database layer to pass table name as parameter 2016-03-15 14:43:45 +08:00
Russell Smith
d22a01fd99 MDL-53213 caching: Faster databasemeta caching for all databases. 2016-02-28 17:03:14 +11:00
Mark Nelson
5e156fe8ce MDL-49724 core_ddl: final deprecation of guess_antolope_row_size() 2016-01-06 10:38:22 +08:00
Simey Lameze
0148cd852e MDL-49723 tool: deprecate guess_antolope_row_size method 2015-04-10 09:33:35 +08:00
Damyon Wiese
112632ed58 Merge branch 'wip_MDL-46235_m28_innodbtext' of https://github.com/skodak/moodle 2014-08-26 12:28:47 +08:00
Petr Skoda
a45d54b8cb MDL-46235 ddl: add support for large number of text fields in one database table 2014-08-25 12:40:57 +12:00