180 Commits

Author SHA1 Message Date
Andrew Nicols
49fc711a07
MDL-79637 testing: Update for current coding standards 2023-10-11 09:39:53 +08:00
Alex Yeung
b690c21eab MDL-78474 mod_label: fix phpunit and behat tests 2023-09-08 12:13:23 +01:00
Amaia Anabitarte
ded74e1e65 MDL-78530 core_completion: New default completion behat generator 2023-08-31 08:40:24 +02:00
Andrew Nicols
baa32f6569 MDL-75913 behat: Add support for file uploads in generators 2023-06-19 16:35:46 +10:00
Simey Lameze
2367bc9ff6 MDL-69231 behat: remaining work for role capability generator
This commit does few things:
* Unify data generators usage to role short name.
* Replace remaining manual steps to use the new data generator.
* Also replaced other manual steps to set config to use data generators.
* Tidy up of some tests, aligning pipes and splitting one line steps into multiple lines.
* Fixes tests to have one Given/When/Then per scenario.
2023-06-02 12:47:27 +08:00
Andrew Nicols
1a4303c9bc MDL-69231 tests: Add role capability setting generator 2023-06-02 12:47:27 +08:00
Andrew Nicols
8c9282f5d6 MDL-69231 tests: Improve existing role generator
Support definition of context levels and permissions.
2023-06-02 12:47:27 +08:00
Marina Glancy
8fc1486d36 MDL-77164 various: fix incorrect phpdocs 2023-04-13 11:35:06 +01:00
Mark Johnson
958da5b67e MDL-68093 groups: Add visibility and participation settings
These new settings are designed to enchance user privacy surrounding
groups. They allow groups to be configured so that users outside the
group cannot see the group, so that users in the group cannot see each
other, or so that users cannot see the group at all, even if they are in
it. This avoids issues where a group may be assigned based on sensitive
personal information (such as a person requiring special arrangements
due to a disability).

By default, groups are visible to all and available for participation in
activities, which maintains the current behaviour.

For performance, a new cache has been added to track the number of
groups on a course that are not visible to non-members. This allows us
to revert to the existing behaviour if the new features are not being
used at all on a course, and only apply the new visibility conditions if
they are.

Users who have the moodle/course:viewhiddengroups capability should be
concious of exposing hidden groups when showing their screen to other
users. The "Switch role to..." feature can be used to show a course page
on screen without exposing private availability conditions, for example.

The changes cover several specific areas:
* grouplib functions, which most code should use to get lists of groups
  and members (this includes the participants page).
* Activities supporting group overrides will not allow overrides for
  groups that are hidden from all users.
* Activities supporting separate/visible groups modes will only allow
  groups with the new "participation" flag enabled to be selected.
* Group messaging will be disabled for groups where members cannot see
  each other, or cannot see the group at all.
2023-03-14 08:52:25 +00:00
Dani Palou
3923ef9408 MDL-75788 testing: Handle new lines in menu profile field generator 2022-12-02 14:54:46 +08:00
Tim Hunt
8babdbd396 MDL-74608 activities: a new option to force the activity language
For a long time, Moodle has had the feature to force the language
for a whole course. This change adds the same feature at activity
level.

The course-level feature was controlled by a capability
moodle/course:setforcedlanguage, and I decided to use the same
capability to control this feature. I think a new capability would be
overkill.
2022-08-15 22:15:52 +01:00
Noel De Martin
bbaf83322f MDL-74613 grade: Add missing generators 2022-05-31 17:59:52 +02:00
Petr Skoda
d91cd20d64 MDL-74416 phpunit: fix generator counters reset 2022-05-10 07:47:46 +08:00
Jake Dallimore
c9636d261b MDL-69542 core_lib: make lti tool generator default to legacy version
This means existing tests won't need to change.
2022-02-11 11:01:26 +08:00
Eloy Lafuente (stronk7)
100bc51f1d MDL-73485 phpunit: externallib, generator and filter tescase names
All externallib_test, generator_test and filter_test classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- 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 tests under testing/tests:

