Problem/Motivation

PHPUnit tests can fail based on the php.ini settings on different environments. E.g. Memory limit

Proposed resolution

We can set memory limits and error reporting levels in the phpunit.xml.dist configuration file so that tests will always run correctly of different environments like this:

<php>
  <ini name="error_reporting" value="32767"/>
  <ini name="memory_limit" value="-1"/>
</php>

Remaining tasks

Discuss what the correct php ini settings should be and add them phpunit.xml.dist

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davidgrayston’s picture

FileSize
473 bytes
dawehner’s picture

Status: Active » Needs review

Should we maybe document what 32767 means? +1 to set memory limit to -1. We already hit the 100MB limit.

Cameron Tod’s picture

FileSize
584 bytes

I think we should! Comments added.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

So I think this change makes sense.

Looking at the PHPUnit error handler code

    public static function handleError($errno, $errstr, $errfile, $errline)
    {
        if (!($errno & error_reporting())) {
            return FALSE;
        }
//...

This will return FALSE if your PHP is configured with error_reporting = E_ALL & ~E_NOTICE and the error number is for a E_NOTICE. Therefore even though PHPUnit is configured with

         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"

by default (http://phpunit.de/manual/3.7/en/appendixes.configuration.html) this actually does not occur.

Setting the error_reporting value in PHPUnit config is a simple fix.

dawehner’s picture

Oh cool, E_STRICT is now part of E_ALL.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.