14 Commits

Author SHA1 Message Date
Andrew Nicols
55126be4ad
MDL-81520 core: Fix test finality 2024-12-11 12:30:21 +08:00
Andrew Nicols
c6942c9bb7
MDL-81521 core: Update all possibly data providers to be static
Note: Some data providers could not be automatically be converted to
being static. These will be handled in a separate issue.
2024-11-18 10:24:55 +08:00
Andrew Nicols
564de9d4a7
MDL-81308 core: Use a helper for consecutive invocation counts 2024-10-23 14:17:37 +08:00
Andrew Nicols
da7c5d98ec
MDL-81308 core: Update tests to not use withConsecutive 2024-10-23 14:17:36 +08:00
Eloy Lafuente (stronk7)
091b458c52
MDL-81522 phpunit: Add missing void return type to all tests #2
This commit includes more changes, all them also adding the :void
return type to unit tests missing them.

The difference is that all these changes, while also detected
perfectly by the moodle.PHPUnit.TestReturnType sniff, were not
auto-fixed (like the previous commit ones), because all them
do include some "return" statement and, for safety, we don't
fix them.

All the cases have been visually inspected and confirmed that
the existing "return" statements always belong to anon
functions within the test body and not the test own return statement.
2024-06-11 12:18:05 +02:00
Eloy Lafuente (stronk7)
1093256560
MDL-81522 phpunit: Add missing void return type to all tests
While this change is not 100% required now, it's good habit
and we are checking for it since Moodle 4.4.

All the changes in this commit have been applied automatically
using the moodle.PHPUnit.TestReturnType sniff and are, exclusively
adding the ": void" return types when missing.
2024-06-11 12:18:04 +02: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)
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
Peter Dias
cf66500557 MDL-70271 repository_dropbox: Switch to core\oauth2 API
Dropbox is updating their OAuth2 authentication to issue short-term
tokens, which are already supported by core\oauth2\client.

This commit updates the dropbox repository to use the
core\oauth2 API, which has built-in support for tokens and
offline access.
2021-06-22 11:44:11 +08: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
Peter Dias
663c84ace6 MDL-70048 dropbox: Augmented unit tests to account for additional params 2021-01-28 07:31:07 +08:00
Mihail Geshoski
b4d5080892 MDL-57666 repositories: Error when copying file from Dropbox repository 2018-07-30 09:28:48 +08:00
Andrew Nicols
066963cd18 MDL-52051 repository_dropbox: Migrate to v2 API 2016-10-11 11:17:09 +08:00
Frederic Massart
9b5e61ac1e MDL-39477 repository: Introducing data generators for repositories 2013-05-28 10:44:43 +08:00