PHP code example of assertwell / phpunit-global-state

1. Go to this page and download the library: Download assertwell/phpunit-global-state 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/ */

    

assertwell / phpunit-global-state example snippets




namespace Tests;

use AssertWell\PHPUnitGlobalState\EnvironmentVariables;
use PHPUnit\Framework\TestCase;

class MyTestClass extends TestCase
{
    use EnvironmentVariables;

    // Your test logic goes here.
}

define('SOME_CONSTANT', 'some value');
var_dump(SOME_CONSTANT)
#=> string(10) "some value"

// Now, re-define the constant.
runkit7_constant_redefine('SOME_CONSTANT', 'some other value');
var_dump(SOME_CONSTANT)
#=> string(16) "some other value"