274 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
4003e31983 MDL-73785 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:

- When belonging to other components and being valid api:
  - analytics related tests have been moved to tests/analytics subdir.
  - backup & restore related tests have been moved to tests/backup subdir.
  - events related tests have been moved to tests/event subdir.
  - privacy related tests have been moved to tests/privacy.
  - task related tests have been moved to tests/task subdir.
- Some simple renames, not including the component part anymore (not
  needed now that they are namespaced):
  - some xxxlib_test.php have been renamed lib_test.php
    (when they where testing the corresponding lib.php).
  - cache stores tests have been all renamed store_test, originally
    each one had its own name (file_test, apcu_test, redis_test...)
  - assign feedback tests have been all renamed feedback_test, originally
    each one had its own name (file_test, editpdf_test...)
2022-03-03 12:19:30 +01: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
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
Andrew Nicols
0888efd258 Merge branch 'mdl-68199-fix-master' of https://github.com/jaypha/moodle 2021-12-02 11:54:59 +08:00
Jason den Dulk
e7f51a3857 MDL-68199 setup: Fix invalid parameters to make_request_directory()
Added parameter type hint to make_request_directory()
Removed invalid parameters from calls to make_request_directory()

Removing these parameters should have no effect on behaviour.
2021-12-02 07:49:28 +11:00
Ferran Recio
26d0e51d91 MDL-72456 mod_assign: fix behats 2021-11-25 15:29:54 +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
Jun Pataleta
4e75e73cb5 Merge branch 'primary_secondary_nav' of https://github.com/Chocolate-lightning/moodle 2021-08-25 10:42:57 +08:00
Adrian Greeve
7d435fb5f2 MDL-70196 navigation: Update to feature files.
- Part of: MDL-69588
A lot of tests rely on the last element of the breadcrumb being
active. This updates feature files to not rely on this anymore.
2021-08-23 17:46:38 +08:00
Dan Marsden
34bdef0b62 MDL-70006 analytics: Don't send notifications to suspended enrolments. 2021-08-03 10:52:53 +12:00
Amaia Anabitarte
5af5368059 MDL-65553 core_analytics: Don't allow to flag predictions several times
Even if a prediction is hidden from the report once is flagged,
it can be flagged several times if the user visits detailed view via URL.
We remove the checkbox to select a prediction and flag it
once it has already been flagged.
2021-04-15 16:39:09 +02: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
Marina Glancy
0af0a96bb1 MDL-70898 various: private functions can not be declared final 2021-02-15 16:20:06 +01:00
Sara Arjona
8099deda48 Merge branch 'MDL-69107-master-2' of git://github.com/andrewnicols/moodle 2020-12-18 15:22:09 +01:00
Amaia Anabitarte
46927df906 MDL-65284 analytics: Final deprecation get_analysables() 2020-12-16 12:47:52 +01:00
Andrew Nicols
31402aa406 MDL-69107 user: Fix autocomplete usages 2020-12-16 07:50:56 +08:00
Ilya Tregubov
2cc84a792b MDL-65186 analytics: Deprecate add_builtin_models 2020-12-08 09:12:00 +02:00
Jake Dallimore
c196068cc4 Merge branch 'MDL-65086-master' of git://github.com/peterRd/moodle 2020-12-03 10:15:19 +08:00
Dan Marsden
9ae716734f MDL-68052 analytics: Clean up analytics_indicator_calc records. 2020-11-17 20:27:00 +13:00
Peter Dias
a726e52e80 MDL-65086 analytics: Deprecate get_enabled_time_splitting_methods 2020-11-17 13:55:26 +08:00
Eloy Lafuente (stronk7)
284d0ae8f8 Merge branch 'MDL-66392' of https://github.com/paulholden/moodle into master 2020-10-21 19:43:13 +02:00
Paul Holden
cecd90ffec MDL-66392 analytics: make model output directory default to empty.
Falling back to path within $CFG->dataroot/models.
2020-10-21 18:04:26 +01:00
Eloy Lafuente (stronk7)
40de097e65 MDL-67673 phpunit: Remove deprecated assertContains() uses on strings
Both assertContains() and assertNotContains() are deprecated in PHPUnit 8
for operations on strings. Also the optional case parameter is. All uses
must be changed to one of:

- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertStringNotContainsString()
- assertStringNotContainsStringIgnoringCase()

More info: https://github.com/sebastianbergmann/phpunit/issues/3422

Regexp to find all uses:

ag 'assert(Not)?Contains\('
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
d95c378771 MDL-67673 phpunit: Remove expectedException annotations
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

The annotations `@expectedException`, `@expectedExceptionCode`,
`@expectedExceptionMessage`, and `@expectedExceptionMessageRegExp`
are now deprecated.
Using these annotations will trigger a deprecation warning
in PHPUnit 8 and in PHPUnit 9 these annotations will be removed.

Also, all uses of expectExceptionMessageRegExp() has been moved
to expectExceptionMessageMatches(). See https://github.com/sebastianbergmann/phpunit/issues/3957

TODO: Various weirdness found while doing the changes with these tests:
- vendor/bin/phpunit lib/tests/exporter_test.php (created MDL-69700)
- vendor/bin/phpunit competency/tests/external_test.php (same issue than prev one)
- vendor/bin/phpunit question/engine/tests/questionengine_test.php (created MDL-69624)
- vendor/bin/phpunit lib/tests/event_test.php (created MDL-69688)
2020-10-21 12:46:00 +02: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)
74ee34fd87 MDL-69521 core: Move all comments in code from 4.1 to 3.11 2020-09-08 18:59:30 +02:00
Bas Brands
4394f9e358 MDL-67735 theme_boost: remove bs2 and bs4alpha compatibility css 2020-08-17 08:16:42 +00:00
Matt Clarkson
7f55289912 MDL-67440 analytics: optimse delete's in clean up task. 2020-07-08 11:16:36 +12:00
Andrew Nicols
a2bc97a386 MDL-68750 analytics: Correct behat test modal checks 2020-05-26 12:55:29 +08:00
Jun Pataleta
1eac44f128 Merge branch 'MDL-67217_master' of git://github.com/dmonllao/moodle 2019-11-25 16:13:01 +08:00
David Monllaó
e477e1350a MDL-67217 unittest: usleep and windows don't get along well 2019-11-22 07:41:07 +08:00
Jun Pataleta
fd8c021447 Merge branch 'MDL-67039_master' of git://github.com/dmonllao/moodle 2019-11-04 19:21:41 +08:00
David Monllaó
b92c764872 MDL-67039 analytics: Unit tests for unidimensional arrays 2019-11-04 09:33:50 +08:00
David Monllaó
47b506e2f7 MDL-67039 analytics: Unidimensional array if no predictions 2019-11-04 09:32:05 +08:00
Eloy Lafuente (stronk7)
6e4cee745b Merge branch 'MDL-66807_master' of git://github.com/dmonllao/moodle 2019-11-01 00:08:16 +01:00
David Monllaó
87e5342a5b MDL-66807 analytics: Fix templates for gmail 2019-10-31 11:41:53 +08:00
David Monllaó
ef05f29267 MDL-67038 analytics: Remove null strings from the DB 2019-10-30 12:40:32 +08:00
David Monllaó
06579b18cc MDL-64739 analytics: Contexts autocomplete with ajax 2019-10-21 15:33:29 +08:00
David Monllaó
76b5ee4545 MDL-64739 tool_analytics: Restrict models to specific contexts 2019-10-21 09:54:39 +08:00
David Monllaó
c22fb4bd4b MDL-64739 core_analytics: Contexts param for get_analysables_iterator 2019-10-21 09:54:34 +08:00
David Monllaó
bf25fb166c MDL-65585 analytics: Global on/off switch 2019-10-10 10:06:31 +08:00
David Monllaó
63c15f6c58 MDL-66004 mlbackend_python: Purge testing output dirs properly 2019-10-03 09:45:57 +08:00
Eloy Lafuente (stronk7)
20502fa30c Merge branch 'MDL-66004_master' of git://github.com/dmonllao/moodle 2019-10-02 20:53:24 +02:00
David Monllaó
463b63db2a MDL-66004 analytics: mlbackend_python tested just once
Either running locally from the web server or using a server if
TEST_MLBACKEND_* vars are set. The tests will still be skipped if
the python backend is not available in the web server.
2019-10-02 08:41:14 +08:00
David Monllaó
aa5b705607 MDL-66004 mlbackend_python: Package installed on a separate server 2019-10-02 08:41:14 +08:00
David Monllaó
386d109172 MDL-62191 analytics: Support for bulk actions 2019-09-27 14:13:52 +08:00
Eloy Lafuente (stronk7)
08a6375507 Merge branch 'MDL-65588_master' of git://github.com/dmonllao/moodle 2019-09-23 22:51:10 +02:00