1) The core_testing component doesn't exist.
2) But testing/tests are allowed because there is a suite pointing to it (phpunit.xml).
3) So, the only possible namespace for them is "core".
4) And to avoid problems with other core testcases (under lib/tests)
   they have been renamed to have testing_xxxx as prefix.

Finally, also modified calendar/tests/events/events_test.php because it uses
some renamed (core_calendar_externallib_testcase => \core_calendar\externallib_test)
classes.
2022-01-21 19:48:23 +01:00
Noel De Martin
3ce936fe6d MDL-72846 testing: Add default block generators 2021-12-02 14:58:24 +01:00
Peter
90acd8d381 MDL-52206 core: Add completion criteria to course_modules 2021-10-04 19:44:02 +08:00
Andrew Nicols
46a5c75196 MDL-72125 testing: Make global $CFG available when including generators
This will remove the requirement to add the global $CFG call to the top
of generator scripts.
2021-07-19 18:41:31 +08:00
Andrew Nicols
daf9b24b6a MDL-72125 testing: Add helper to run generators as a user 2021-07-16 12:33:56 +08:00
Marina Glancy
ef3d6a3d70 MDL-71051 core_user: use user profile generator in all tests 2021-04-28 11:47:21 +02:00
Amaia Anabitarte
9798fb06c8 MDL-70412 groups: Improving create_group data generator
Increasing the size of the name for generated groups
to ensure we don't have problems with ordering.
2021-04-15 16:57:23 +02:00
Simey Lameze
1fcd850859 MDL-71182 calendar: Revert "Merge branch 'MDL-67494-master' of git://github.com/lameze/moodle"
This reverts commit 9d58d4de46e9415eb4ac405a340381de44c510c1, reversing
changes made to 535c0277de3547f02d94959fbe103e44a6706d4e.
2021-03-24 09:11:01 +08: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
sam marshall
9ddb51b07e MDL-45242 Testing: Generators for user profile fields 2021-03-08 09:20:17 +00:00
Simey Lameze
2dd31504b9 MDL-67494 calendar: set userid to zero for shared events 2021-03-03 16:06:32 +08:00
Eloy Lafuente (stronk7)
d95c378771 MDL-67673 phpunit: Remove expectedException annotations
While this is not strictly required, because removal will
happen in PHPUnit 9.0, we are already getting rid of all
uses in core.

From release notes:https://phpunit.de/announcements/phpunit-8.html

The annotations `@expectedException`, `@expectedExceptionCode`,
`@expectedExceptionMessage`, and `@expectedExceptionMessageRegExp`
are now deprecated.
Using these annotations will trigger a deprecation warning
in PHPUnit 8 and in PHPUnit 9 these annotations will be removed.

Also, all uses of expectExceptionMessageRegExp() has been moved
to expectExceptionMessageMatches(). See https://github.com/sebastianbergmann/phpunit/issues/3957

TODO: Various weirdness found while doing the changes with these tests:
- vendor/bin/phpunit lib/tests/exporter_test.php (created MDL-69700)
- vendor/bin/phpunit competency/tests/external_test.php (same issue than prev one)
- vendor/bin/phpunit question/engine/tests/questionengine_test.php (created MDL-69624)
- vendor/bin/phpunit lib/tests/event_test.php (created MDL-69688)
2020-10-21 12:46:00 +02:00
Andrew Nicols
b430493ca8 MDL-68705 testing: Allow composer updates to be disabled 2020-08-20 20:11:13 +02:00
Michael Hawkins
4157e2d4f3 MDL-68348 lib: Added create_user_course_lastaccess generator
This creates a last access record for a user within a course.
It is requires for testing accesssince participants filtering.
2020-05-25 18:10:53 +08:00
Marina Glancy
5b529aca15 MDL-68333 testing: trigger user_created event in user generator 2020-05-19 19:11:54 +02:00
David Mudrák
866ce1fbe9 MDL-68645 output: Make other generators fail if they init the output too
Identically to what we've added to the module generators, let's raise a
coding exception if generating a block or a repository triggers the
theme and output initialisation.
2020-05-14 07:55:19 +02:00
Tim Hunt
f883c681ff MDL-68645 output: Make module generators fail if they init the output
The coding exception hint should say it all. Creating an activity module
should not need any output function call. It turned out it can lead to
hard-to-debug bugs and unexpected behaviour. So better to explicitly
fail and let the developer fix the code.
2020-05-13 10:03:01 +02:00
Pau Ferrer Ocaña
375d82cafc MDL-66612 calendar: Change global events to site events
AMOS BEGIN
 CPY [category,moodle],[category,calendar]
 CPY [site,notes],[eventtypesite,calendar]
 CPY [site,moodle],[site,calendar]
 MOV [typesite,moodle],[siteevent,calendar]
