65 Commits

Author SHA1 Message Date
05977c9f6a MDL-85563 phpunit: Clock API should always use Moodle system time
When using `clock::now()` the frozen cloxk and incrementing clock will now
always return a `DateTimeImmutable` that uses the configured Moodle system
time. In unit tests this will be Australia/Perth.

Before this change, it would sometimes be UCT.
2025-06-30 11:38:00 +01:00
2f3cffd815 Merge branch 'MDL-83468-main' of https://github.com/andrewnicols/moodle 2025-01-20 16:47:56 +01:00
bc75ef8bbc MDL-83468 phpunit: Fix various tests after phpunit 10 2025-01-20 16:47:55 +01:00
c26cc0e005 MDL-83172 dml: Remove Oracle from LMS 2025-01-13 17:11:55 +07:00
152a37cb59 MDL-83316 Behat: New step allows system clock change 2024-11-06 13:59:09 +00:00
024e36be17 MDL-81634 core: Fix all implicitly defined nullables
Note: This does not impact third-party libraries.
2024-08-02 14:11:12 +08:00
298c13ac3b MDL-80838 core: Add PSR-20/Clock support
This commit adds the PSR-20 ClockInterface to core, with a
moodle-specific extension to the Interface at `\core\clock`, and a
standard clock at `\core\system_clock`.

Further clocks are provided as `\incrementing_clock` and `\frozen_clock`
which are available to unit tests using:

- `$this->mock_clock_with_incrementing(?int $starttime = null);`
- `$this->mock_clock_with_frozen(?int $time = null);`

For the incrementing clock, every call to fetch the time will bump the
current time by one second.

For the frozen clock the time will not change, but can be modified with:
- `$clock->set_to(int $time);`; and
- `$clock->bump(int $seconds = 1);`
2024-04-02 10:24:54 +08:00
6dc8d74ac5 MDL-79637 core: Fix mistyped and replacement 2023-10-24 21:49:27 +08:00
73267a7848 Merge branch 'MDL-79637-master' of https://github.com/andrewnicols/moodle 2023-10-24 10:48:43 +08:00
49fc711a07 MDL-79637 testing: Update for current coding standards 2023-10-11 09:39:53 +08:00
9741db47f7 MDL-79638 phpunit: Remove mysql/mariadb hack
This hack was introduced to work around a bug in MySQL 5.6.14 and
MariaDB at the time.

https://bugs.mysql.com/bug.php?id=69882

It was addressed a few months later in 5.6.16, and 5.7.4.
MariaDB merged version 5.6.16 of MySQL's InnoDB engine in MariaDB
10.0.11 and got hte patch from there.

Moodle has required MySQL 8.0, and MariaDB 10.6.7 since Moodle 4.2 and
it is therefore safe to remove these hacks.
2023-10-10 23:35:26 +08:00
fc1785b086 MDL-60978 testing: Support ability to run phpunit in isolated process 2019-06-21 14:36:13 +08:00
f7af1e0b9c MDL-65220 behat: test scenarios sometimes do not clear database data 2019-03-29 15:39:31 +00:00
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
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
a169739d5d MDL-56273 cache: Use cache initialise always.
purge_all() and purge_by_definition() look in the configuration
for which caches are available and then creates them to purge them.
The configuration stores the values used by initialise(), not
initialise_unit_test_instance() and would therefore fail to purge
all caches if they were not purged by another means.

In the case of filestore, it's purged by unit tests, in the case
of memcache(d), it purges the whole store when a single definition
is requested.

