SiteWeaver_CMS/tests/unit/Core/ConfigTest.php

41 lines
918 B
PHP
Raw Normal View History

2026-09-09 23:58:20 +00:00
<?php
declare(strict_types=1);
namespace Tests\unit\Core;
use SiteWeaver\Core\Config;
use PHPUnit\Framework\TestCase;
final class ConfigTest extends TestCase
{
public function testLoadsEnvironmentVariables(): void
{
$env = [
'APP_ENV' => 'testing',
'DB_HOST' => 'localhost',
'DEBUG' => true,
];
$config = new Config($env);
$this->assertSame('testing', $config->get('APP_ENV'));
$this->assertSame('localhost', $config->get('DB_HOST'));
$this->assertTrue($config->get('DEBUG'));
// unknown key returns null
$this->assertNull($config->get('NON_EXISTENT_KEY'));
}
public function testAllReturnsMergedArray(): void
{
$env = [
'FOO' => 'bar',
'BAZ' => 123,
];
$config = new Config($env);
$this->assertSame($env, $config->all());
}
}