How to Determine if PHPUnit Tests are Running?

An alternative approach is to set a constant in the PHP section of your phpunit.xml.*:

<php>
   <const name="PHPUNIT_YOURAPPLICATION_TESTSUITE" value="true"/>
</php>

In your PHP application, you might then use the following check:

if (defined('PHPUNIT_YOURAPPLICATION_TESTSUITE') && PHPUNIT_YOURAPPLICATION_TESTSUITE)
{ 
    echo 'TestSuite running!';
}

First, we check that the constant is defined, secondly, we check the value of the constant.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)