Commit Graph

44 Commits

Author SHA1 Message Date
b2a2d3dc66 MDL-79338 core: add support for hook callback redirection in tests 2023-09-14 11:47:52 +02:00
c1d805a676 Merge branch 'MDL-78738-master' of https://github.com/andrewnicols/moodle 2023-08-01 16:24:42 +02:00
235d5b9b72 MDL-78738 core_testing: Add helper to run adhoc tasks 2023-08-01 19:50:13 +08:00
1a53cbbae4 MDL-77989 testing: Add test file isolation helper
When we deprecate the use of a file, we often include tests which ensure
that the legacy behaviour is maintained. There are also legacy uses
in the community where people would like to use the deprecated API for a
period.

The issue that we face is that, if the deprecated file is included once,
then it will be included for all other, unrelated, tests. This means
that other tests may not detect cases where the deprecated file was
included.

We can solve these cases by running the test that performs the inclusion
in a deprecated process. This means that the inclusion is only performed
in that isolated process, and other unrelated tests do not include the
file.

However, we also then need to detect which files which are including the
file and which we do not know about.

This change introduces:
- an override to the TestCase::setInIsolation method to define a
  constant when the test is running in isolation
- a new function that a file can call when it is included, to make sure
  that the test process was isolated, where there is any test.
2023-04-21 13:33:56 +08:00
5319ba9c15 MDL-77837 phpunit: Ensure that the cron user setter is used
When running an adhoc task in a unit test we should use the cron variant
of the set user method to mimic the behaviour of a real cron run.
2023-04-06 23:19:01 +08:00
f4891b1034 Merge branch 'MDL-69882' of https://github.com/paulholden/moodle 2023-03-17 13:04:33 +01:00
6b6e7eaad2 MDL-69882 phpunit: final removal of deprecated 310 helper methods. 2023-03-13 17:46:44 +00:00
9ec46c232d MDL-77186 core: Move all uses of cronlib to new class 2023-03-13 21:21:13 +08:00
e5ca7766e7 MDL-52805 core: Remove legacy log calls 2023-03-07 13:08:46 +08:00
447316a9f6 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:00 +02:00
8183def69e 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:00 +02:00
fc1785b086 MDL-60978 testing: Support ability to run phpunit in isolated process 2019-06-21 14:36:13 +08:00
26218b7852 MDL-65204 phpunit: make testcases match their expected signature 2019-04-03 10:39:19 +08:00
0616f045c3 MDL-53566 core: Add support for context locking
This chagne adds support for a new feature known as Context Locking.
This allows a context to be locked, thereby removing all write
capabilities for all users (including admin) for that context, and all
child contexts.
2018-11-13 21:17:40 +08:00
7bd269e82d MDL-62660 tool_dataprivacy: Add method for unit tests to run adhoc tasks 2018-08-20 15:31:20 +08:00
801a372dad MDL-60611 phpunit: switch to namespaced phunit classes 2017-11-02 23:45:34 +01:00
ef15173794 MDL-56354 unittests: Put debug messages in the failure notice. 2016-10-26 08:39:10 +11:00
74ee9d29d2 MDL-55944 testing: Reduce sleep usage.
Remove sleep() and replace with waiting for a second to roll over,
this results in a simpler call the guarantee time() has moved forward
2016-09-14 09:49:30 +10:00
20ff2fba25 MDL-48621 events: Adapting unit tests to debugging messages
- A new assertDebuggingCalledCount has been introduced, as multiple debugging messages
  may be called in some cases, for example when calling events_cron with queued events
  that need to be dispatched.
- events_update_definition has been moved out of setUp as debugging messages are only
  caught by our phpunit custom stuff when they are called inside tests.
2016-01-19 15:19:10 +08:00
faea241337 MDL-52656 unittest: Reset original session while setting user 2016-01-08 09:41:28 +10:00
1766e6a17f MDL-52284 core: PHP7 engine errors have type Throwable 2015-12-10 10:49:37 +08:00
d74b7e424f MDL-52284 core: compatibility with Exception/Throwable changes in PHP7 2015-12-10 10:49:36 +08:00
81676e84e6 MDL-52077 unittest: Fixed string typo 2015-11-10 13:53:47 +08:00
5ecf8e8f21 MDL-51266 unittest: replaced low level phpunit_util calls 2015-09-23 15:42:48 +08:00
b9432e1a7d MDL-50926 phpunit: Advanced testcase should extend base_testcase 2015-08-11 02:37:28 +02:00
d6e7a63d9a MDL-49684 timezones: rewrite timezone support
This patch replaces all homegrown timezone
stuff with standard PHP date/time code.

