32 Commits

Author SHA1 Message Date
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)
3a5641cb74 MDL-67673 phpunit: Remove deprecated assertEquals() params
The optional parameters of assertEquals() and assertNotEquals()
are deprecated in PHPUnit 8 (to be removed in PHPUnit 9):

- delta => use assertEqualsWithDelta()
- canonicalize => use assertEqualsCanonicalizing()
- ignoreCase => use assertEqualsIgnoringCase
- maxDepth => removed without replacement.

More info @ https://github.com/sebastianbergmann/phpunit/issues/3341

Initial search done with:

ag 'assert(Not)?Equals\(.*,.*,' --php

Then, running tests and fixing remaining cases.
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
40de097e65 MDL-67673 phpunit: Remove deprecated assertContains() uses on strings
Both assertContains() and assertNotContains() are deprecated in PHPUnit 8
for operations on strings. Also the optional case parameter is. All uses
must be changed to one of:

- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertStringNotContainsString()
- assertStringNotContainsStringIgnoringCase()

More info: https://github.com/sebastianbergmann/phpunit/issues/3422

Regexp to find all uses:

ag 'assert(Not)?Contains\('
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
f6711bb394 MDL-67673 phpunit: Fix the return type of template methods
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.

At the same time, fix a few wrong function names,
provider data and param types, return statements...
2020-10-21 12:45:59 +02:00
Eloy Lafuente (stronk7)
6625cff604 Merge branch 'MDL-63136-master' of git://github.com/rezaies/moodle 2018-09-11 23:52:02 +02:00
Shamim Rezaie
eb4c801cef MDL-63136 mod_data: Check if the module is visible to the user 2018-09-07 17:40:29 +10:00
Shamim Rezaie
362f9e7c61 MDL-63136 mod_data: Add userid param to mod_data calendar callbacks 2018-09-07 17:40:16 +10:00
Neill Magill
196aa50489 MDL-62944 activities: Test adding activities with no calendar capability 2018-08-31 10:15:36 +01:00
Simey Lameze
61ac58a887 MDL-60060 mod_data: add unit tests for callbacks 2017-12-11 14:05:00 +08:00
Andrew Hancox
ee9a2706b3 MDL-57455 mod_data: Added PHPUnit tests 2017-10-12 16:59:15 +08:00
Marina Glancy
e1577187ed MDL-58665 mod_data: cache times in modinfo for performance 2017-05-01 12:57:22 +08:00
Jake Dallimore
d233adbb77 MDL-58460 completion: add callbacks to mod_data for bulk completion
Part of MDL-58138 epic
2017-04-19 08:56:11 +08:00
Dan Poltawski
1e4e5c52d7 Merge branch 'MDL-55611-master' of git://github.com/danpoltawski/moodle 2017-04-04 17:07:41 +01:00
Mark Nelson
e1cd93ce20 MDL-58423 core_calendar: moved \core_calendar\event class
Part of MDL-55611 epic.
2017-04-04 11:01:49 +01:00
Andrew Nicols
89cfa1e6b2 MDL-58363 mod_data: Remove calendar is_visible
Part of MDL-55611 epic.
2017-04-03 11:37:09 +08:00
Mark Nelson
7c6f961bf9 MDL-57877 mod_data: added action events
Part of MDL-55611 epic.
2017-04-03 11:36:34 +08:00
Marcus Green
f9729dcfe0 MDL-23919 mod_data: add requiredentries to completion settings
Added required entries text field to the completion criteria area.
This field accepts a number.

If the legacy Entries required field has a value greater than 0 it will
be displayed and editable. For new instances this field will not be displayed.
2017-03-31 15:20:44 +01:00
Juan Leyva
57ab070e01 MDL-57925 mod_data: Implement check_updates_since callback 2017-03-30 03:41:55 +02:00
Juan Leyva
023ffa656d MDL-57915 mod_data: Move view completion and event code to function 2017-03-13 19:21:07 +01:00
Andrew Nicols
4e2e54eed0 MDL-55866 mod_data: Remember editor enabled state for templates
Some templates can legitimately contain invalid HTML (e.g. mismatched tags)
because the templates operate in pairs.

In these instances we should not use an editor because the nature of the
editor (content editable) means that the browser automatically corrects all
HTML supplied to it, thus breaking the template entirely.

Therefore we need to disable HTML editors for some templates, and do so in
a way tied to the instance of the activity, rather than to a specific user.

This patch adds a new 'config' field, with matching setters and getters, to
allow such per-instance values to be stored.
2016-09-15 08:38:10 +08:00
Stephen Bourget
87d6e85a9a MDL-55158 mod_data: Add calendar events for database activities 2016-07-18 18:35:37 -04:00
Adrian Greeve
4a9a9bad73 MDL-51486 mod_data: Unit test update for item ratings.
Additional checks that access is available for item ratings
on records that have a group id of zero (all participants).
2015-11-04 10:12:39 +08:00
Andrew Nicols
be09ca85ef MDL-50664 mod_data: Fix for unit test failure 2015-09-23 09:27:30 +08:00
Ryan Wyllie
ec9e1bec57 MDL-50664 mod_data: tests for 'manageapproved' setting.
Adding test coverage for the 'manageapproved' setting that
was added by Johannes Burk.
2015-09-17 06:18:26 +00:00
Ankit Agarwal
731c2712e7 MDL-50173 ratings: Use proper checks to ensure ratings are viewable.
Mainly to verify groups visibility this new callback has been created.

Note this was originally 3 commits but for amending purposes they have
been squashed.
2015-09-09 04:07:21 +02:00
Russell Smith
d2c58b95bb MDL-43835 phpunit: Correct unit tests.
When different ID's are set for each sequence a number
of unit test failures appear.  They have been corrected
to allow unit tests to pass with the new generator in place.
2014-06-17 19:08:01 +10:00
Rajesh Taneja
b54696395d MDL-44552 Events: Fixed wrong id returned in get_url 2014-03-19 09:57:44 +08:00
Marina Glancy
1b066c06c6 Merge branch 'MDL-43440-master' of git://github.com/mr-russ/moodle 2014-02-03 13:42:23 +08:00
Rajesh Taneja
623a32e50d MDL-43736 Events: Updated unit test to test context not used in event 2014-01-29 11:39:50 +08:00
Russell Smith
74b63eae76 MDL-43440 unit testing: Use cmid in unit tests when it should be used.
instance is has been used instead of cmid.  This works as all id's are 1
in most cases, but not always.

accesslib_clear_all_caches_for_unit_testing was updated to clear the
$USER->access cache which would fail test when the wrong user's data was used.
2014-01-25 08:57:32 +11:00
Rajesh Taneja
cdfd607449 MDL-43293 Events: Added unit test for comment events 2013-12-23 09:22:15 +08:00
Adrian Greeve
e727e8ff58 MDL-40871 - mod_data: Unit tests for data_delete_record() 2013-08-09 16:53:18 +08:00