41 lines
918 B
PHP
41 lines
918 B
PHP
<?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());
|
|
}
|
|
}
|