phpunit-globals icon indicating copy to clipboard operation
phpunit-globals copied to clipboard

Add support for attributes

Open jakzal opened this issue 3 years ago • 0 comments

#[Env('FOO', 'bar')]
class ExampleTest extends TestCase
{
    #[
        Env('APP_ENV', 'foo'),
        Env('APP_DEBUG', '0'),
        Server('APP_ENV', 'bar'),
        Server('APP_DEBUG', '1')],
        PutEnv('APP_HOST', 'localhost')
    ]
    public function test_global_variables()
    {
        $this->assertSame('bar', $_ENV['FOO']);
        $this->assertSame('foo', $_ENV['APP_ENV']);
        $this->assertSame('0', $_ENV['APP_DEBUG']);
        $this->assertSame('bar', $_SERVER['APP_ENV']);
        $this->assertSame('1', $_SERVER['APP_DEBUG']);
        $this->assertSame('localhost', \getenv('APP_HOST'));
    }
}

jakzal avatar Feb 02 '22 11:02 jakzal