As Juhana commented you should first of all fix your code where the warning(s) appear. It's a sign that the code is not working properly / strictly.
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 setUp
of 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.
See as well the related question: test the return value of a method that triggers an error with PHPUnit.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…