41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Phred\Tests;
|
|
|
|
use Phred\Support\Config;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class ConfigTest extends TestCase
|
|
{
|
|
protected function tearDown(): void
|
|
{
|
|
// Clean up env changes
|
|
putenv('APP_ENV');
|
|
unset($_ENV['APP_ENV'], $_SERVER['APP_ENV']);
|
|
putenv('APP_DEBUG');
|
|
unset($_ENV['APP_DEBUG'], $_SERVER['APP_DEBUG']);
|
|
putenv('API_FORMAT');
|
|
unset($_ENV['API_FORMAT'], $_SERVER['API_FORMAT']);
|
|
}
|
|
|
|
public function testEnvOverridesConfigFile(): void
|
|
{
|
|
// config/app.php sets 'env' => 'local' by default; ensure ENV wins
|
|
putenv('APP_ENV=production');
|
|
$this->assertSame('production', Config::get('APP_ENV'));
|
|
$this->assertSame('production', Config::get('app.env'));
|
|
}
|
|
|
|
public function testReadsFromConfigFileWhenEnvMissing(): void
|
|
{
|
|
// From config/app.php
|
|
$this->assertSame('UTC', Config::get('app.timezone'));
|
|
}
|
|
|
|
public function testReturnsDefaultWhenNotFound(): void
|
|
{
|
|
$this->assertSame('fallback', Config::get('nonexistent.key', 'fallback'));
|
|
}
|
|
}
|