AntCMS/tests/ConfigTest.php

56 lines
1.2 KiB
PHP
Raw Normal View History

2023-01-09 09:05:24 +00:00
<?php
use AntCMS\AntConfig;
use PHPUnit\Framework\TestCase;
include_once 'Includes' . DIRECTORY_SEPARATOR . 'Include.php';
class ConfigTest extends TestCase
{
public function testGetConfig()
{
$config = AntConfig::currentConfig();
$expectedKeys = array(
'siteInfo',
2023-01-09 09:05:24 +00:00
'forceHTTPS',
'activeTheme',
'cacheMode',
2023-01-09 09:05:24 +00:00
'debug',
'baseURL'
);
foreach ($expectedKeys as $expectedKey) {
$this->assertArrayHasKey($expectedKey, $config, "Expected key '{$expectedKey}' not found in config array");
2023-01-09 09:05:24 +00:00
}
}
public function testSaveConfigFailed()
{
$Badconfig = [
'cacheMode' => 'none',
];
try {
$result = AntConfig::saveConfig($Badconfig);
} catch (Exception $exception) {
$result = $exception;
}
$this->assertNotTrue($result);
}
public function testSaveConfigPassed()
{
$currentConfig = AntConfig::currentConfig();
try {
$result = AntConfig::saveConfig($currentConfig);
} catch (Exception $exception) {
$result = $exception;
}
$this->assertTrue($result);
}
2023-01-09 09:05:24 +00:00
}