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(
|
2023-01-12 03:30:34 +00:00
|
|
|
'siteInfo',
|
2023-01-09 09:05:24 +00:00
|
|
|
'forceHTTPS',
|
|
|
|
'activeTheme',
|
2023-05-27 06:46:42 +00:00
|
|
|
'cacheMode',
|
2023-01-09 09:05:24 +00:00
|
|
|
'debug',
|
|
|
|
'baseURL'
|
|
|
|
);
|
|
|
|
|
2023-01-15 04:44:27 +00:00
|
|
|
foreach ($expectedKeys as $expectedKey) {
|
|
|
|
$this->assertArrayHasKey($expectedKey, $config, "Expected key '{$expectedKey}' not found in config array");
|
2023-01-09 09:05:24 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-17 20:38:38 +00:00
|
|
|
|
|
|
|
public function testSaveConfigFailed()
|
|
|
|
{
|
|
|
|
$Badconfig = [
|
2023-05-27 06:46:42 +00:00
|
|
|
'cacheMode' => 'none',
|
2023-01-17 20:38:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
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
|
|
|
}
|