159 Commits

Author SHA1 Message Date
Daniel Ziegenberg
08027e408c
MDL-81281 phpunit: assertObjectHasAttribute is deprecated
To be integrated as part of MDL-81266

When running PHPUnit 9.6 we get the following deprecation warnings:
"assertObjectHasAttribute() is deprecated and will be removed in PHPUnit
10. Refactor your test to use assertObjectHasProperty() instead."

So we replace all instances of assertObjectHasAttribute with
assertObjectHasProperty.

PHPUnit justifies the change with:
> PHPUnit currently refers to "fields" (see above) as "attributes". This
> is (or will become) confusing considering the introduction of
> attributes in PHP 8 and their support in PHPUnit.  PHPUnit will be
> changed to use the term "property" instead of "attribute" where "field"
> is meant.

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2024-03-25 16:21:45 +01:00
Daniel Ziegenberg
87267da39d
MDL-81281 phpunit: assertObjectNotHasAttribute is deprecated
To be integrated as part of MDL-81266

When running PHPUnit 9.6 we get the following deprecation warnings:
"assertObjectNotHasAttribute() is deprecated and will be removed in PHPUnit
10. Refactor your test to use assertObjectNotHasProperty() instead."

So we replace all instances of assertObjectNotHasAttribute with
assertObjectNotHasProperty.

PHPUnit justifies the change with:
> PHPUnit currently refers to "fields" (see above) as "attributes". This
> is (or will become) confusing considering the introduction of
> attributes in PHP 8 and their support in PHPUnit.  PHPUnit will be
> changed to use the term "property" instead of "attribute" where "field"
> is meant.

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2024-03-25 16:21:07 +01:00
Eloy Lafuente (stronk7)
ba1f804ffa
MDL-65292 style: Fix all function declarations white space
This has been generated running the following Sniffs, all
them part of the Moodle's CodeSniffer standard:
- PSR12.Functions.ReturnTypeDeclaration
- PSR12.Functions.NullableTypeDeclaration
- moodle.Methods.MethodDeclarationSpacing
- Squiz.Whitespace.ScopeKeywordSpacing

All them are, exclusively, about correct spacing, so the changes
are, all them, only white space changes.

Only exceptions to the above are 3 changes what were setting the
return type in a new line, and, when that happens, the closing
parenthesis (bracket) has to go to the same line than the colon.
2024-02-28 23:33:26 +01:00
Ilya Tregubov
1c059cb3fe
MDL-80504 forum: Fix seperate group mode 2024-02-08 15:32:31 +08:00
Paul Holden
b98fd96084
MDL-71733 behat: final removal of deprecated 400 step definitions. 2024-01-04 12:43:52 +00:00
Stephan Robotta
dd07c7c042 MDL-41465 reports: In separate group mode, limit to same 2023-12-06 13:53:28 +07:00
Paul Holden
2bb6c551cf
MDL-79310 enrol: restrict searched users to those user can view. 2023-10-04 14:30:45 +08:00
Marina Glancy
8fc1486d36 MDL-77164 various: fix incorrect phpdocs 2023-04-13 11:35:06 +01:00
Juan Leyva
27be439eb7 MDL-73708 course: Return geo pattern generated course images via WS 2023-03-22 17:39:07 -03:00
Mathew May
e5ca7766e7 MDL-52805 core: Remove legacy log calls 2023-03-07 13:08:46 +08:00
Andrew Nicols
a3cc26f8bb MDL-76583 core: Update uses of external_* classes 2023-01-19 07:34:09 +08:00
Amaia Anabitarte
31d84aaa2c MDL-75441 mod_forum: Show add new post button to guest users 2022-12-13 18:49:53 +01:00
Paul Holden
23930c2516 MDL-76490 behat: use defined step for interaction with autocomplete. 2022-12-05 14:02:33 +00:00
Dmitrii Metelkin
a6cad23b1a MDL-73431 enrol: Introduce a sync interval 2022-05-30 15:58:22 +10:00
Jun Pataleta
e60e8bc629 Merge branch 'MDL-73423-master' of https://github.com/marinaglancy/moodle 2022-05-26 00:18:35 +08:00
Eloy Lafuente (stronk7)
9f53b0e965 MDL-73971 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various 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:

- Some fixtures, initially defined in the test files have been
  moved to new files in fixtures subdirectory, leaving the unit
  test files clearer:
  - moodle2_course_format_test.php
- Rename wrong named test:
  - baseoptiogroup_test = baseoptigroup_test
2022-05-06 18:29:11 +02:00
Marina Glancy
a0398fdde8 MDL-73423 core_privacy: Calling reset() on objects deprecated PHP8.1 2022-04-29 16:16:07 +02:00
Marina Glancy
15eb402228 MDL-73669 core_enrol: move deprecated behat steps to own file
Steps were initially deprecated in MDL-72090
2022-02-04 17:17:08 +01: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
Eloy Lafuente (stronk7)
e4a2d9c1d4 MDL-73348 phpunit: normalize all privacy provider tests
As far as now all them have correct privacy level2 namespace:
- Move them to "privacy" subdir.
- Rename the files to "provider_test.php", this includes old
  privacy_test.php and privacy_provider_test.php files
- Rename the testcase to provider_test too (to match file name)

Also, change some relative paths and comments to point to new
locations.
2021-12-17 14:21:02 +01:00
Eloy Lafuente (stronk7)
57e6fb7ad9 MDL-73348 phpunit: privacy and privacy_provider testcase names
All privacy_test and privacy_provider_test classes:

