This commit is contained in:
2025-04-25 20:46:09 -04:00
parent 9bdecb1455
commit e84c7cf9ad
11 changed files with 2056 additions and 55 deletions

46
tests/Helpers/EnvTest.php Normal file
View File

@@ -0,0 +1,46 @@
<?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);
}
}