3331 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
870a8de3fb MDL-37655 phpunit: Avoid having multiple testcase classes in 1 file
Note that there wasn't any case of multiple testcase classes in
1 file. All the cases reported in the issue were false positives
caused but other "mock/fixture" files being named _test.

So all this issue does is:

1) rename any _test suffixed class in test files, because we are
   going to start renaming a lot of test classes to _test.

2) ensure that the 2 test case classes modified in this issue,
   are already observing the filename = classname rule that will
   be implemented soon (and verigy it works).
2021-03-30 19:17:54 +02:00
sam marshall
5e72715e4f MDL-71099 Lib: Move new user_fields class from core to core_user
This class would belong more appropriately within the 'user' API
(core_user) instead of within the 'core' API, since it is
directly related to user data.

Since the class has only just been added to Moodle, now is a good
time to move it.
2021-03-25 13:47:23 +00:00
Eloy Lafuente (stronk7)
3edac87e20 Merge branch 'MDL-70689-master' of git://github.com/sarjona/moodle 2021-03-17 23:20:37 +01:00
Jun Pataleta
ebf078458d Merge branch 'MDL-71036' of https://github.com/stronk7/moodle 2021-03-17 20:05:25 +08:00
Mihail Geshoski
c14242c807 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:22:12 +08:00
Sara Arjona
4211787141 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:31:24 +01:00
Sara Arjona
57d9354505 MDL-70689 oauth2: deprecate unused strings 2021-03-12 12:31:24 +01:00
Sara Arjona
0f59f19d3b 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:31:24 +01:00
Sara Arjona
5066c60206 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:31:22 +01:00
Eloy Lafuente (stronk7)
713722c3fb 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:04:32 +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
Eloy Lafuente (stronk7)
90db228323 Merge branch 'MDL-70726-master' of https://github.com/NashTechOpenUniversity/moodle 2021-03-11 00:11: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
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
Sara Arjona
1fa9fe25dc Merge branch 'MDL-70608-master-langimportasync' of git://github.com/mudrd8mz/moodle 2021-03-09 16:42:52 +01:00
sam marshall
3f003455f3 MDL-45242 Lib: Replace direct references to ->showuseridentity 2021-03-08 09:20:18 +00:00
Amaia Anabitarte
d0bea8aa5e MDL-70726 behat: Fixing existing fail tests
Some of the current behat tests were wrong but not failing because of the bug in 'should not exist' step.
Once the bug is fixed, we must fix also wrong behats.
2021-03-05 14:19:55 +07:00
Ilya Tregubov
eaf40e050e MDL-69680 lib: Replace deprecated jQuery functions 2021-03-04 12:48:26 +08:00
Eloy Lafuente (stronk7)
8cf7878e18 Merge branch 'MDL-70424-auth-avoid-changes' of https://github.com/brendanheywood/moodle 2021-03-04 00:27:53 +01:00
Marina Glancy
9cfacff738 MDL-65552 user: escape idnumber and email in table_sql 2021-03-03 23:15:07 +08:00
Paul Holden
a7e0ba1e71 MDL-65552 user: escape idnumber field on output.
This commit also corrects parameter definition of the field to
match core_user.
2021-03-03 23:15:07 +08:00
Sara Arjona
5db1ed89b9 Merge branch 'MDL-67515-master' of git://github.com/vmdef/moodle 2021-03-02 11:21:17 +01:00
Víctor Déniz
bb4da690cf MDL-67515 tool_customlang: Ignore invalid component strings
After uninstalling a plugin, the translated strings remain in
tool_customlang table, throwing an exception when trying to localise
any strings. Currently there is no mechanism to
clean up customlang tables and files during the uninstall process,
so with this patch the invalid components will be ignored.
2021-03-02 09:07:38 +00:00
Eloy Lafuente (stronk7)
b7d3e56d7e Merge branch 'MDL-70931-master-xmldbeol' of git://github.com/mudrd8mz/moodle 2021-03-01 10:00:27 +01:00
Eloy Lafuente (stronk7)
ac9b920981 Merge branch 'MDL-70964-master-enfix' of git://github.com/mudrd8mz/moodle 2021-03-01 09:33:49 +01:00
David Mudrák
0c9eaeff59 MDL-70964 lang: Use the fixed strings in tests 2021-02-25 16:20:58 +01:00
Jun Pataleta
e85b1f9c0f Merge branch 'MDL-70768-langpack-admin' of https://github.com/brendanheywood/moodle 2021-02-25 11:32:36 +08:00
Brendan Heywood
300213ee2e MDL-70424 auth: Avoid random changes to $CFG->auth 2021-02-23 11:40:57 +11:00
David Mudrák
af9ad8b2b6 MDL-70608 lang: Recommend running the scheduled task to update packs 2021-02-19 16:02:02 +01:00
David Mudrák
c85215e955 MDL-70608 lang: Install langpacks asynchronously via ad hoc task
When multiple language packs are selected for installation, perform the
installation asynchronously in the background via ad hoc task.
2021-02-19 16:02:02 +01:00
David Mudrák
70b0df5891 MDL-70931 xmldb: Generate install.xml files with EOL and EOF
As discussed in MDLSITE-6397, all Moodle code files should end with
single Unix-style end of line character. Files created and edited
through the XMLDB editor should follow this rule, too.
2021-02-17 20:59:19 +01:00
Mihail Geshoski
76fe097b55 MDL-47410 tool_licensemanager: Update tool_licensemanager behat tests
Updates the tool_licensemanager behat tests to utilize the ability to
conviniently populate the date selector fields.
2021-02-11 12:01:09 +08:00
Brendan Heywood
17e465ca85 MDL-70768 tool_langimport: Make installed admin UI more consistent 2021-02-11 10:43:19 +11:00
Andrew Nicols
84872802ce Merge branch 'MDL-70632' of git://github.com/paulholden/moodle 2021-02-04 09:25:25 +08:00
Eloy Lafuente (stronk7)
b74beab57c MDL-70741 capability overview: missing whitespace after placeholder 2021-02-04 00:01:31 +01:00
Sara Arjona
655a682794 Merge branch 'MDL-70741' of https://github.com/timhunt/moodle 2021-02-03 14:49:36 +01:00
Paul Holden
3f36a7da98 MDL-70632 tool_langimport: search for available language packs. 2021-02-03 10:03:37 +00:00
Jun Pataleta
793aa03598 MDL-70288 mod_lti: Remove unnecessary empty label string
* When a label is passed to an (advanced) checkbox and no text
  was provided, the label will be displayed on the right of the the
  checkbox element. So there's no point in passing an empty string for
  the label just to render the text to the right of the checkbox.
