You've already forked Traefik-Redis-Api
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Siteworxpro\Tests\Helpers;
|
|
|
|
use Siteworxpro\App\Helpers\Env;
|
|
use Siteworxpro\Tests\Unit;
|
|
|
|
class EnvTest extends Unit
|
|
{
|
|
public function testGetReturnsStringByDefault(): void
|
|
{
|
|
putenv('TEST_KEY=example');
|
|
$result = Env::get('TEST_KEY');
|
|
$this->assertSame('example', $result);
|
|
}
|
|
|
|
public function testGetReturnsDefaultIfKeyNotSet(): void
|
|
{
|
|
putenv('TEST_KEY'); // Unset the environment variable
|
|
$result = Env::get('TEST_KEY', 'default_value');
|
|
$this->assertSame('default_value', $result);
|
|
}
|
|
|
|
public function testGetCastsToBoolean(): void
|
|
{
|
|
putenv('TEST_KEY=true');
|
|
$result = Env::get('TEST_KEY', null, 'bool');
|
|
$this->assertTrue($result);
|
|
}
|
|
|
|
public function testGetCastsToInteger(): void
|
|
{
|
|
putenv('TEST_KEY=123');
|
|
$result = Env::get('TEST_KEY', null, 'int');
|
|
$this->assertSame(123, $result);
|
|
}
|
|
|
|
public function testGetCastsToFloat(): void
|
|
{
|
|
putenv('TEST_KEY=123.45');
|
|
$result = Env::get('TEST_KEY', null, 'float');
|
|
$this->assertSame(123.45, $result);
|
|
}
|
|
}
|