151 Commits

Author SHA1 Message Date
Andrew Nicols
5be481d1d0
MDL-81520 core: Fix test finality 2024-12-11 12:30:21 +08:00
Andrew Nicols
3d51aed3e2
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-19 09:30:51 +08:00
Paul Holden
a9cc2ebb6e
MDL-82431 phpunit: correct unit test filename and classname.
Standardise the same test cases, e.g. make final, covers notation,
static data providers, namespaces, etc.

Once the tests run, a couple of them failed. They required changes
to assertions to make them pass.
2024-07-10 19:06:11 +01:00
Eloy Lafuente (stronk7)
ff263b6dbc
MDL-82148 phpunit: Remove all cases of multiple @coversDefaultClass
Only one by class is allowed (to be used as shortcut exclusively).
2024-06-14 16:05:48 +02:00
Andrew Nicols
77a0a535b3 MDL-76362 core_privacy: Shortcircuit URL rewriting on empty content 2023-01-23 09:16:08 +08:00
Marina Glancy
2dd7290ccb MDL-76362 various: Avoid passing nulls to functions that don't allow nulls
PHP 8.1 is more strict on the parameter type. Functions such as trim(), strlen(), str_replace(), etc
show notice when null is passed as an argument
2023-01-23 09:16:06 +08:00
Jun Pataleta
fb302fe40f Merge branch 'MDL-75469-master' of https://github.com/kevpercy/moodle 2022-10-31 17:10:23 +08:00
Marina Glancy
41b93bd7e5 MDL-73424 general: Internal methods must have same type as parent
Otherwise the error is thrown in PHP8.1
2022-10-10 16:46:13 +02:00
Kevin Percy
c53f9f2db8 MDL-75469 lib: Update jQuery to 3.6.1, jQuery UI to 1.13.2 2022-10-05 13:55:56 +08:00
Eloy Lafuente (stronk7)
caf55abf17 MDL-74413 phpunit: Move more tests to use correct names and namespaces
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:

- Moved to the level2 "privacy" namespace:
  - \mod_assign\privacy\feedback_legacy_polyfill_test
  - \mod_assign\privacy\submission_legacy_polyfill_test

- Moved to the level2 "task" namespace:
  - \core_message\task\migrate_message_data_test
  - \ltiservice_gradebookservices\task\cleanup_test
  - \message_email\task\send_email_test
  - \mod_lti\task\clean_access_tokens_test
  - \mod_workshop\task\cron_task_test

- Moved to the level2 "event" namespace:
  - \core_h5p\event\deleted_test
  - \core_h5p\event\viewed_test

- Renamed to a better name:
  - backup_forum_activity_task_test.php (missing "task")
2022-05-07 20:32:30 +02:00
Eloy Lafuente (stronk7)
7a0d024e60 MDL-73659 phpunit: restore_date, api, rule, plugin, manager & helper
All restore_date_test, api_test, rule_test, plugin_test,
manager_test, helper_test 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:

- All restore_date_test cases have been put under xxx\backup
  level 2 (valid API) namespace.
2022-02-05 00:03:32 +01:00
Sara Arjona
f667bdfb33 MDL-71704 lib: Set Moodle files after JQuery upgrade 2022-01-11 12:07:20 +01:00
Jun Pataleta
80c17cd2a0 Merge branch 'MDL-72701-master' of https://github.com/andrewnicols/moodle 2021-12-23 12:10:46 +08:00
Andrew Nicols
3a70983d53 MDL-72701 unit tests: Generate default coverage 2021-12-21 09:24:00 +08:00
Eloy Lafuente (stronk7)
e4a2d9c1d4 MDL-73348 phpunit: normalize all privacy provider tests
As far as now all them have correct privacy level2 namespace:
- Move them to "privacy" subdir.
- Rename the files to "provider_test.php", this includes old
  privacy_test.php and privacy_provider_test.php files
- Rename the testcase to provider_test too (to match file name)

Also, change some relative paths and comments to point to new
locations.
2021-12-17 14:21:02 +01:00
Eloy Lafuente (stronk7)
57e6fb7ad9 MDL-73348 phpunit: privacy and privacy_provider testcase names
All privacy_test and privacy_provider_test classes:

- Namespaced with component\privacy.
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed.
- Renamed a few files to make all be privacy_test or privacy_provider_test.php
- All them passing individually.
- Complete runs passing too.
2021-12-17 14:21:02 +01:00
Sara Arjona
3f2f2e85bb MDL-72115 course: Rename Miscellaneous category
The "Miscellaneous" course category has been renamed to Category 1.
Besides, the description field has been set from FORMAT_MOODLE to
FORMAT_HTML.
2021-09-13 08:36:17 +02:00
Ferran Recio
21d93554d4 MDL-71863 courseformat: create courseformat subsystem 2021-06-28 13:50:18 +02:00
Mahmoud Kassaei
95782015ba MDL-71258 questions: privacy support for settings defaults preferences 2021-04-30 10:14:38 +01:00
Eloy Lafuente (stronk7)
cfba0366db Merge branch 'MDL-70893-master' of git://github.com/marinaglancy/moodle 2021-03-18 00:23:26 +01:00
Eloy Lafuente (stronk7)
9fd6ac7c9d MDL-71036 phpunit: xml config - switch coverage info to new includes
This applies the "whitelist" => "include" changes to all the core
phpunit_coverage_info occurrences, so core won't emit any deprecation
warning (see previous commit).

At the same time, modified a bunch of comments in coverage files
to be more readable/understandable.
2021-03-11 23:04:32 +01:00
Eloy Lafuente (stronk7)
81407f18ec MDL-71036 phpunit: Mock->setMethods() silently deprecated
The current ->setMethods() has been silently (won't emit any
warning) in PHPUnit 9. And will stop working (current plans)
in PHPUnit 10.

Basically the now deprecated method has been split into:

- onlyMethods(): To point to existing methods in the mocked artifact.
- addMethods(): To point to non existing (yet) methods in the mocked
  artifact.

In practice that means that all our current setMethods() calls can be
converted to onlyMethods() (existing) and done. The addMethods() is
mostly useful on development phases, not final testing.

Finally note that <null> isn't accepted anymore as parameter to
double all the methods. Instead empty array [] must be used.

Link: https://github.com/sebastianbergmann/phpunit/issues/3770
2021-03-11 23:04:31 +01:00
Eloy Lafuente (stronk7)
8a14a7bd22 MDL-71036 phpunit: assertContains() now performs strict comparison
The methods assertContains() and assertNotContains() now perform
strict (type and value) comparison, pretty much like assertSame()
does.

A couple of new assertContainsEquals() and assertNotContainsEquals()
methods have been created to provide old (non-strict) behavior, pretty
much like assertEquals() do.

Apart from replacing the calls needing a relaxed comparison to those
new methods, there are also a couple of alternative, about how to
fix this, depending of every case:

- If the test is making any array_values() conversion, then it's better
  to remove that conversion and use assertArrayHasKey(), that is not
  strict.
- Sometimes if may be also possible to, simply, cast the expectation
  to the exact type coming in the array. I've not applied this technique
  to any of the cases in core.

Link: https://github.com/sebastianbergmann/phpunit/issues/3426
2021-03-11 23:04:31 +01: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
Ilya Tregubov
ec47946ea9 MDL-69680 lib: Update jQuery version in Moodle files 2021-03-04 12:48:26 +08:00
Marina Glancy
0eada7a5f9 MDL-70893 various: optional function arguments must be in the end 2021-02-15 16:53:37 +01:00
Eloy Lafuente (stronk7)
f94195c320 MDL-67673 phpunit: Remove deprecated assertInternalType()
While this is not strictly required, because removal will
happen in PHPUnit 9.0, we are already getting rid of all
uses in core.

From release notes:https://phpunit.de/announcements/phpunit-8.html

assertInternalType() is deprecated and will be removed in
PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(),
assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(),
assertIsResource(), assertIsString(), assertIsScalar(),
assertIsCallable(), or assertIsIterable() instead.
2020-10-21 12:45:59 +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)
de245163e3 MDL-68875 privacy: Keep moodle_content_writer->get_path() the same
In MDL-62853 a new clean_param(PARAM_PATH) was added to the
moodle_content_writer->get_path() method. And this caused some
Windows tests to start failing.

The problem is that clean_param(PARAM_PATH) does normalise directory
separators to be always forward backslashes and that's normally ok
but the get_path() method has some DIRECTORY_SEPARATOR dependent code
that stopped working under windows.