AMOS END
2019-10-21 09:33:01 +02:00
Andrew Nicols
fc1785b086 MDL-60978 testing: Support ability to run phpunit in isolated process 2019-06-21 14:36:13 +08:00
Simey Lameze
1fefa3ce7a MDL-63643 core_test: make possible to change users last ip field 2019-05-28 11:11:29 +08:00
Amaia Anabitarte
3204deacfe MDL-64993 core_message: Add self-conversations to create_user generator 2019-05-05 22:41:35 +02:00
Jason Platts
f7af1e0b9c MDL-65220 behat: test scenarios sometimes do not clear database data 2019-03-29 15:39:31 +00:00
Andrew Nicols
aac98ca7df MDL-62514 behat: Remove potentially conflicting names from description 2019-01-30 08:24:32 +08:00
Marina Glancy
bbf60b1412 MDL-57898 core_customfield: coding style fixes 2019-01-18 14:28:24 +01:00
Daniel Neis Araujo
01c1095954 MDL-57898 core_customfield: Custom fields API
This commit is part of work on Custom fields API,
to minimize commit history in moodle core the work of a team of developers was split
into several commits with different authors but the authorship of individual
lines of code may be different from the commit author.
2019-01-18 14:28:17 +01:00
Jake Dallimore
19237383f3 MDL-63884 core: allow tests to set group pictures when creating groups 2018-11-06 16:42:46 +08:00
Marina Glancy
442f12f81a MDL-62742 core: rename coursecat->core_course_category
Also rename course_in_list -> core_course_list_element
Deprecate class coursecat_sortable_records
2018-08-28 11:36:23 +02:00
Andrew Nicols
e984917db8 MDL-55609 testing: Add a create_and_enrol helper 2018-06-01 07:30:32 +08:00
Matteo Scaramuccia
ef844148a9 MDL-60923 backup: Added $CFG->backuptempdir
The new setting will allow to host the temporary backup files
into a specific target directory. Defaults to '$CFG->tempdir/backup'.

Calling make_backup_temp_directory() checks that the required sub-directory
will be properly created under the new target directory.
2018-04-16 23:50:28 +02:00
Andrew Nicols
68c2b72673 MDL-61223 course: Set default course start date 2018-01-16 14:26:19 +08:00
Andrew Hancox
64cd459648 MDL-50666 core: Rename allow_ACTION to core_role_set_ACTION_allowed 2017-12-19 13:53:23 +13:00
Andrew Hancox
a63cd3e2ca MDL-50666 core: Add function get_viewable_roles to set role visibility 2017-12-19 13:53:23 +13:00
sam marshall
a938e4096c MDL-60174 core_dml: fix miscellaneous incorrect recordset usage
The new recordset support for Postgres requires transactions and
will cause errors if recordsets are not closed correctly. This
commit fixes problems that were identified during unit tests, and
via some basic code analysis, across all core code. Most of these
are incorrect usage of recordset (forgetting to close them).
2017-11-27 11:10:33 +00:00
Juan Leyva
44ae08383b MDL-60813 calendar: Fix core_calendar_get_calendar_events for categories
Users couldn’t see category events when filtering by categories in the
core_calendar_get_calendar_events WS.
2017-11-16 19:16:01 +01:00
Andrew Nicols
fb3c0fc38b MDL-59890 calendar: Allow event creation in behat 2017-10-04 11:16:06 +08:00
Dan Poltawski
58a9d391a6 Merge branch 'wip-MDL-59287-master-v3' of git://github.com/abgreeve/moodle 2017-07-11 11:29:53 +01:00