PHP code example of oscmarb / phpunit-speedgun

1. Go to this page and download the library: Download oscmarb/phpunit-speedgun library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oscmarb / phpunit-speedgun example snippets


class SlowTestCase extends PHPUnit\Framework\TestCase
{
    /**
     * @slowThreshold 5000
     */
    public function testSlow()
    {
        // Code that takes a longer time to execute
    }
}
xml

<phpunit bootstrap="vendor/autoload.php">
    ...
    <extensions>
        <extension class="Oscmarb\SpeedGun\SpeedGunPHPUnitExtension"/>
    </extensions>
</phpunit>
xml

<phpunit bootstrap="vendor/autoload.php">
    <!-- ... other suite configuration here ... -->

    <extensions>
        <extension class="Oscmarb\SpeedGun\SpeedGunPHPUnitExtension">
            <arguments>
                <array>
                    <element key="pattern_thresholds">
                        <array>
                            <element key="(.*)Doctrine(.*)">
                                <integer>500</integer>
                            </element>
                        </array>
                    </element>
                </array>
            </arguments>
        </extension>
    </extensions>
</phpunit>
xml

<phpunit bootstrap="vendor/autoload.php">
    <php>
        <env name="PHPUNIT_SPEED_GUN" value="0"/>
    </php>

    <extensions>
        <extension class="Oscmarb\SpeedGun\SpeedGunPHPUnitExtension"/>
    </extensions>
</phpunit>