100278 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
4a1df0219e MDL-71036 phpunit: ->at() matcher is deprecated
Mocke at() matcher is being deprecated with phpunit9 and
will be removed with phpunit10.

Source: https://github.com/sebastianbergmann/phpunit/issues/4297

Luckily we are using those deprecated matchers only in completionlib
tests, so there aren't many cases to modify. Now, we are using
supported matchers (once, exactly, never...) and the tests have
been reorganised to better represent the expected behavior (how
many times stuff is called, with which params and return values).
2021-03-11 23:04:19 +01:00
Eloy Lafuente (stronk7)
be30af0e23 MDL-71036 phpunit: Remove custom autoloader
Custom autoloaders are deprecated with PHPUnit 9 and will be removed
with PHPUnit 10.

Since PHPUnit 8.5 custom autoloaders don't do much because that
version removed the ability to launch unit tests by class name
and that's exactly the reason we had a custom autoloader (to map
class names to files within our tests). See MDL-67673 about
when direct use of classes was deprecated (8.5), now removed (9.5).

So, as far as it's unused, removing it now, test still can be
selectively using any of:

- a relative path to file (although there are some restrictions comming
  with PHPUnit 9, see https://github.com/sebastianbergmann/phpunit/issues/4105
- using --filter, to point to any classname[::method]
- using --testsuite to run a complete suite
- using --config to point to custom components.

Also, commented out the lib/ajax/tests directory because it doesn't
exist / is empty and PHPUnit 9 emits error when a configured test
directory does not exist. See
https://github.com/sebastianbergmann/phpunit/issues/4493.

Alternative was to completely remove the configuration line, but
decided to keep it around in case some day we want to add some
test there.
2021-03-11 19:22:24 +01:00
Eloy Lafuente (stronk7)
8a3663b175 MDL-71036 phpunit: XML load() method has been moved to new loader class
Used by our custom assertTag() and assertNotTag() assertions, that some
day we should deprecate... the loading of XML content for further
processing has been moved to new classes within the PHPUnit utils. We
are just following the move here.
2021-03-11 19:22:24 +01:00
Eloy Lafuente (stronk7)
857f6385a4 MDL-71036 phpunit: Fix param check, must be array
With stricter typed param checks in php73, the 7th param of the
getMockForAbstractClass() must be array, so previous code defaulting
to null now throws a TypeError.
2021-03-11 19:22:24 +01:00
Eloy Lafuente (stronk7)
5f755ac26e MDL-71036 phpunit: Deprecated expectException for notice/warning/error
In PHP 9.1, the use of expectException(PHPUnit\Framework\Error\*) has
been deprecated, that is, when a Notice/Warning/Error/Deprecated
problem is reported. Instead, these new assertions must be used:

- expectDeprecation() for E_DEPRECATED and E_USER_DEPRECATED
- expectNotice() for E_NOTICE, E_USER_NOTICE, and E_STRICT
- expectWarning() for E_WARNING and E_USER_WARNING
- expectError() for everything else

More info:

https://github.com/sebastianbergmann/phpunit/blob/9.0.0/ChangeLog-9.0.md
https://github.com/sebastianbergmann/phpunit/issues/3775

Regexp to find all them:

ag 'expectException.*(Notice|Warning|Error|Deprecated)
2021-03-11 19:22:24 +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
Eloy Lafuente (stronk7)
309a65a6f7 MDL-71036 phpunit: Renamed various file-related assertions
In PHPUnit 9.1, the following file-related assertions
have been deprecated and there are new alternatives for
all them:
- assertNotIsReadable()         -> assertIsNotReadable()
- assertNotIsWritable()         -> assertIsNotWritable()
- assertDirectoryNotExists()    -> assertDirectoryDoesNotExist()
- assertDirectoryNotIsReadable()-> assertDirectoryIsNotReadable()
- assertDirectoryNotIsWritable()-> assertDirectoryIsNotWritable()
- assertFileNotExists()         -> assertFileDoesNotExist()
- assertFileNotIsReadable()     -> assertFileIsNotReadable()
- assertFileNotIsWritable()     -> assertFileIsNotWritable()

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 'assertNotIsReadable|assertNotIsWritable|assertDirectoryNotExists|\
assertDirectoryNotIsReadable|assertDirectoryNotIsWritable|\
assertFileNotExists|assertFileNotIsReadable|assertFileNotIsWritable'
2021-03-11 19:22:23 +01:00
Eloy Lafuente (stronk7)
5fcd5e1cf7 MDL-71036 phpunit: Stricter signature matching 2021-03-11 19:22:23 +01:00
Eloy Lafuente (stronk7)
10c2aa7122 MDL-71036 phpunit: Bump to phpunit 9.5.x 2021-03-11 19:22:23 +01:00
Sara Arjona
fc335f5ea0 weekly release 4.0dev 2021-03-11 17:18:40 +01:00
Sara Arjona
c51a5056b3 Merge branch 'install_master' of https://git.in.moodle.com/amosbot/moodle-install 2021-03-11 17:18:36 +01:00
Jun Pataleta
8eab098f26 Merge branch 'MDL-70911-master' of git://github.com/sarjona/moodle 2021-03-11 17:41:46 +08:00
Sara Arjona
0a0729f48e MDL-70911 core_badges: Add navigation menu in classic
Manage backpacks page wasn't displaying the navigation and administration
menus when using classic theme (it's unrelated to changes done here).
This patch fixes this unexpected behaviour (raised thanks to behat tests).
2021-03-11 09:00:35 +01:00
Adrian Greeve
baa906485c Merge branch 'MDL-66025' of git://github.com/paulholden/moodle 2021-03-11 11:46:34 +08:00
Adrian Greeve
98fa5b64bd Merge branch 'MDL-71026-master' of git://github.com/ilyatregubov/moodle 2021-03-11 11:04:23 +08:00
Eloy Lafuente (stronk7)
90db228323 Merge branch 'MDL-70726-master' of https://github.com/NashTechOpenUniversity/moodle 2021-03-11 00:11:15 +01:00
Eloy Lafuente (stronk7)
82b2488305 Merge branch 'MDL-70789' of git://github.com/paulholden/moodle 2021-03-10 23:52:16 +01:00
Eloy Lafuente (stronk7)
9c07520969 Merge branch 'MDL-70891-master' of git://github.com/marinaglancy/moodle 2021-03-10 23:39:44 +01:00
Eloy Lafuente (stronk7)
4f0b58714c Merge branch 'MDL-70967-master' of git://github.com/marinaglancy/moodle 2021-03-10 23:39:25 +01:00
Sara Arjona
2c0038f7f9 Merge branch 'MDL-70287-master-3' of git://github.com/rezaies/moodle 2021-03-10 20:48:44 +01:00
Jun Pataleta
fc238f329d MDL-70815 completion: Cast custom data to array
Since cm_info::customdata can be of any type, we need to cast it to an
array first before checking for custom completion rules. Otherwise,
an exception can be thrown (e.g. customdata has been set as an stdClass)
2021-03-10 19:22:15 +01:00
Jun Pataleta
5a7c629f7c Merge branch 'MDL-45242-master' of https://github.com/sammarshallou/moodle 2021-03-10 23:39:30 +08:00
sam marshall
987e55452f MDL-45242 Course: Enrol feature supports custom profile fields 2021-03-10 10:57:11 +00:00
sam marshall
e86ead1d91 MDL-45242 Course: Participants list supports custom profile fields 2021-03-10 10:57:11 +00:00
sam marshall
dbc09f74e9 MDL-45242 Admin: User list supports custom profile fields 2021-03-10 10:57:11 +00:00
sam marshall
558cc1b85e MDL-45242 Lib: Replace calls to deprecated functions
In all cases changes have been kept to a minimum while not making
the code completely horrible. For example, there are many instances
where it would probably be better to rewrite a query entirely, but
I have not done that (in order to reduce the risk of changes).
2021-03-10 10:57:10 +00:00
Jun Pataleta
644f32784d Merge branch 'MDL-70911-master' of git://github.com/sarjona/moodle 2021-03-10 16:15:43 +08:00
Sara Arjona
49c1d41a60 MDL-70911 core_badges: Remove $CFG->badges_site_backpack
The $CFG->badges_site_backpack setting has been completely removed
because it's not required anymore. From now, the primary site
backpack will be the first one in the "Manage backpacks" list (so,
the one with lower sortorder value).
2021-03-10 09:09:05 +01:00
Sara Arjona
066e998400 MDL-70911 core_badges: Add support to backpacks sortorder
Before removing $CFG->badges_site_backpack setting, admins should be
able to re-order the existing site-backpacks (because then, the first
one will be treated as the default one).
This patch adds the sort order feature to the backpack list.
2021-03-10 08:29:47 +01:00
AMOS bot
11826cc831 Automatically generated installer lang files 2021-03-10 00:07:42 +00:00
Eloy Lafuente (stronk7)
9e1da41763 Merge branch 'MDL-63961-master' of git://github.com/sarjona/moodle 2021-03-10 00:19:31 +01:00
Sara Arjona
1fa9fe25dc Merge branch 'MDL-70608-master-langimportasync' of git://github.com/mudrd8mz/moodle 2021-03-09 16:42:52 +01:00
Sara Arjona
489318e327 Merge branch 'MDL-70815-master-6' of git://github.com/junpataleta/moodle 2021-03-09 15:18:28 +01:00
Sara Arjona
471819e5cd Merge branch 'MDL-70855-master' of https://github.com/dmitriim/moodle 2021-03-09 14:56:57 +01:00
Jun Pataleta
8d29653fbc MDL-70815 completion: Test internal_get_state() with custom completion
Use the custom completion implementation for mod_choice to test
completion_info::get_state() to cover the case where the completion
state is being determined from the custom completion condition.
2021-03-09 20:15:28 +08:00
Jun Pataleta
2f0914e55f MDL-70815 mod_choice: Unit tests for the custom completion class 2021-03-09 20:15:28 +08:00
Jun Pataleta
4b2d9ef76d MDL-70815 mod_choice: Custom completion implementation 2021-03-09 20:15:28 +08:00
Jun Pataleta
32721b3511 MDL-70815 core_completion: Update completion_info
* Update completion_info::get_data() to add other completion
information from a new method called get_other_cm_completion_data().
This allows the storage of the completion statuses of the following
completion rules to completion_info objects:
  - 'Students must receive a grade' completion rule.
  - Any custom completion rule defined by an activity.
This allows detailed completion information to be fetched for course
modules.
It also allows custom completion statuses to be cached which will help
reduce DB queries when fetching completion statuses.
* Update update_state() to fetch overall completion state from the
module's activity_custom_completion implementation. Falls back to the
*_get_completion_state() callback function.
* Update internal_set_data() to include the other cm completion data
in the updated cache data for the module instance.
2021-03-09 20:15:28 +08:00
Jun Pataleta
18ef213da5 MDL-70815 core_completion: completion_info::get_grade_completion()
Move the current logic for determining the completion status for the
"Student must receive grade" completion rule to a function so it cann
be reused.
Unit test included.
2021-03-09 20:15:28 +08:00
Jun Pataleta
236033151d MDL-70815 core_completion: Fix unit tests
* Unit tests for completion_info::get_data() and
completion_info::internal_get_state are mocked which causes failures
with the new implementation. It's more straightforward and realistic
to generate real course and modules to test these methods.
2021-03-09 20:15:24 +08:00
Jun Pataleta
14234bf240 MDL-70815 core_completion: Unit tests for activity_custom_completion
Tests cover
 - get_overall_completion_state()
 - is_available()
 - validate_rule()
Tests don't cover
 - methods that rely on static methods such as:
   - is_defined()
 - static methods in the class because they can't be mocked
 - abstract methods that can be tested better by the plugins
   that extend activity_custom_completion such as:
   - get_state()
   - get_defined_custom_rules()
   - get_custom_rule_descriptions()
2021-03-09 19:27:46 +08:00
Jun Pataleta
beb0dd74f2 MDL-70815 core_completion: Activity custom completion details base class
* Base class for defining an activity module's custom completion details
2021-03-09 19:27:41 +08:00
Sara Arjona
323b3ca3a4 Merge branch 'MDL-70766-auth-config-log' of https://github.com/brendanheywood/moodle 2021-03-08 11:39:13 +01:00
sam marshall
3f003455f3 MDL-45242 Lib: Replace direct references to ->showuseridentity 2021-03-08 09:20:18 +00:00
sam marshall
60a1b159aa MDL-45242 Lib: Deprecate field-related library functions 2021-03-08 09:20:18 +00:00
sam marshall
677e1c6248 MDL-45242 Lib: Allow custom profile fields in showuseridentity 2021-03-08 09:20:18 +00:00
sam marshall
9ddb51b07e MDL-45242 Testing: Generators for user profile fields 2021-03-08 09:20:17 +00:00
sam marshall
e18b37c61d MDL-45242 Admin: Added lazy-loading callback to multicheckbox
Currently admin_setting_configselect has lazy-loading support via a
callback function (so you don't have to make pointless single-use
classes for each unusual setting), but this is not present in other
similar types.

This commit adds identical support to
admin_setting_configmulticheckbox.
2021-03-08 09:20:17 +00:00
Sara Arjona
a306fd7a18 MDL-70911 core_badges: Move "External backpack" to badges settings
Setting "External backpack connection" has been moved from "Backpack
settings" to "Badges settings" in order to make easier to find and
configure it.
Some extra tests have been added to cover existing behaviour and
confirm is still working as expected.
2021-03-08 09:24:53 +01:00
AMOS bot
a654567b9c Automatically generated installer lang files 2021-03-07 00:07:46 +00:00