One possible solution is to set the APP_ENV environment variable directly in the phpunit.xml file using the putenv() function. Here's an example:
<phpunit>
<php>
<server name="APP_ENV" value="testing"/>
<eval><![CDATA[
putenv('APP_ENV=testing');
]]></eval>
</php>
</phpunit>
This will set the APP_ENV environment variable to "testing" both as a server variable and as a global environment variable accessible through getenv('APP_ENV'). The putenv() function call is necessary to make sure that the environment variable is also available to the PHP code running in the tests.
Note that this solution assumes that you're using PHPUnit version 6 or later, which supports the <eval> element for executing arbitrary PHP code in the test environment. If you're using an older version of PHPUnit, you may need to use a different approach.