2021-02-02 13:53:05 +08:00
Tim Hunt
3da5a51df7 MDL-70741 capability overview: avoid errors from orphan contexts 2021-01-29 20:48:14 +00:00
Jake Dallimore
9a4cfdeabb Merge branch 'MDL-66979-master-7' of git://github.com/andrewnicols/moodle 2021-01-29 15:41:03 +08:00
Andrew Nicols
b658d18b51 MDL-66979 behat: Mark some tests as being slow
Uses of the httpsreplace and customlang tools are known to be extremely
slow.

In our CI infrastructure on slwoer DBs, the customlang tool can take
over 90 seconds to load the page, whilst the httpsreplace tool can take
up to about 60 seconds.

These changes set appropriate timeout factors to increase the timeout
accordingly.
2021-01-29 14:15:26 +08:00
Víctor Déniz
34dec1d26e Merge branch 'MDL-69816' of git://github.com/paulholden/moodle 2021-01-27 23:00:53 +00:00
Andrew Nicols
05fca85d8e MDL-66979 behat: Warn about old behat.yml file location 2021-01-23 20:43:20 +08:00
Andrew Nicols
0c2403f9b3 MDL-66979 behat: Uncomment step disabled for old firefox 2021-01-22 14:52:12 +08:00
Andrew Nicols
653fb1842f MDL-66979 behat: Remove unnecessary steps which fail
These steps were completely pointless and were failing with the W3C
Webdriver becuase focus was never on the Update Profile button in the
first place.

At a minimum we should remove the Focus change step as it not valid, but
the following step is also pointless.
2021-01-22 14:52:10 +08:00
Eloy Lafuente (stronk7)
333472ce2a Merge branch 'MDL-70159' of git://github.com/paulholden/moodle 2021-01-19 23:43:55 +01:00
Sara Arjona
7d24686e59 Merge branch 'MDL-69308' of https://github.com/stronk7/moodle 2021-01-14 12:03:30 +01:00