Files
FOSSBilling/tests/Modules/System/SystemAdminTest.php
T
Belle Aerni b061d5da04 Implemented a new class for config management (#2066)
* Implemented a new class for config management

* Run Rector & PHP-CS-Fixer

* Spelling

* Pointed a bunch of code to the new class

* Fix tests, removed 2 broken ones that did nothing

* Quick run of PHP-CS-Fixer

* Fixed issues noticed in self review

* Updated remaining old methods. Fixed minor error page issue

* Very minor code tweak

* Fixes, added a related test

* Check for OPCache functions being defined

* I don't think this timeout is needed
2024-01-15 14:12:53 -08:00

42 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
use APIHelper\Request;
use PHPUnit\Framework\TestCase;
final class SystemAdminTest extends TestCase
{
public function testClearCache(): void
{
// Clear the cache
$response = Request::makeRequest('admin/system/clear_cache');
$this->assertTrue($response->wasSuccessful(), $response->generatePHPUnitMessage());
$this->assertIsBool($response->getResult());
}
public function testErrorReportingToggle(): void
{
// Get the starting value
$before = Request::makeRequest('admin/system/error_reporting_enabled')->getResult();
$this->assertIsBool($before);
// Toggle the option
$response = Request::makeRequest('admin/system/toggle_error_reporting');
$this->assertTrue($response->wasSuccessful(), $response->generatePHPUnitMessage());
$this->assertTrue($response->getResult());
// Check that it was correctly switched
$after = Request::makeRequest('admin/system/error_reporting_enabled')->getResult();
$this->assertIsBool($after);
$this->assertNotEquals($after, $before);
// Ensure we don't leave error reporting on (it shouldn't report anyways, but this is best practice)
if ($after) {
$response = Request::makeRequest('admin/system/toggle_error_reporting');
$this->assertTrue($response->wasSuccessful(), $response->generatePHPUnitMessage());
$this->assertTrue($response->getResult());
}
}
}