61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Scape\Tests;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Scape\Config;
|
|
|
|
class ConfigTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
// Clear environment variables before each test
|
|
putenv('SCAPE_TEMPLATES_DIR');
|
|
putenv('SCAPE_LAYOUTS_DIR');
|
|
putenv('SCAPE_PARTIALS_DIR');
|
|
putenv('SCAPE_FILTERS_DIR');
|
|
putenv('SCAPE_MODE');
|
|
}
|
|
|
|
public function testDefaultValues(): void
|
|
{
|
|
$config = new Config();
|
|
|
|
$this->assertEquals('production', $config->getMode());
|
|
$this->assertEquals('./templates', $config->getTemplatesDir());
|
|
$this->assertEquals('./templates/layouts', $config->getLayoutsDir());
|
|
$this->assertEquals('./templates/partials', $config->getPartialsDir());
|
|
$this->assertEquals('./filters', $config->getFiltersDir());
|
|
$this->assertEquals('./.scape/cache', $config->getCacheDir());
|
|
}
|
|
|
|
public function testEnvironmentVariableOverrides(): void
|
|
{
|
|
putenv('SCAPE_MODE=debug');
|
|
putenv('SCAPE_TEMPLATES_DIR=/tmp/templates');
|
|
|
|
$config = new Config();
|
|
|
|
$this->assertEquals('debug', $config->getMode());
|
|
$this->assertEquals('/tmp/templates', $config->getTemplatesDir());
|
|
// Layouts/Partials should still fall back relative to templates if not set?
|
|
// Or remain as defaults? Let's check spec.
|
|
// Spec says they are managed via env vars. We'll assume they have independent defaults.
|
|
}
|
|
|
|
public function testProgrammaticOverridesPrecedence(): void
|
|
{
|
|
putenv('SCAPE_MODE=debug');
|
|
|
|
$config = new Config([
|
|
'mode' => 'production',
|
|
'templates_dir' => '/custom/path'
|
|
]);
|
|
|
|
$this->assertEquals('production', $config->getMode());
|
|
$this->assertEquals('/custom/path', $config->getTemplatesDir());
|
|
}
|
|
}
|