- 12 Mar, 2021 13 commits
-
-
Eloy Lafuente authored
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
-
Eloy Lafuente authored
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
-
Eloy Lafuente authored
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).
-
Eloy Lafuente authored
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.
-
Eloy Lafuente authored
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.
-
Eloy Lafuente authored
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.
-
Eloy Lafuente authored
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)
-
Eloy Lafuente authored
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
-
Eloy Lafuente authored
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'
-
Eloy Lafuente authored
-
Eloy Lafuente authored
-
Sara Arjona authored
-
-
- 11 Mar, 2021 10 commits
-
-
git://github.com/sarjona/moodlejun authored
-
Sara Arjona authored
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).
-
-
-
-
-
-
-
-
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)
-
- 10 Mar, 2021 10 commits
-
-
-
sam marshall authored
-
sam marshall authored
-
sam marshall authored
-
sam marshall authored
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).
-
git://github.com/sarjona/moodlejun authored
-
Sara Arjona authored
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).
-
Sara Arjona authored
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.
-
AMOS Bot authored
-
-
- 09 Mar, 2021 7 commits
-
-
-
-
-
jun authored
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.
-
jun authored
-
jun authored
-
jun authored
* 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.
-