PHPUNIT Sensitive to notice & warning

By default, PHPUnit converts PHP errors, warnings, and notices that are triggered during the execution of a test to an exception.

See Testing PHP Errors which has more information how to test for your warnings (and how to ignore warnings in sub-routines you call in tests).

To disable the default behaviour, you can tell PHPUnit to do so in your tests, e.g. within the setUpof your test or the test itself by setting a static variable in the global namespace:

# Warning:
PHPUnit_Framework_Error_Warning::$enabled = FALSE;

# notice, strict:
PHPUnit_Framework_Error_Notice::$enabled = FALSE;

Another option to change the default behaviour is to configure the testrunner with an XML file with the following settings:

<phpunit convertErrorsToExceptions="false"
         convertNoticesToExceptions="false"
         convertWarningsToExceptions="false">
</phpunit>

These three options are not available as command-line switches.

Latest Post

Popular Post

Our Skills

Author

Project Director Information Architect Database Administrator Unix Administrator Senior Developer Project Manager Product Manager Web Marketer Cloud Engineer

Contact Us

For any questions or project ideas please contact me at the following.

I'm here