Common unit test problems

Jump to: navigation, search

General Issues

Segfaults on Oracle

When I was running tests on oracle I was getting phpunit sefaulting.. --Dan Poltawski 00:29, 16 May 2012 (WST)

Solution Set statement_cache_size in php.ini:
oci8.statement_cache_size = 0

(More info: PHP Bug #49803).

Execution ends with "zend_mm_heap corrupted" error

This was happening with a standard XAMPP stack, running Moodle against Oracle.

  1. Verify that you are not using multiple PHP opcode accelerators together (APC, Opcode...). Also try disabling all them (they really don't help much in a phpunit execution).
  2. Set output_buffering in php.ini to 65536 (from default 4096).

Many random errors about "Warning: rmdir dataroot/cache/.../.... Directory not empty"

Use a different $CFG->phpunit_dataroot , completely apart from your current [LXMW]AMP stack, for example in windows 'C:\\Windows\\Temp\\dataroot'. For some reason, unknown at the time of writing this, using any directory within the [LXMW]AMP stack lead to randomly busy/locked (aka, non deletable) files.

Specific failures


Unique index is accent insensitive, this may cause problems for non-ascii languages. This is usually caused by accent insensitive default collation.

Solution Use the utf8mb4_bin collation on your database for unit tests on MySQL/MariaDB


SQL operator "=" is expected to be case sensitive Failed asserting that 1 matches expected 2.

Solution Use the utf8mb4_bin collation on your database for unit tests on MySQL/MariaDB


A test using UTF-8 characters has failed. Consider updating PHP and PHP's PCRE or INTL extensions (MDL-30494) Failed asserting that false is true.

Solution Use the utf8mb4_bin collation on your database for unit tests on MySQL/MariaDB


Failed to load the sample RSS file. Please check your proxy settings in Moodle. %s

Solution Your moodle needs network connectivity, please check proxy settings.


Failed asserting that 'cURL Error: Operation timed out after 2000 milliseconds with 0 bytes received' is null.

Solution Your moodle needs network connectivity, please check proxy settings


Collation aware sorting not supported, PHP extension "intl" is not available.

Solution Install php intl extension.

Note that, on Windows, this extension does not seem to be included in the installer, but you can get it by downloading the zip, and copying the right DLLs across. If you Google, there are more detailed instructions on Stack Exchange.


Failed asserting that false is identical to 'aaabbb'.

Solution This problem indicates buggy iconv. See [1] for discussion. So this is a real problem, to be fixed in a future integration cycle


Failed asserting that false is an instance of class "stored_file".

Solution Unfortunately, the php GD extension is a requirement for this test (see MDL-36447).

Go to your Moodle directory and type
php admin/tool/phpunit/cli/util.php --drop
, then reinitialise PHPunit and run the test again.


Row size limit reached in MySQL using InnoDB, configure server to use innodb_file_format=Barracuda and innodb_file_per_table=1

""Solution"" default InnoDB database tables in MySQL cannot handle more than 10 text columns, so innodb file format should be Barracuda (see MDL-46971)

php admin/cli/mysql_compressed_rows.php
will solve the problem.


Failed asserting that two strings are identical. Since 2.9, en_AU.UTF-8 locale is required to run phpunit.

Solution Install the AU locale on your server if you want to run phpunit. Here are sample commands for installing the en_AU locale:

  • Debian/Centos: "sudo localedef -v -c -i en_AU -f UTF-8 en_AU.UTF-8"
  • Ubuntu: "sudo locale-gen en_AU.UTF-8"


Failed asserting that an array has the key 'addplugintest'.

Solution Set opcache.enable_cli = 0

MSSQL failures with core_course_externallib_testcase

On the MSSQL database driver, some problems occur with core_course_externallib_testcase, for example:


unserialize(): Error at offset 24191 of 24192 bytes

Solution Ensure that the correct configuration is set in freedts.conf (from, e.g.

text size = 20971520
client charset = UTF8

PHP Warning: include_once(PHPUnit/Extensions/Database/Autoload.php): failed to open stream

This occurs on Mac installs from experience. The reason this occurs is because DBUnit was not installed during the PHPUnit installation via PEAR.

Solution In terminal type:
sudo pear install -f phpunit/DbUnit

!!! Error reading from database !!!!! Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.

If running unit tests under FreeTDS, remember that without a valid FREETDS environment variable, PHP won't be able to find the freetds.conf file and will default to version 5.0 which has poor support for unicode collations.

Solution Ensure a FREETDS environment variable is set prior to running the automated tests, which points to a valid path that contains a freetds.conf file. Also ensure the tds version element is set to a recent enough version (8.0)

Solution2 Under windows you can put the freetds.conf file in the disk root directory where php is being executed (for example C:\freetds.conf). That directory is always looked. Also ensure the tds version element is set to a recent enough version (8.0)

Note: Another potential solution may be to set TDSVER (

Errors running unit tests against Oracle, related with locales, decimal points and friends

Surely your PHP CLI (the one executing phpunit) is not aware of the expected Oracle NLS configuration. To enforce it, set at least these 2 env variables in your system (globally or for the current user):


The test file "evolution.test" should not contain section named "[lots of content]"

Likely that you've got git setting autocrlf set to true and its altered the line endings. Set autocrlf to false in your git config and reset your checkout following this guide.