293 Commits

Author SHA1 Message Date
Huong Nguyen
f64fda43d5
MDL-4188 behat: Turn off course welcome message
Turn off the course welcome message,
so we can easily test other messages.
2024-04-04 20:13:47 +07: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
Huong Nguyen
a2866d6833
MDL-72359 core_analytics: Better handling of MAX_TIME
We are limited by both PHP's max int value and DB (cross-db) max int allowed.
We need to use the smallest one
2023-08-29 20:36:58 +07:00
Daniel Poggenpohl
079a5fa104
MDL-72359 core: Changed MAX_TIME from 9999999999 to PHP_INT_MAX
This prevents automatic casting from int to double on 32 bit systems
(which have a maximum for integers of 2147483647)

Whilst Moodle will not support 32-bit systems for much longer, this is
still worth doing to prevent future issues.
2023-08-23 14:34:32 +08:00
Paul Holden
a06b8d978b
MDL-78140 analytics: improve context restrictions manager test.
This test apparently fails sporadically on Oracle, without obvious
causes. The failure however was hard to interpret, and the test
itself made a lot of assumptions about the system re. naming of
categories/courses. This could be prone to errors, so improve that.
2023-05-11 09:39:39 +01:00
Meirza
a6894fc65e MDL-77337 analytics: Added class properties that are not declared.
In PHP 8.2 and later, setting a value to an undeclared class property is
deprecated and emits a deprecation notice.
So we need to add missing class properties that still need to be declared.
2023-03-16 09:46:07 +07:00
Sara Arjona
ae53d04144 Merge branch 'MDL-75337-master' of https://github.com/laurentdavid/moodle 2023-01-24 16:07:35 +01:00
Laurent David
fc72a1d7b1 MDL-75337 core: Single button - core changes
* Change all core calls toward single_button to use single_button::BUTTON_PRIMARY
    when needed
2023-01-24 06:01:35 +01:00
Marina Glancy
b0a83aa7bd 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:15:54 +08:00
Jun Pataleta
fad05d7929 Merge branch 'MDL-76583-master-withoutrename' of https://github.com/andrewnicols/moodle 2023-01-19 09:44:48 +08:00
Andrew Nicols
853f07d4c0 Merge branch 'MDL-69127' of https://github.com/paulholden/moodle 2023-01-19 09:01:39 +08:00
Andrew Nicols
a3cc26f8bb MDL-76583 core: Update uses of external_* classes 2023-01-19 07:34:09 +08:00
Marina Glancy
594a8c5ab7 MDL-76356 various: avoid implicit conversion to arrays
PHP before version 8.1 automatically converted stdClass or 'false' to arrays if
function parameter expects array (for example, "reset").
PHP 8.1 shows notices in these situations
2023-01-10 12:16:52 +01:00
Paul Holden
d843168c14 MDL-69127 analytics: final removal of renamed target class mapping. 2023-01-05 17:28:59 +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
Kevin Pham
1495c10c26 MDL-49795 analytics: Add missing metadata providers for analytics tables
Affected tables:
- analytics_models
- analytics_models_log
2022-08-03 15:17:05 +10:00
Sujith Haridasan
73d604369d MDL-71062 core: Step 1 deprecation of print_error function 2022-07-13 08:20:54 +05:30
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