- Namespaced with component\privacy.
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed.
- Renamed a few files to make all be privacy_test or privacy_provider_test.php
- All them passing individually.
- Complete runs passing too.
2021-12-17 14:21:02 +01:00
abgreeve
05a6bca72c MDL-72090 behat: Deprecation of enrolment behat step.
i_add_enrolment_method_with() is now deprecated, please use
i_add_enrolment_method_for_with() instead.
2021-12-09 11:13:35 +08:00
abgreeve
fcd4de8639 MDL-72090 navigation: Update to behat feature files for navigation.
This updates feature files to use the new steps to navigate to certain
pages.
2021-12-09 11:13:35 +08:00
abgreeve
8a5e36fa06 MDL-72090 navigation: Update to existing behat steps.
This creates new general behat steps for navigating in theme
boost and classic.
2021-12-09 11:13:35 +08:00
Juan Leyva
10a6e99ea2 MDL-73084 enroll: Return timemodified field in get_users_courses 2021-11-23 15:59:04 +01:00
Mathew May
bdffbe3e48 MDL-65799 enrol: Final deprecations 2021-11-10 15:22:43 +08:00
Eloy Lafuente (stronk7)
8515a0560f MDL-72807 behat: Add a few more @skip_chrome_zerosize tags
This is the 3rd round adding the tags to some scenarios
detected to be failing with zerosize problems lately.

Note that @ MDL-71108, the final solution will happen, say
switching to own webdriver till the upstream one is fixed
or whatever. Our @skip_chrome_zerosize solution is just a
workaround to have all those scenarios detected and ignored
by normal runs.
2021-10-14 16:12:20 +02:00
sam marshall
171313781d MDL-71836 core_enrol: Cannot search for users by username 2021-06-02 14:52:43 +01:00
Ferran Recio
45048b8796 MDL-70909 core: add cannotmatchanyrows to capabilities join 2021-04-22 13:16:35 +02:00
Paul Holden
b5267b7b38 MDL-70099 enrol: increase accuracy of current enrolments by date.
By rounding the current time it was possible that the most recently
created user enrolments (e.g. self enrolments) were being excluded.

This would manifest itself in a user being enrolled on a course,
but it not appearing under "My courses" navigation or on their own
Dashboard until the rounded time had caught up with the current
time.
2021-04-05 19:32:33 +01:00
sam marshall
987e55452f MDL-45242 Course: Enrol feature supports custom profile fields 2021-03-10 10:57:11 +00:00
Paul Holden
a251c260c4 MDL-70822 enrol: respect capability to view other users profile.
When retrieving courses of another user via web services, we should
respect the capability to view that users profile in a given course.
2021-03-02 23:44:24 +01:00
Andrew Nicols
74a86acc8d MDL-66979 behat: Use tab to blur current focus
The focus should be on something, rather than removed.

The way in which focus removal works can lead to side effects.
2021-01-22 14:52:10 +08:00
Ilya Tregubov
65a1d6e8e0 MDL-69869 enrol: Clean up - switch to [] from array(). 2020-12-08 09:15:15 +02:00
Ilya Tregubov
e53bc6a1f8 MDL-69869 enrol: Add ability to get suspended users through
core_enrol_get_enrolled_users webservice.
2020-12-08 09:15:15 +02:00
Andrew Nicols
ba34d6e225 MDL-70148 behat: Update steps for keyboard 2020-11-17 15:14:43 +08:00
Mihail Geshoski
253af8711d MDL-67837 backup: Add unit tests 2020-11-03 12:34:28 +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)
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
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
Dani Palou
25bc7a3d6b MDL-68098 ws: Add unit tests to test mathjax in WS 2020-09-23 11:18:41 +02:00
Alexander Bias
8471a0db42 MDL-61804 admin: Add setting for course visibility sorting 2019-10-08 11:58:39 +02:00
Simey Lameze
6d76fc107a MDL-66075 enrol: add unit tests for search_users webservice 2019-09-23 13:07:40 +08:00
Simey Lameze
1de4baf1f1 MDL-66075 core: various fixes & code polishing
* Removes unnecessary comment in search_users() WS.
* Replaces DB call by get_course() in search_users() WS.
* Fix discussionids handling on export.php.
* Coding style fix in test_search_users unit test.
* Add missing version bump.
* phpDOc fixes in post vault.
* Fix in the dataformat callback to handle different data types.
2019-09-23 13:07:30 +08:00
Shamim Rezaie
151ef39cd8 MDL-66269 enrol: added search_users method to course_enrolment_manager
Part of MDL-66075.
2019-09-20 08:19:01 +08:00
Shamim Rezaie
2d4ce64dde MDL-66489 enrol: Send all form data to WS and do all busines logic there
It is discouraged to use JS Date functions. We should pass all raw data to PHP.
2019-09-11 20:18:26 +10:00
Huong Nguyen
0fc30827dc MDL-64032 enrol_manual: Make consistent the UI for setting enrolment
Add end date/duration for the UI for setting enrolment should be consistent
2019-07-23 14:21:43 +07:00
Juan Leyva
dfcf8342fb MDL-65211 enrol: Return if user is being completion tracked 2019-04-01 18:45:14 +02:00
Julien Boulen
b1d1369dff MDL-46803 course: Prevent unenrol users with multiple roles during reset 2019-03-18 11:20:08 +01:00
Eloy Lafuente (stronk7)
c93eedf8dd Merge branch 'MDL-64084-master' of git://github.com/jleyva/moodle 2019-03-12 00:29:58 +01:00