-
Notifications
You must be signed in to change notification settings - Fork 1
Install and Testing Environment
The following documentation was followed during the install process: https://docs.moodle.org/39/en/Step-by-step_Installation_Guide_for_Ubuntu#Step_2:_Install_Apache.2FMySQL.2FPHP
This text describes the steps we took to configure the Moodle testing environment. The official documentation can be found at the link below.
Official Moodle Documentation: https://docs.moodle.org/dev/PHPUnit
https://getcomposer.org/download/
Composer was installed using the followng commands in the moodle directory:
Note: must be root
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '795f976fe0ebd8b75f26a6dd68f78fd3453ce79f32ecb33e7fd087d39bfeb978342fb73ac986cd4f54edd0dc902601dc') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar install
Create dedicated dataroot
mkdir ../phpu_moodledata
chown www-data phpu_moodledata
chmod 755 phpu_moodledata
Add dedicated dataroot in config.php
In section 9 edit the following lines:
$CFG->phpunit_prefix = 'phpu_';
$CFG->phpunit_dataroot = '/home/example/phpu_moodledata';
Initialize
php admin/tool/phpunit/cli/init.php
From moodle dir run:
vendor/bin/phpunit
Keys for all tests output:
.
- Printed when the test succeeds.
F
- Printed when an assertion fails while running the test method.
E
- Printed when an error occurs while running the test method.
R
- Printed when the test has been marked as risky.
S
- Printed when the test has been skipped.
I
- Printed when the test is marked as being incomplete or not yet implemented.
see more on test outputs
- One Test
vendor/bin/phpunit my/test/filename.php
- Single Method
vendor/bin/phpunit --filter test_function_name path/to/file.php
- Grouped Tests
vendor/bin/phpunit --filter test_flag_user
Note: Tests are flagged with the following file annotation
/**
* Unit tests for {@link stack_cas_keyval}.
* @group qtype_stack
*/
class qtype_stack_cas_keyval_exception_testcase extends basic_testcase {
Tests of this group would be run with: phpunit --group qtype_stack