mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
883ce42127
Also deprecated the following functions - 1. message_move_userfrom_unread2read - It is not necessary for us to mark a message as read on user deletion. 2. message_get_blocked_users - Horrible logic used to determine if a user is blocked via reference on some randomly chosen 'isblocked' variable. 3. message_get_contacts - The same as above. This can be done in a much nicer way. 4. message_mark_message_read - We want two functions to do this to avoid confusing messages and notifications. 5. message_can_delete_message - This assumed the variable $message contained the 'useridto' property, which was present in the old table structure. We do not want future usages where a query is done on the new table and is simply passed as this won't contain this property. 6. message_delete_message - Same as above.
PHPUnit testing support in Moodle
Documentation
Composer installation
Composer is a dependency manager for PHP projects. It installs PHP libraries into /vendor/ subdirectory inside your moodle dirroot.
- install Composer - http://getcomposer.org/doc/00-intro.md
- install PHUnit and dependencies - go to your Moodle dirroot and execute
php composer.phar install
Configure your server
You need to create a new dataroot directory and specify a separate database prefix for the test environment, see config-dist.php for more information.
- add
$CFG->phpunit_prefix = 'phpu_';
to your config.php file - and
$CFG->phpunit_dataroot = '/path/to/phpunitdataroot';
to your config.php file
Initialise the test environment
Before first execution and after every upgrade the PHPUnit test environment needs to be initialised, this command also builds the phpunit.xml configuration files.
- execute
php admin/tool/phpunit/cli/init.php
Execute tests
- execute
vendor/bin/phpunit
from dirroot directory - you can execute a single test case class using class name followed by path to test file
vendor/bin/phpunit core_phpunit_basic_testcase lib/tests/phpunit_test.php
- it is also possible to create custom configuration files in xml format and use
vendor/bin/phpunit -c mytestsuites.xml
How to add more tests?
- create
tests/
directory in your add-on - add test file, for example
local/mytest/tests/my_test.php
file withlocal_my_testcase
class that extendsbasic_testcase
oradvanced_testcase
- add some test_*() methods
- execute your new test case
vendor/bin/phpunit local_my_testcase local/mytest/tests/my_test.php
- execute
php admin/tool/phpunit/cli/init.php
to get the plugin tests included in main phpunit.xml configuration file
Windows support
- use
\
instead of/
in paths in examples above