After analysing various solutions, and trying to keep the behavior
EXACTLY like it was before MDL-62853, but with the cleaning included
we have applied 2 changes:

b) Move the clean_param() to later within the array_map() function,
that way the code there, that uses DIRECTORY_SEPARATOR will continue
working the same.

b) As far as there are more DIRECTORY_SEPARATOR dependent code later
in the function, also perform a str_replace() to convert back to the
OS directory separator.

Those 2 points together (a and b) make the behavior to be 100% the
original one, with separators being kept and the paths being cleaned.

This solution corresponds 100% with the proposed fixes named 3) and
4) in the issue.

Final note... all that DIRECTORY_SEPARATOR maybe needs a review because
it really shouldn't be used unless strictly needed. But that falls out
from this issue which goal was to keep things safely working like they
were before the regression (but with the cleaning applied).
2020-06-02 15:53:40 +02:00
Jake Dallimore
33294da864 Merge branch 'MDL-62853' of https://github.com/paulholden/moodle 2020-05-25 16:11:55 +08:00
cescobedo
aeacd6c862 MDL-67798 core_contentbank: Add privacy provider 2020-04-24 16:39:41 +02:00
Paul Holden
d99e0ab7a2 MDL-62853 privacy: sanitize subcontext paths. 2020-04-21 14:38:22 +01:00
Jun Pataleta
3a836cc110 MDL-66245 privacy: Encode each part of the data URL instead of the whole 2020-02-10 16:55:11 +08:00
Paul Holden
07dc0cad34 MDL-64695 privacy: filter site fullname in data export. 2019-12-12 18:20:13 +00:00
Andrew Nicols
fe0944987e MDL-66011 test: remove magic @covers lines 2019-10-04 09:40:34 +08:00
Adrian Greeve
f05c426357 MDL-66710 privacy: Update to template to reference js file right. 2019-09-19 10:42:48 +08:00
Mihail Geshoski
88d2bc81c8 MDL-65751 lib: Update jQuery version in Moodle files 2019-07-15 08:45:34 +08:00
Paul Holden
b4d999a5a6 MDL-64511 privacy: encode data URL when loading content.
Previously paths that included ? or # characters would break loading.
2019-06-28 13:16:16 +01:00
Eloy Lafuente (stronk7)
594717128d MDL-62459 database: remove unused table role_sortorder 2019-04-22 01:37:14 +02:00
Andrew Nicols
bc01342057 MDL-65130 privacy: Add @covers annotation to tests 2019-03-21 10:29:07 +08:00
Andrew Nicols
09d02b3914 MDL-65130 privacy: Fix memory hungry test 2019-03-21 09:52:24 +08:00
Andrew Nicols
306ce452ab MDL-63366 core_privacy: Add coverage whitelisting 2019-03-01 10:30:31 +08:00
Binh Thai
658bf9d554 MDL-64291 GDPR export: Context paths can be very long, not unique 2019-01-28 19:49:09 +07:00
sam marshall
fc570e6699 MDL-64497 GDPR: moodle_content_writer can cause endless loop
Fixes a buggy function by replacing it with a call to file_get_contents,
and adds error detection on a couple of file accesses.
2019-01-03 16:54:38 +00:00
Adrian Greeve
34adbfe0b1 MDL-62061 core_privacy: Stop directories being created.
This stops directories being created in the root directory
while running unit tests.
2018-12-06 11:25:32 +01:00
Damyon Wiese
ff015b5f7a MDL-64220 privacy: Clean path params
We need to consistently clean the path params before we use them. This
shows a difference on windows where dir separators are different.
2018-11-27 15:01:41 +08:00
Jun Pataleta
60e265e76f Merge branch 'MDL-63921-master' of git://github.com/andrewnicols/moodle 2018-11-20 13:54:14 +08:00
Mark Johnson
80aff7db49 MDL-63660 privacy: Include CSS locally for data export 2018-11-14 14:53:27 +00:00
Andrew Nicols
9f12dd7a2f MDL-63921 privacy: Add unit test to prove userlist compliance 2018-11-13 11:41:02 +08:00
David Monllao
754ff36d1d Merge branch 'MDL-63925-master' of git://github.com/mickhawkins/moodle 2018-11-12 11:57:42 +01:00