Skip to content

Conversation

@johnkary
Copy link
Owner

This PR allows using an environment variable PHPUNIT_SPEEDTRAP to disable slowness profiling for each environment. Setting the value "disabled" will disable slowness profiling and not display the slowness report in the PHPUnit test suite output. The README contains more information.

Disable for just this run

$ PHPUNIT_SPEEDTRAP="disabled" ./vendor/bin/phpunit

Disabled by default, enable for just this run

phpunit.xml can also be configured to disable profiling by default with PHPUNIT_SPEEDTRAP="disabled". A developer can enable slowness profiling locally or one time only by setting PHPUNIT_SPEEDTRAP="enabled" using any environment variable mechanism in PHP.

Disable profiling in phpunit.xml by default

<phpunit bootstrap="vendor/autoload.php">
...
    <php>
        <env name="PHPUNIT_SPEEDTRAP" value="disabled" />
    </php>

    <listeners>
        <listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
    </listeners>
</phpunit>

Enable profiling for just this run

$ PHPUNIT_SPEEDTRAP="enabled" ./vendor/bin/phpunit

How do I set environment variables?

PHP supports many ways to set environment variables, making this a flexible feature to match any project configuration.

Some projects use vlucas/phpdotenv to manage their environment variables.

Associated Issues

Improves support for environment-based configuration, such as automated
test/build environments.
@johnkary johnkary added this to the 4.0 milestone Jan 19, 2020
@johnkary johnkary mentioned this pull request Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants