Commit Graph

53 Commits

Author SHA1 Message Date
Daniel Ziegenberg c23d5edb0f MDL-83334 core: Remove deprecated constant E_STRICT
One of the error levels PHP previously emitted was E_STRICT, on code
that was not strictly correct to ensure interoperability and forward
compatibility. PHP 7.0 converted the majority of existing E_STRICT
warnings to E_NOTICE, and since PHP 8.0, all E_STRICT notices have
changed to E_NOTICE.

Because all of the E_STRICT notices are upgraded to E_NOTICE since PHP
8.0, PHP 8.4 deprecates the E_STRICT constant.

The E_STRICT constant is deprecated in PHP 8.4. Using the constant
anywhere in PHP code now emits a deprecation notice in PHP 8.4 and
later.

The E_STRICT constant will be removed in PHP 9.0.

PHP core and core extensions since PHP 8.0 and later do not emit
E_STRICT notices at all. It is safe to assume that any PHP applications
that run on PHP 8.0 and later will never encounter E_STRICT notices, and
error reporting and handling can be safely updated to ignore E_STRICT
notices.

See: https://php.watch/versions/8.4/E_STRICT-deprecated

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2025-03-04 20:38:04 +01:00
Andrew Nicols 2b49ad42f5 MDL-81456 core: Use DI for all hook access
Using DI for all hook access means that it becomes significantly easier
to mock hooks and callbacks for unit testing without fundamentally
altering the structure of the code purely for the purposes of unit
testing.
2024-04-08 09:35:41 +08:00
Andrew Nicols 49fc711a07 MDL-79637 testing: Update for current coding standards 2023-10-11 09:39:53 +08:00
Andrew Nicols 99a6cd12b2 MDL-79637 phpunit: Do not reset DB during init of isolated tests
During the bootstrap of PHPUnit we ensure that the database has been
reset to its initial state.

We do this by checking the internally-stored DB write count between
runs. If the count is not yet set (null), or it has been increased, we
force a reset.

When running an isolated test the test runner resets the database, it
then sets up a new isolated test environment by writing a new PHPUnit
test case and passing it to a new PHP Process using standard in. As part
of this, the bootstrap is run for that process.

Because we are in a new process, the db write count is fresh and not yet
set. This has been leading to an additional db reset before the isolated
test.

To handle this we want to _not_ perform a reset during the
initialisation for isolated runs. We know that the DB is in a fresh
state before we start the run.

To support this we need to know whether the test is an isolated test
during the bootstrap, which means we cannot use the previous approach to
calculating this.

Instead we look at the PHP_SELF value. PHP sets this to "Standard input
code" when run from stdin, instead of running a file.

There should not be any other legitimate reason to run a PHPUnit
bootstrap via this stdin approach.

Unfortunately this approach is a little bit risky as it depends on the
presence of a specific string, however this string has been in place
since 2016, and there is no legitimate way of calculating this.

I did consider looking at whether the called script included `/vendor/`
and `/phpunit`, but this is also likely a risky approach if someone
calls PHPUnit in an unexpected way.

This approach is itself unit tested so any change to PHP's stdin string
before we deprecate this approach entirely in 12 months time will be
caught.
2023-10-11 09:29:26 +08:00
Petr Skoda 99a7a7c782 MDL-74954 core: add Hooks based on PSR-14 2023-05-20 11:03:46 +02:00
Eloy Lafuente (stronk7) 2e48f924e7 MDL-73586 phpunit: Simply, remove the setting
It's not available since PHP 7.0, so no use at all.
2022-03-08 14:56:59 +01:00
Matt Clarkson 728e8c4a3c MDL-72527 core: Fix behat unit test failure
$CFG->behat_wwwroot, $CFG->behat_dataroot and $CFG->behat_prefix being
undefined resulted in unit test failure.
2021-09-13 11:32:50 +12:00
Eloy Lafuente (stronk7) be30af0e23 MDL-71036 phpunit: Remove custom autoloader
Custom autoloaders are deprecated with PHPUnit 9 and will be removed
with PHPUnit 10.

Since PHPUnit 8.5 custom autoloaders don't do much because that
version removed the ability to launch unit tests by class name
and that's exactly the reason we had a custom autoloader (to map
class names to files within our tests). See MDL-67673 about
when direct use of classes was deprecated (8.5), now removed (9.5).

So, as far as it's unused, removing it now, test still can be
selectively using any of:

- a relative path to file (although there are some restrictions comming
  with PHPUnit 9, see https://github.com/sebastianbergmann/phpunit/issues/4105
- using --filter, to point to any classname[::method]
- using --testsuite to run a complete suite
- using --config to point to custom components.

Also, commented out the lib/ajax/tests directory because it doesn't
exist / is empty and PHPUnit 9 emits error when a configured test
directory does not exist. See
https://github.com/sebastianbergmann/phpunit/issues/4493.

Alternative was to completely remove the configuration line, but
decided to keep it around in case some day we want to add some
test there.
2021-03-11 19:22:24 +01:00
Andrew Nicols fc1785b086 MDL-60978 testing: Support ability to run phpunit in isolated process 2019-06-21 14:36:13 +08:00
Adam Olley edd51eb245 MDL-63811 phpunit: Fix typo in new allowed config variable
Without this, phpunit doesn't allow the pathtophp unit config setting to be set
in config.php as intended.
2018-10-30 09:15:59 +10:30
Toni Barberà Melià c759ae5d55 MDL-60514 tasks: added new config parameter. changes in cron execution 2018-10-25 08:02:44 +02:00
Eloy Lafuente (stronk7) 801a372dad MDL-60611 phpunit: switch to namespaced phunit classes 2017-11-02 23:45:34 +01:00
David Monllao c5705b3a0f MDL-60410 analytics: Whitelist pathtopython for testing 2017-10-13 13:44:47 +02:00
Eloy Lafuente (stronk7) 55946a892a MDL-54901 phpunit: Change phpunit wwwroot to HTTPS and fix tests
This includes:

- Changing PHPUnit's bootstrap to use https://www...
- Modify all existing expectations to the new wwwroot.
- Amend some tests now with different defaults because of is_https()
- Added a note to main upgrade.php about the change.
2017-04-18 03:40:17 +02:00
Rajesh Taneja db4b59fa03 MDL-58068 testing: Whitelist alternative_file_system_class in testing
Unit test and behat should be allowed to
run with alternative file system
2017-02-28 14:58:49 +08:00
Russell Smith 8f7dcb3453 MDL-55504 profiling: Support for PHPUnit and big profiles.
To support PHPUnit we need to support large profiles, these may
include backups and restores. To do that the following was required;
- gzcompress for database space saving.
- gzcompress for XML DomDocument field to say < 10Mb and allow imports.
- Save PHPUnit runs directly to a file so they can be imported to the normal database.
- Memory allowance on profiling view pages increases to support large profiles.
2016-09-06 12:41:56 +10:00
Damyon Wiese 1356d85151 MDL-52954 core: Change from pandoc to unoconv - it gives better results
Most importantly it retains formatting better, and supports different charsets far better than pandoc.
2016-03-30 11:48:39 +08:00
Damyon Wiese 2e76c14e11 MDL-52954 core: Add a document converter to file_storage
This lets us convert between common office formats. E.g. docx -> pdf
html -> pdf, html -> ods.

This commit also updates assignment editpdf plugin to use this converter
on all compatible submission files.
2016-03-30 11:48:39 +08:00
Ruslan Kabalin 7d19e0e33d MDL-50887 antivirus_clamav: Move global clamav settings to plugin level.
AMOS BEGIN
 MOV [clamfailureonupload,core],[clamfailureonupload,antivirus_clamav]
 MOV [configclamactlikevirus,core],[configclamactlikevirus,antivirus_clamav]
 MOV [configclamdonothing,core],[configclamdonothing,antivirus_clamav]
 MOV [configclamfailureonupload,core],[configclamfailureonupload,antivirus_clamav]
 MOV [configpathtoclam,core],[configpathtoclam,antivirus_clamav]
 MOV [configquarantinedir,core],[configquarantinedir,antivirus_clamav]
 MOV [configrunclamavonupload,core],[configrunclamavonupload,antivirus_clamav]
 MOV [pathtoclam,core],[pathtoclam,antivirus_clamav]
 MOV [quarantinedir,core],[quarantinedir,antivirus_clamav]
 MOV [runclamavonupload,core],[runclamavonupload,antivirus_clamav]
AMOS END
2016-02-25 09:55:45 +00:00
Andrew Nicols 556e3a9e8a MDL-48197 testing: Always set up a mail sink for mail redirection
Rather than setting noemailever in the bootstrap, this sets up a default
phpmailer message sink which will catch all messages.

Tests which require the phpmailer sink will continue to work as before
without change, though the noemailever config setting no longer needs to
be altered.

For tests wanting to test with noemailever set with the previous behaviour,
they will need to load the message sink and then close it.
2014-11-19 09:09:49 +08:00
Petr Skoda 1993cc02b6 MDL-47287 prevent web access to phpunit boostrap 2014-11-03 17:10:33 +08:00
Marina Glancy 0313897108 Merge branch 'wip-mdl-44839' of git://github.com/rajeshtaneja/moodle
Conflicts:
	lib/phpunit/bootstrap.php
2014-06-04 10:07:03 +08:00
Rajesh Taneja 1bce3a70d9 MDL-44839 admin: Moved all system executable paths to config
AMOS BEGIN
 MOV ['gspath','assignfeedback_editpdf'],['pathtogs','admin']
 MOV ['gspath_help','assignfeedback_editpdf'],['pathtogs_help','admin']
AMOS END
2014-06-03 17:33:49 +08:00
Sam Hemelryk 79a8ea653c MDL-45513 cache: added support to unit tests for alt cache stores 2014-05-30 08:41:07 +12:00
Petr Škoda 62c8032509 MDL-34347 remove all problematic global text caching
Instead we will create new MUC caches inside each filter plugin.
Please note that all cache filters should work with local caches
without the need of strict cache invalidation.
2014-01-14 10:49:23 +08:00
Petr Škoda 96f81ea385 MDL-39474 introduce $CFG->debugdeveloper and cleanup $CFG init 2013-08-12 13:01:47 +02:00
Petr Škoda d7245e3400 MDL-40475 add alternative component cache location and other improvements
Improvements include:
* Alternative location might be useful when server administrator wants to maintain
  a local copy of component cache instead of using shared $CFG->cachedir.
* Component caching is now enabled in behat tests which should improve performance.
* Standardised ignoring of component caching.
* Fixed debug mode in ABORT_AFTER_CONFIG scripts.
* General documentation improvements.
2013-07-12 13:05:41 +02:00
Petr Škoda c05a50992e MDL-40415 add explicit OPcache support 2013-07-04 19:32:26 +02:00
Petr Škoda d44e0aa323 MDL-40305 implement moodle specific phpunit testcase classloader 2013-06-24 21:29:37 +02:00
Petr Škoda 15bac12e9d MDL-37783 add some useful information to any phpunit output 2013-03-23 00:06:39 +01:00
Simon Coggins ec2d8ceb88 MDL-35332 lib: Improve security of hashed passwords 2013-02-09 06:47:57 +13:00
Petr Škoda a07c89c632 MDL-37713 let phpunit bootstrap create test dataroot if necessary 2013-01-26 14:59:27 +01:00
Dan Poltawski 77ea8340de Merge branch 'MDL-37458_master' of git://github.com/dmonllao/moodle 2013-01-21 11:14:38 +08:00
David Monllao 0ea35584ae MDL-37458 testing common methods generalization 2013-01-18 09:17:30 +08:00
Eloy Lafuente (stronk7) c6523d2f94 MDL-37555 Apply realpath() 2 CFG->phpunit_dataroot 2013-01-16 16:15:56 +01:00
Dan Poltawski 06dcb573c4 Merge branch 'w18_MDL-32589_m23_proxytest' of git://github.com/skodak/moodle 2012-04-30 17:00:23 +08:00
Petr Skoda 46cb5d9ace MDL-32589 remove bogus webproxy whitelisting
Thanks Dan Poltawski!
2012-04-30 08:35:16 +02:00
Petr Skoda 32962961a8 MDL-32651 increase memory limit to 2G when running phpunit tests
This should help when running tests with coverage reports.
2012-04-27 13:54:38 +02:00
Petr Skoda 366c6adba3 MDL-32589 phpunit: allow proxy server specification via config.php 2012-04-27 13:43:21 +02:00
Petr Skoda fb8e3faba2 MDL-32569 always set $CFG->wwwroot to http://www.example.com/moodle in test environment 2012-04-22 17:23:20 +02:00
Petr Skoda 0684ea9972 MDL-32400 do not silence diagnostic PHPUnit includes 2012-04-15 12:23:42 +02:00
Petr Skoda 0d8e51a65f MDL-32400 rework phpunit exit codes, use only php based init 2012-04-15 12:23:42 +02:00
Petr Skoda 920f4efe51 MDL-32323 improve inline docs 2012-04-10 15:27:14 +02:00
Petr Skoda b5b10866e2 MDL-32323 require at least PHPUnit 3.6.0 2012-04-10 15:27:11 +02:00
Petr Skoda 61d3013c8b MDL-32323 fix concurrent run collision caused by setup reset 2012-04-10 15:27:03 +02:00
Petr Skoda 4be2ad3660 MDL-32323 prevent concurrent execution of unit tests 2012-04-10 15:27:03 +02:00
Petr Skoda 6e2cff2d81 MDL-32323 minor phpunit related improvements and cleanup 2012-04-10 15:27:01 +02:00
Petr Skoda 7b0ff21385 MDL-32323 experimental web UI for execution of PHPUnit tests
It is not localised intentionally because only developers should use it…
2012-04-10 15:27:01 +02:00
Petr Skoda 7514f9c243 MDL-32149 allow defining of PHPUNIT_LONGTEST from /config.php and improve acceslib tests 2012-04-03 22:30:59 +02:00
Petr Skoda 728eadac78 MDL-32149 significantly faster database reset, "util.php --drop" can now be interrupted at any time 2012-04-03 22:30:54 +02:00