AntCMS/tests/ConfigTest.php
Belle Aerni 38e51166c3
Implemented APCu caching (#44)
* Start implementing APCu caching

* Fix tests

* Now make PHPStan happy :)

* Fix tests

* Also enable the APCu extension in the tests

* Set maxlife to 7 days & clear with cron

* Implement a more correct way to clear the cache

* Also mention the APCu caching in the readme
2023-05-26 23:46:42 -07:00

55 lines
1.2 KiB
PHP

<?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',
'forceHTTPS',
'activeTheme',
'cacheMode',
'debug',
'baseURL'
);
foreach ($expectedKeys as $expectedKey) {
$this->assertArrayHasKey($expectedKey, $config, "Expected key '{$expectedKey}' not found in config array");
}
}
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);
}
}