AntCMS/tests/ConfigTest.php
Belle Aerni 23e8b18ba3
Implemented multi-user support (#27)
* Implemented rudimentary multi-user support

* Delete src.zip

* Improve the update user function

And added a new function to the auth module to invalidate a session

* Update AntAuth.php

* Rename the configs, a bit more auth stuff

* Fix test and JS regex

* Turn the admin landing page into a twig template

* plugin/admin/ -> admin/

* Refactored templating for plugins

Plus. I finally converted the remaining options in the admin plugin to twig templates. No extra styling, but it'll be easier now

* Fix PHPStan warnings

* Basic "first time" user setup

* Improved styling

* Started implementing user management

* Completed user management in the admin panel

* Renamed templates, added support for sub-dirs

* Limit and validate allowed chars for usernames

* Finished the basics of the profile plugin

* Styling for the bootstrap theme

* Some more final touches

* Added an example to show author

* Tweak to the readme
2023-03-07 02:09:32 -08: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',
'enableCache',
'debug',
'baseURL'
);
foreach ($expectedKeys as $expectedKey) {
$this->assertArrayHasKey($expectedKey, $config, "Expected key '{$expectedKey}' not found in config array");
}
}
public function testSaveConfigFailed()
{
$Badconfig = [
'enableCache' => true,
];
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);
}
}