The main change is the introduction of core_date
class that returns normalised user and server
timezones. From now on nobody should be using
$CFG->timezone or $user->timezone directly!

Other new features and fixes:
* admins are prompted for timezone during install
* editing of other users is finally fixed
* timezones are displayed in user profile
* new $this->setTimezone() in phpunit
* time locale is now automatically reset in phpunit
* timezone is now automatically reset in phpunit
* phpunit has Australia/Perth as default timezone
2015-04-06 13:53:51 +12:00
c386f35bca MDL-44339 treat unexpected debugging() calls in phpunit tests as errors 2014-03-14 11:43:46 +08:00
623a32e50d MDL-43736 Events: Updated unit test to test context not used in event 2014-01-29 11:39:50 +08:00
2a67e105b6 MDL-41935 attempt to work around random time comparison test failures 2013-10-12 15:53:25 +02:00
a9d2f1b414 MDL-41707 allow custom location of external test files used from unit tests 2013-09-27 10:47:56 +02:00
d79d5ac276 MDL-31501 rework user session architecture
List of changes:
 * New OOP API using PHP namespace \core\session\.
 * All handlers now update the sessions table consistently.
 * Experimental DB session support in Oracle.
 * Full support for session file handler (filesystem locking required).
 * New option for alternative session directory.
 * Official memcached session handler support.
 * Workaround for memcached version with non-functional gc.
 * Improved security - forced session id regeneration.
 * Improved compatibility with recent PHP releases.
 * Fixed borked CSS during install in debug mode.
 * Switched to file based sessions in new installs.
 * DB session setting disappears if DB does not support sessions.
 * DB session setting disappears if session handler specified in config.php.
 * Fast purging of sessions used in request only.
 * No legacy distinction -  file, database and memcached support the same functionality.
 * Session handler name included in performance info.
 * Fixed user_loggedin and user_loggedout event triggering.
 * Other minor bugfixing and improvements.
 * Fixed database session segfault if MUC disposed before $DB.

Limitations:
 * Session access time is now updated right after session start.
 * Support for $CFG->sessionlockloggedinonly was removed.
 * First request does not update userid in sessions table.
 * The timeouts may break badly if server hosting forces PHP.ini session settings.
 * The session GC is a lot slower, we do not rely on external session timeouts.
 * There cannot be any hooks triggered at the session write time.
 * File and memcached handlers do not support session lock acquire timeouts.
 * Some low level PHP session functions can not be used directly in Moodle code.
2013-09-21 13:11:56 +02:00
93564564e4 Merge branch 'MDL-41196-m' of git://github.com/andrewnicols/moodle 2013-08-21 09:56:16 +12:00
1aba6b2b4d MDL-41196 Unit Tests: Add a phpmailer message sink 2013-08-15 13:58:51 +01:00
96f81ea385 MDL-39474 introduce $CFG->debugdeveloper and cleanup $CFG init 2013-08-12 13:01:47 +02:00
320aee339c MDL-40935 phpunit: Remove assertLegacyEventName() since get_legacy_eventname() is public now 2013-08-06 14:58:30 +08:00
d6277b0ca0 MDL-40997 phpunit: Assertions for events legacy data 2013-08-02 18:30:02 +08:00
62401e8fd5 MDL-39846 implement event sink for unit testing 2013-07-19 08:43:29 +02:00
71fc50031d MDL-38989 detect changed timeout in tests
The trouble is that PHPUnit should ideally test mostly low level libraries that should not change the timeouts.
2013-04-10 09:48:57 +02:00
5c3c2c81be MDL-37457 testing Refactoring references 2013-01-15 11:07:43 +08:00
4c9e03f0ac MDL-36031 implement message redirection for unit testing 2012-10-13 20:00:54 +02:00
94c9db5493 MDL-35479 document unit test debugging() changes 2012-09-17 13:00:36 +02:00
ef5b5e051e MDL-35479 debugging support in our phpunit integration 2012-09-17 11:27:57 +02:00
d59ef9c5ab MDL-32926 exorcise setUser(2) evil from phpunit 2012-05-12 21:42:07 +02:00
7e7cfe7a03 MDL-32960 refactor phpunit integration to one class per file structure 2012-05-12 20:53:48 +02:00