Commit graph

27988 commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
7f20e2071c MDL-67673 phpunit: Document all the changes in upgrade.txt
This includes:

- Breaking changes (return void + PHP 7.1 min requirement).
- Deprecations and removals.
- Specifically DbUnit and its replacement.
- Printer showing how to rerun tests removed.
2020-10-21 12:46:05 +02:00
Eloy Lafuente (stronk7)
0ab106f41c MDL-67673 phpunit: Remove the rerun hint on failed test cases
That custom printer was using some hacks to be able to intercept
configuration switches, reflection and other tricks to be able to
print the:

To re-run:
 vendor/bin/phpunit --verbose "core_setuplib_testcase" lib/tests/setuplib_test.php

line on every failed/exceptional/skipped test. After some internal
discussion it was agreed that the normal phpunit output:

1) core_setuplib_testcase::test_localcachedir
Time is lower that allowed start value
Failed asserting that 1601976686 is equal to 1601976687 or is greater than 1601976687.

/var/www/html/lib/phpunit/classes/advanced_testcase.php:446
/var/www/html/lib/tests/setuplib_test.php:170
/var/www/html/lib/phpunit/classes/advanced_testcase.php:80

has already all the information at hand about how to rerun a test:

- vendor/bin/phpunit lib/tests/setuplib_test.php
- vendor/bin/phpunit --filter core_setuplib_testcase::test_localcachedir
- vendor/bin/phpunit --filter ::test_localcachedir
- vendor/bin/phpunit --testsuite componentname_testsuite
- vendor/bin/phpunit --config <<compoenent directory>>
- use --cache-result to get failed tests rerun with ease.
- ...

So better, let's use standard phpunit output and done. Also, note that,
with the upgrade to phpunit 8.5, the printer was not working correctly
any more, causing some switches, like --verbose ... to be ignored. Sure
it could have been fixed but, as commented above, no real need for all
that "parapheranlia" to print the rerun information.
2020-10-21 12:46:05 +02:00
Eloy Lafuente (stronk7)
9f82c9aece MDL-67673 phpunit: deprecate old phpunit/dbunit stuff
Apply the standard deprecation procedure to the old APIs, to
be removed in Moodle 4.2 (MDL-69882). Existing unit tests
cover the deprecation debugging.

Originally MDL-64600
2020-10-21 12:46:05 +02:00
Eloy Lafuente (stronk7)
1f13dff1a7 MDL-67673 phpunit: Move tests to use new phpunit_dataset
- Make advanced_testcase old methods to use new ones internally.
- Fix advanced_testcase, statslib, mod/quiz and mod/data tests.

Originally MDL-64600
2020-10-21 12:46:05 +02:00
Eloy Lafuente (stronk7)
be396eddf0 MDL-67673 phpunit: Introduce a new, lightweight phpunit_dataset
In charge of taking over the, now removed/archived, phpunit/dbunit
package. It supports loading of CSV/XML files and strings and
PHP arrays, allowing to send the loaded information to database.

Perform some basic controls about the consistency of information,
surely not super-exhaustive but fair enough.

100% covered with unit test.

Planned like an "interim" replacement for phpunit/dbunit uses in
core that, ideally, should be moved to generators stuff at some
point.

Note, expect a few tests in core to fail with this commit, I've
changed some fixtures around. Next commit will fix existing uses.

Originally MDL-64600
2020-10-21 12:46:05 +02:00
Eloy Lafuente (stronk7)
46606b3ddd 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:05 +02:00
Eloy Lafuente (stronk7)
35bc26b516 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:05 +02:00
Eloy Lafuente (stronk7)
ddf72dd60d 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:05 +02:00
Eloy Lafuente (stronk7)
0ae27225f5 MDL-67673 phpunit: Remove deprecated assertArraySubset()
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

assertArraySubset() is deprecated and will be removed in PHPUnit 9.
2020-10-21 12:46:05 +02:00
Eloy Lafuente (stronk7)
a6674bf8a4 MDL-67673 phpunit: Remove deprecated assertInternalType()
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

