AntCMS/tests/CMSTest.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

84 lines
2.2 KiB
PHP

<?php
use AntCMS\AntCMS;
use AntCMS\AntPages;
use PHPUnit\Framework\TestCase;
include_once 'Includes' . DIRECTORY_SEPARATOR . 'Include.php';
class CMSTest extends TestCase
{
public function testgetSiteInfo()
{
$siteInfo = AntCMS::getSiteInfo();
$this->assertIsArray($siteInfo);
$this->assertArrayHasKey('siteTitle', $siteInfo);
$this->assertEquals('AntCMS', $siteInfo['siteTitle']);
}
public function testRenderPage()
{
AntPages::generatePages();
$antCMS = new AntCMS;
$pagePath = '/index.md';
$result = $antCMS->renderPage($pagePath);
$this->assertNotEmpty($result);
$this->assertIsString($result);
}
public function testGetPageLayout()
{
//We need to generate the Pages.yaml file so that the nav list can be generated.
AntPages::generatePages();
$antCMS = new AntCMS;
$pageLayout = $antCMS->getPageLayout();
$this->assertNotEmpty($pageLayout);
$this->assertIsString($pageLayout);
}
public function testGetPage()
{
$antCMS = new AntCMS;
$result = $antCMS->getPage('/index.md');
$this->assertNotEmpty($result);
$this->assertIsArray($result);
$this->assertArrayHasKey('content', $result);
$this->assertArrayHasKey('title', $result);
$this->assertArrayHasKey('author', $result);
$this->assertArrayHasKey('description', $result);
$this->assertArrayHasKey('keywords', $result);
}
public function testGetPageFailed()
{
$antCMS = new AntCMS;
$result = $antCMS->getPage('/thisdoesnotexist.md');
$this->assertEquals(false, $result);
$this->assertIsBool($result);
}
public function testGetThemeTemplate()
{
$antCMS = new AntCMS;
$result = $antCMS->getThemeTemplate();
$this->assertNotEmpty($result);
$this->assertIsString($result);
}
public function testGetThemeTemplateFallback()
{
$antCMS = new AntCMS;
$result = $antCMS->getThemeTemplate('atemplatethatjusdoesntexist');
$this->assertNotEmpty($result);
$this->assertIsString($result);
}
}