mirror of
https://github.com/moodle/moodle.git
synced 2025-06-11 02:21:20 +02:00
admin
analytics
auth
availability
backup
badges
blocks
blog
cache
calendar
cohort
comment
competency
completion
course
dataformat
enrol
error
favourites
files
filter
grade
group
install
iplookup
lang
lib
adodb
ajax
amd
antivirus
behat
bennu
classes
db
ddl
dml
dtl
editor
evalmath
external
filebrowser
filestorage
fonts
form
geopattern-php
google
grade
horde
html2text
htmlpurifier
jabber
jquery
lessphp
ltiprovider
markdown
maxmind
minify
mlbackend
mustache
pear
php-css-parser
phpexcel
phpmailer
phpunit
classes
tests
bootstrap.php
bootstraplib.php
lib.php
phpunit.xsd
readme.md
portfolio
requirejs
rtlcss
scssphp
simplepie
spout
tcpdf
templates
testing
tests
typo3
userkey
xhprof
xmldb
yui
yuilib
accesslib.php
adminlib.php
authlib.php
badgeslib.php
blocklib.php
boxlib.php
cacert.pem
cacert.txt
clilib.php
completionlib.php
componentlib.class.php
conditionlib.php
configonlylib.php
cookies.js
coursecatlib.php
cronlib.php
csslib.php
csvlib.class.php
customcheckslib.php
dataformatlib.php
datalib.php
ddllib.php
default.ttf
deprecatedlib.php
dmllib.php
dtllib.php
editorlib.php
emptyfile.php
enrollib.php
environmentlib.php
excellib.class.php
externallib.php
filelib.php
filterlib.php
flickrclient.php
flickrlib.php
formslib.php
gdlib.php
googleapi.php
gradelib.php
graphlib.php
grouplib.php
index.html
installlib.php
javascript-static.js
javascript.php
jslib.php
ldaplib.php
lexer.php
licenselib.php
listlib.php
mathslib.php
messagelib.php
modinfolib.php
moodlelib.php
myprofilelib.php
navigationlib.php
oauthlib.php
odslib.class.php
outputactions.php
outputcomponents.php
outputfactories.php
outputfragmentrequirementslib.php
outputlib.php
outputrenderers.php
outputrequirementslib.php
pagelib.php
pdflib.php
phpminimumversionlib.php
plagiarismlib.php
portfoliolib.php
questionlib.php
recaptchalib.php
recaptchalib_v2.php
requirejs.php
resourcelib.php
rsslib.php
searchlib.php
sessionkeepalive_ajax.php
sessionlib.php
setup.php
setuplib.php
soaplib.php
statslib.php
tablelib.php
thirdpartylibs.xml
tokeniserlib.php
upgrade.txt
upgradelib.php
uploadlib.php
validateurlsyntax.php
webdavlib.php
weblib.php
wiki_to_markdown.php
womenslib.php
wordlist.txt
xhtml.xsl
xmlize.php
xsendfilelib.php
local
login
media
message
mnet
mod
my
notes
pix
plagiarism
portfolio
privacy
question
rating
report
repository
rss
search
tag
theme
user
userpix
webservice
.eslintignore
.eslintrc
.gherkin-lintrc
.gitattributes
.gitignore
.jshintrc
.shifter.json
.stylelintignore
.stylelintrc
.travis.yml
CONTRIBUTING.txt
COPYING.txt
Gruntfile.js
INSTALL.txt
PULL_REQUEST_TEMPLATE.txt
README.txt
TRADEMARK.txt
behat.yml.dist
brokenfile.php
composer.json
composer.lock
config-dist.php
draftfile.php
file.php
help.php
help_ajax.php
index.php
install.php
npm-shrinkwrap.json
package.json
phpunit.xml.dist
pluginfile.php
tokenpluginfile.php
version.php
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