Therefore all configuration was moved into the configuration file
during unit tests and does not have any special override codes in
the unit test infrastructure.
2016-10-30 13:42:43 +11:00
4f391d7a33 MDL-55143 unittests: Check the db rather than cache for version hash. 2016-10-18 09:35:22 +11:00
cc0ac30488 MDL-55764 behat: Reset static update db list
While running multiple suites we should
ensure static cli cache is also reset.
2016-08-30 08:00:01 +08:00
30daa61475 Merge branch 'wip-mdl-55072' of https://github.com/rajeshtaneja/moodle 2016-08-24 09:26:29 +08:00
5aa9b5cee3 MDL-55072 behat: Added support for overriding theme tests 2016-08-24 08:57:15 +08:00
e99f0cbba6 MDL-55072 behat: refactor behat_config_manager 2016-08-19 06:49:13 +08:00
39eb8abe15 MDL-46514 behat: Delete tablesupdatedbyscenario before suite
Delete tablesupdatedbyscenario before db reset to ensure
db is fully reset. In case user exits or process terminated
then the file will be left and can lead to wrong results
2016-08-19 06:46:27 +08:00
fc2e137750 MDL-55174 core_testing: Use proper directory separator
While searching for existing files if directory
separator is not correct then original files
and directories will be deleted. So use DIRECTORY_SEPARATOR.
2016-07-15 13:51:41 +08:00
13708875d3 MDL-54573 testing: don't uppercase dbtype 2016-05-17 17:16:12 +08:00
fc3d70d798 MDL-54573 testing: don't uppercase dbtype 2016-05-16 08:25:10 +01:00
f6cbdf788a MDL-54573 testing: use dbtype rather dbvendor for diagnostics
So that we can differentiate between drivers
2016-05-13 14:49:42 +01:00
e891c8381e MDL-52502 behat: Ensure php web and cli version is same 2016-04-05 11:46:44 +08:00
af2dc48b41 MDL-52502 phpunit: Add php, db and os deatils 2016-04-05 11:46:43 +08:00
0e5458f45f Merge branch 'wip-mdl-52799' of git://github.com/rajeshtaneja/moodle 2016-01-29 10:15:16 +08:00
31ed36f193 MDL-52721 behat: Exclude links in moodle while finding tests
Parallel run create links within moodle
so avoid searching for tests within links
2016-01-19 14:35:18 +00:00
28dab6408c MDL-52799 unittest: Removed empty if statement 2016-01-18 15:47:07 +08:00
1226f3ca33 MDL-52799 phpunit: Truncate records for brokedmysql not empty. 2016-01-18 14:10:18 +08:00
60237c2ce2 MDL-52721 unittest: Exclude tests in vendor and node_modules 2016-01-18 10:25:02 +08:00
e487a51db3 MDL-52060 phpunit: Keep track of modified database for reset
Keep list of modified tables, so they can be reset
without any guess work
2015-12-22 15:37:40 +08:00
22d55b3950 MDL-52060 phpunit: Check file only if needed 2015-12-22 13:19:06 +08:00
44121fbdc9 MDL-52060 phpunit: Keep track of initial reset sequence 2015-12-22 13:19:06 +08:00
3c71c15c26 MDL-39752 behat: Modified following for parallel run:
1. Create behat datadir within behat_dataroot not at same level
2. Define suffix for link and not use hard-coded values
3. Renamed ns_parallel to run.php
4. Rename variables to best understand them
5. Added support for each run to specify db, prefix, rerun and profile.
6. Showing number of steps in each line of parallel run.
2015-03-09 06:52:54 +08:00
97d0445a7b MDL-48302 behat: Make sure to clear php file cache 2014-11-21 10:22:56 +08:00
3fa0daa90f MDL-47664 phpunit: Do not use sequence number changes for Oracle
When resetting a sequence number, we call change_database_structure()
which in turns clears the MUC cache for databasemeta. This cache contains
information about the table, columns, etc.

After the cache is cleared, it must be re-filled, and it was discovered
that the get_columns() code which fills this cache can take a particularly
long time. Given that this is called for every table in Moodle, this can
add up to a significant period, and this is done on a per-testsuite basis.

On my SSD install this was taking approximately 40 seconds on each re-fill
of the cache.
2014-10-17 13:28:46 +08:00
ddffa9d6d3 MDL-47538 phpunit: fix invalid PHPUNIT_SEQUENCE_START constant 2014-10-06 17:31:15 +13:00
529495f7ce MDL-46193 phpunit: Use random starting value on initialization. 2014-07-04 16:33:13 +10:00
fbb0c914b0 MDL-43835 phpunit: Create unique starting id's for sequences.
When all starting autoincrement ids are the same, it's difficult to detect coding and testing
errors that use the incorrect id in test calls.  The classic case is cmid vs instance id.
To reduce the chance of the coding error we start sequences at different values where possible.

OUBlog installation is the case that highlighted this as it inserts a sitewide course module
at install time and cmid <> instance id in most cases.
2014-06-14 00:29:26 +10:00
a9236a2c3f MDL-45287 fix behat database reset between scenarios
We cannot find out if DB received any writes because behat
web access runs in different request.

This was affecting only scenarios without generators.
2014-04-28 17:02:58 +08:00
5d4c82560b MDL-44191 hack around MySQL 5.6 inability to lower auto_increment 2014-03-14 11:31:43 +08:00
630bb85d9e MDL-43266 testing: avoid assoc arrays for json
Last commit switched from raw arrays to associative
arrays. That leads to json_encode() to generate an
object instead of an array, ultimately leading to
problems with the rest of code expecting an array.

By using array_values() we are moving back to the
non-associative array.

Also, fix some file permissions.
2014-03-13 22:11:03 +01:00
d3daf24563 MDL-43266 testing: Removing duplicated keys 2014-03-12 17:49:55 +08:00
c78f19d153 MDL-43266 Testing sites are cleaning all test dataroot contents 2014-02-25 14:47:25 +08:00
244da9d1f8 MDL-43355 testing: Return the hash when HEAD points to a hash 2013-12-12 17:26:22 +08:00
7514c2f282 MDL-42842 testing: Generalization of the site info 2013-11-26 10:48:29 +08:00
c5701ce7d4 MDL-41086 rework detection of necessary upgrades 2013-08-08 21:11:40 +02:00