assertInternalType() is deprecated and will be removed in
PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(),
assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(),
assertIsResource(), assertIsString(), assertIsScalar(),
assertIsCallable(), or assertIsIterable() instead.
2020-10-21 12:46:05 +02:00
Eloy Lafuente (stronk7)
dc87fd4b3f MDL-67673 phpunit: phpunit_constraint_object_is_equal_with_exceptions
Constraints are now declared final, so we cannot extend them anymore.

Hence, instead of extending PHPUnit\Framework\Constraint\IsEqual we
are just wrapping it into our constraint.
2020-10-21 12:46:04 +02:00
Eloy Lafuente (stronk7)
d81a94807b 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:46:04 +02:00
Eloy Lafuente (stronk7)
c611109ed7 MDL-67673 phpunit: Bump to PHPUnit 8.5 and remove DBunit
This makes everything to break, but it's what we'll be fixing
in the next commits, heh. :-)

Generated with php72 (min version supported), following the
instructions @ https://docs.moodle.org/dev/Composer
2020-10-21 12:46:04 +02:00
Paul Holden
74ef7dc5b1 MDL-69788 admin: validate language menu configuration. 2020-10-21 11:24:22 +01:00
Neill Magill
55d463b9f2 MDL-69553 output: Handle pre-loading multiline string defines
Before this patch strings that were declared over multiple lines in
a template would not be parsed correctly.

