Commit graph

100821 commits

Author SHA1 Message Date
Sara Arjona
3329494332 Merge branch 'MDL-44613-311-1' of git://github.com/mihailges/moodle into MOODLE_311_STABLE 2021-03-15 15:53:44 +01:00
Paul Holden
5543e99d6d MDL-70977 mod_forum: fix empty equality check updating post content.
Using the external method for updating posts, the check for empty
subject/message content wasn't correct (disallowed the string '0'),
in addition to being impossible to set a posts message format
property to FORMAT_MOODLE (integer 0).
2021-03-15 12:48:59 +00:00
Paul Holden
e2e4b15285 MDL-70924 course: ensure required fields present when getting courses. 2021-03-15 12:46:41 +00:00
Jun Pataleta
38607b4b93 Merge branch 'MDL-66667-cache-course-image-MOODLE_311_STABLE' of https://github.com/dmitriim/moodle into MOODLE_311_STABLE 2021-03-15 17:18:59 +08:00
Adrian Greeve
8dad051443 Merge branch 'MDL-70306-311' of git://github.com/peterRd/moodle into MOODLE_311_STABLE 2021-03-15 11:16:01 +08:00
Peter Dias
17779918f9 MDL-70306 auth: Update the thirdpartylib.xml 2021-03-15 11:10:12 +08:00
Peter Dias
e72dbd0752 MDL-70313 core: Update the thirdpartylib.xml 2021-03-15 10:28:03 +08:00
Peter Dias
c4b0667582 MDL-70313 core: Rebuilt module files 2021-03-15 10:28:03 +08:00
Peter Dias
63b9f338ed MDL-70313 core: Update codemirror to 5.59.4 2021-03-15 10:28:03 +08:00
Dmitrii Metelkin
88a150467f MDL-66667 course: add course image cache 2021-03-15 12:53:40 +11:00
Mihail Geshoski
978348d189 MDL-44613 mod_assign: Automate testing of the assignment availability 2021-03-15 08:26:17 +08:00
Mihail Geshoski
8a7fadc4ee MDL-44613 tool_behat: Update datetime format usages to strftime
Updates all existing datetime format usages to strftime in the
'time to timestamp' transformation in tool_behat behat tests.
2021-03-15 08:26:17 +08:00
Mihail Geshoski
70ae4664e6 MDL-44613 core_message: Update datetime format usages to strftime
Updates all existing datetime format usages to strftime in the
'time to timestamp' transformation in core_message behat tests.
2021-03-15 08:26:17 +08:00
Mihail Geshoski
3bc58c98d0 MDL-44613 behat: strftime format in time to timestamp transformation
Modifies the 'string time to timestamp' behat trasformation to use
userdate() instead of date(). The userdate() method is generally used
throught Moodle for constructing formatted date strings and this change
will provide more consistency and prevent any potential behat failures.
Therefore, if the date format is defined in the given trasformation, it
has to be strftime compatible. Example:
'I should see "##tomorrow noon##%A, %d %B %Y, %I:%M %p##"'
2021-03-15 08:26:17 +08:00
AMOS bot
c8a829ea3c Automatically generated installer lang files 2021-03-13 00:07:30 +00:00
Amaia Anabitarte
c2c3148664 MDL-70978 core_contentbank: Increasing contrast for unlisted content 2021-03-12 12:49:20 +01:00
Sara Arjona
c9110ffdce MDL-70689 oauth2: unit tests for new IMS OBv2.1
Apart from adding new unit tests for covering new IMS OBv2.1 issuer,
some extra tests have been added to test existing issuers and confirm
they are still working as expected after the changes.
2021-03-12 12:33:54 +01:00
Sara Arjona
a7229e4ad9 MDL-70689 oauth2: deprecate unused strings 2021-03-12 12:33:54 +01:00
Sara Arjona
9941e04857 MDL-70689 oauth2: self-register IMS OBv2.1 services
IMS OBv2.1 services have a registration endpoint to get client id
and secret.
This patch adds and implements the "register" method for the IMS
Open Badges Connect discovery system, to get the proper client id
and secret values.
2021-03-12 12:33:54 +01:00
Sara Arjona
84e51fb0fd MDL-70689 oauth2: add support to IMS OBv2.1 service
In order to make easier to create and maintain new OAuth2 services,
a couple of classes have been added:

- discovery\* contains methods related to the discovery system. Until
now, only OpenID Connect was supported by Moodle so all the code was
centralised in api.php.
With this patch, as IMS OBv2.1 has a different discovery system, a new
abstract class (base_definition) has been added to be called and let
every discovery system (OpenID Connect, IMS Badge Connect...)
implement their own methods.

- service\* . Instead of keep adding methods to the api, the service
namespace has been created to store all the standard issuer services.
An interface (issuer_interface) has been created and all the services
should implement it.
This patch creates the "IMS OBv2.1" and "Custom" services and moves
the methods for "Google" service because it uses the OpenID connect
discovery system.
2021-03-12 12:33:53 +01:00
Paul Holden
dbc7d37685 MDL-70565 user: filter course participants by country. 2021-03-12 09:50:02 +00:00
Eloy Lafuente (stronk7)
0357efb1fc MDL-71036 phpunit: Coding style changes, 99% whitespace only
I've gone over a few of the mofified files (those
which were showing warnings and errors to CiBoT. Some of them
have been fixed completely, while others only have fixed
for the lines belonging to this issue (lib/tests/moodlelib_test.php)
for example.
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
e2e333c9cd MDL-71036 phpunit: Add all the noticeable changes to upgrade notes 2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
790237a77f 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:07:31 +01:00
Eloy Lafuente (stronk7)
a9c0c3d5a9 MDL-71036 phpunit: xml config - deprecate whitelist from coverage
Following the changes in the schema, from "whitelists" to "includes",
we are deprecating these two properties from phpunit_coverage_info:

- whitelistfolders => includelistfolders
- whitelistfiles   => includelistfiles

They will continue working over the deprecation period but the init/util
scripts will throw some warnings about them being deprecated for 3.11 and
the way to replace them.

Standard 2y deprecation applies with final removed to happen @ MDL-71067
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
d786046e52 MDL-71036 phpunit: xml config - change dist file to spread them to final
Basically switch to 2-space indenting and small tweaks to comments,
so both the main phpunit.xml file and also the individual components
ones, all them based in the dist one will be consistent.
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
50e3bb8546 MDL-71036 phpunit: xml config - change generation code to follow xsd
This performs all the changes needed in the util generator to
produce XML files compliant with the new schema (see previous
commit for description of changes).

- All the occurrences in code of filter => coverage.
- All the occurrences in code of whitelist => include.
- Apply all the changes to comply with the new schema.

- Remove processUncoveredFilesFromWhitelist attribute, useless (false
    is its default value, and now have another name).
- Move from 4-spaces indented XML to 2-spaces indented.
- Small linefeed tweaks to generate better-looking XML.
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
cf38a34904 MDL-71036 phpunit: xml config - add new (9.5) validation xsd
PHPUnit 9 comes with various changes in the XML
configuration file, namely:

  - the old "filter" section has been renamed to "coverage".
  - "whitelist" has been renamed to "include"
  - "exclude" is not a child of "include" anymore, but of "coverage".
  - "include" cannot have configuration attributes anymore, only
    "coverage" can"

Visually it means that the old section (invented example):
```
<filter>
  <whitelist attributes_may_go_here="xx">
    <directory suffix=".php">classes</directory>
    <directory suffix=".php">externallib.php</directory>
    <exclude>
      <directory suffix="_test.php">.</directory>
    </exclude>
  </whitelist>
</filter>
```
Now looks like:
```
<coverage attributes_may_go_here="xx">
  <include>
    <directory suffix=".php">classes</directory>
    <directory suffix=".php">externallib.php</directory>
  </include>
  <exclude>
    <directory suffix="_test.php">.</directory>
  </exclude>
</filter>
```

So, switching to the new xsd so we can validate the remaining changes.
2021-03-11 23:07:31 +01:00
Eloy Lafuente (stronk7)
2d693cda7a 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:07:31 +01:00
Eloy Lafuente (stronk7)
3dd26fe334 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:07:31 +01:00
Eloy Lafuente (stronk7)
8940f67486 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:07:30 +01:00
Eloy Lafuente (stronk7)
ad249ced07 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 23:07:30 +01:00
Eloy Lafuente (stronk7)
6d5eb09218 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 23:07:30 +01:00
Eloy Lafuente (stronk7)
23f09c8c1a 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 23:07:30 +01:00
Eloy Lafuente (stronk7)
3b37f318d4 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 23:07:30 +01:00
Eloy Lafuente (stronk7)
c989d6ec61 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 23:07:30 +01:00
Eloy Lafuente (stronk7)
cbf01aa79a 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 23:07:30 +01:00
Eloy Lafuente (stronk7)
87680e8b2b MDL-71036 phpunit: Stricter signature matching 2021-03-11 23:07:30 +01:00
Eloy Lafuente (stronk7)
77f09eccfe MDL-71036 phpunit: Bump to phpunit 9.5.x 2021-03-11 19:34:28 +01:00
Sara Arjona
295901e6a1 weekly release 3.11dev 2021-03-11 17:18:44 +01:00
Sara Arjona
4d1323a8a8 Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2021-03-11 17:18:42 +01:00
hiendinh
c06b63113a MDL-69474 Accessibility: Profile image changes 2021-03-11 16:42:05 +07:00
Jun Pataleta
9fe5ab67f1 Merge branch 'MDL-70911-311' of git://github.com/sarjona/moodle into MOODLE_311_STABLE 2021-03-11 17:41:25 +08:00
Sara Arjona
9b74408a33 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:02:23 +01:00
Adrian Greeve
fefc5d6421 Merge branch 'MDL-66025-311' of git://github.com/paulholden/moodle into MOODLE_311_STABLE 2021-03-11 11:43:26 +08:00
Adrian Greeve
24ee5bc2c3 Merge branch 'MDL-71026-311' of git://github.com/ilyatregubov/moodle into MOODLE_311_STABLE 2021-03-11 11:03:28 +08:00
Eloy Lafuente (stronk7)
bb4d5dbc25 Merge branch 'MDL-70726-3.11' of https://github.com/NashTechOpenUniversity/moodle into MOODLE_311_STABLE 2021-03-11 00:11:44 +01:00
Eloy Lafuente (stronk7)
ca6b26fae7 Merge branch 'MDL-70789-311' of git://github.com/paulholden/moodle into MOODLE_311_STABLE 2021-03-10 23:52:46 +01:00
Eloy Lafuente (stronk7)
3841ce68cf Merge branch 'MDL-70891-311' of git://github.com/marinaglancy/moodle into MOODLE_311_STABLE 2021-03-10 23:40:07 +01:00
Eloy Lafuente (stronk7)
58afea8c59 Merge branch 'MDL-70967-311' of git://github.com/marinaglancy/moodle into MOODLE_311_STABLE 2021-03-10 23:39:15 +01:00