{{#str}}value,
mod_forum{{/str}}

would have been been parsed to get_string('value', 'core')

{{#str}}
value, mod_forum
{{/str}}

would have been been parsed to get_string('', 'core')
2020-10-21 10:06:26 +01:00
Neill Magill
bbb58b10ad MDL-69553 output: Unit tests for loading multiline string defines 2020-10-21 10:06:25 +01:00
Adrian Greeve
5429ece3f8 Merge branch 'MDL-69807-310' of https://github.com/paulholden/moodle into MOODLE_310_STABLE 2020-10-21 14:18:02 +08:00
Adrian Greeve
32f99bc4d1 Merge branch 'MDL-68766-M310' of https://github.com/michael-milette/moodle into MOODLE_310_STABLE 2020-10-21 12:54:02 +08:00
Jake Dallimore
df0df3110d Merge branch 'MDL-68983-recent-session-lock-ro-MOODLE_310_STABLE' of https://github.com/brendanheywood/moodle into MOODLE_310_STABLE 2020-10-21 12:45:55 +08:00
Jake Dallimore
17056bf206 Merge branch 'MDL-69751-310' of git://github.com/mihailges/moodle into MOODLE_310_STABLE 2020-10-21 10:02:47 +08:00
Adrian Greeve
55189def65 Merge branch 'MOODLE_310_STABLE-MDL-68284' of https://github.com/yao9394/moodle into MOODLE_310_STABLE 2020-10-20 08:49:06 +08:00
Mihail Geshoski
086a2adc35 MDL-69751 core: Restore deleted guest user and add missing context
This upgrade step fixes the cases where the current guest user is
labelled as 'deleted' and the related user context is missing.
2020-10-20 08:41:35 +08:00
Andrew Nicols
0a54a501eb Merge branch 'MDL-69687-m310' of https://github.com/sammarshallou/moodle into MOODLE_310_STABLE 2020-10-20 08:02:22 +08:00
Paul Holden
9428e33d55 MDL-69807 blocks: remove redundant sesskey loading edit/delete page. 2020-10-19 22:40:45 +01:00
Eloy Lafuente (stronk7)
31a98b3fb2 Merge branch 'MDL-69906-310-searchsimpledb' of git://github.com/mudrd8mz/moodle into MOODLE_310_STABLE 2020-10-19 22:56:31 +02:00
Sara Arjona
33c7881448 Merge branch 'MDL-69897-310' of https://github.com/paulholden/moodle into MOODLE_310_STABLE 2020-10-19 18:14:54 +02:00
sam marshall
178d5a0e23 MDL-69687 Course: remove_course_contents orphaned completion data
The remove_course_contents function did not delete data from
course_module_completion table in most cases, resulting in large
quantities of orphaned data.
2020-10-19 10:24:44 +01:00
Brendan Heywood
4db3403481 MDL-69513 email: Add support for email DKIM signatures 2020-10-19 16:20:42 +11:00
Michael Milette
1b4ef7cd88 MDL-68766 auth: Login form: 'Log in using...' should be h3, not h6 2020-10-17 03:59:35 -04:00
sam marshall
3576eb4835 MDL-69687 Course: Improve removal of completion data on MySQL 2020-10-16 18:22:51 +01:00
sam marshall
39eb58c754 MDL-69687 DB: Add API for deleting data based on subquery
The new API works on normal databases (by deleting data based on the
subquery) and also on MySQL (by deleting the data using a weird join
on the subquery).
2020-10-16 18:22:51 +01:00
Paul Holden
252f95e1b7 MDL-69788 lang: fallback to all translations if misconfigured.
If given translation list contains only invalid entries, fallback
to returning the complete list of available language translations.
2020-10-16 14:38:03 +01:00
Sagar Ghimire
1ebbd18b82 MDL-68284 gradebook: Prevent exposing hidden quiz grade item 2020-10-16 15:06:34 +11:00
Adrian Greeve
a2aa548af7 Merge branch 'MDL-69549-310-7' of git://github.com/andrewnicols/moodle into MOODLE_310_STABLE 2020-10-15 15:11:29 +08:00
Jun Pataleta
30eccfabaa Merge branch 'MDL-69520-310' of git://github.com/sarjona/moodle into MOODLE_310_STABLE 2020-10-15 13:53:36 +08:00
Andrew Nicols
17d4bc49f6 MDL-69549 core: Add context export API 2020-10-15 13:46:25 +08:00
Sara Arjona
ad28920d0b MDL-69520 core_h5p: add example and tutorial links 2020-10-14 18:35:50 +02:00
Víctor Déniz
5ea92799c4 Merge branch 'MDL-69779-better-x-redirect-by-MOODLE_310_STABLE' of https://github.com/brendanheywood/moodle into MOODLE_310_STABLE 2020-10-13 23:41:59 +01:00
Brendan Heywood
15044cea7f MDL-68983 cache: Fix bug with readonly session combined with lock debug 2020-10-13 14:53:26 +11:00
Andrew Nicols
1170a8b694 Merge branch 'MDL-66928-request-dir-purge-bug-MOODLE_310_STABLE' of https://github.com/brendanheywood/moodle into MOODLE_310_STABLE 2020-10-13 11:49:10 +08:00
Brendan Heywood
69959c371f MDL-66928 core: Move request dirs to system tmp instead of localcache 2020-10-13 14:29:30 +11:00
Jake Dallimore
a7ea95030c Merge branch 'MDL-68292-admin-sesskey-MOODLE_310_STABLE' of https://github.com/brendanheywood/moodle into MOODLE_310_STABLE 2020-10-12 14:37:07 +08:00
Brendan Heywood
3f04dbee09 MDL-68292 core: Remove sesskey leakage on module pages 2020-10-12 17:11:59 +11:00
Adrian Greeve
6a91117d4a Merge branch 'MDL-65743-310' of git://github.com/lameze/moodle into MOODLE_310_STABLE 2020-10-12 13:41:44 +08:00
Simey Lameze
cfe9f53e91 MDL-65743 lib: update moodle library docs 2020-10-12 13:10:12 +08:00
Simey Lameze
decd480c42 MDL-65743 lib: add XMPPHP namespace and update calls 2020-10-12 13:10:12 +08:00
Simey Lameze
d947f53d4c MDL-65743 lib: upgrade XMPPHP library to v2.2 2020-10-12 13:10:12 +08:00
Andrew Nicols
00877bf283 Merge branch 'MDL-69776-310' of git://github.com/jleyva/moodle into MOODLE_310_STABLE 2020-10-12 12:33:51 +08:00
Adrian Greeve
6f86e933ed Merge branch 'MDL-69649-310' of git://github.com/rezaies/moodle into MOODLE_310_STABLE 2020-10-12 10:15:41 +08:00
Jake Dallimore
7924191691 Merge branch 'MDL-69707-redis-avoid-write-MOODLE_310_STABLE' of https://github.com/brendanheywood/moodle into MOODLE_310_STABLE 2020-10-12 09:57:46 +08:00