mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 20:27:07 +09:00
* Initial plan * fix: harden index URL handling and relax brittle theme API error assertions Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/1a498284-9424-42d6-8e7f-dfe061a51478 Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * chore: address review nits in index and theme admin test Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/1a498284-9424-42d6-8e7f-dfe061a51478 Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * fix: keep url fallback type-safe when parse_url fails Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/1a498284-9424-42d6-8e7f-dfe061a51478 Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * test: clarify 740 error code reference in theme admin test Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/1a498284-9424-42d6-8e7f-dfe061a51478 Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * fix: add explicit null fallback for parsed request path Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/1a498284-9424-42d6-8e7f-dfe061a51478 Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>
52 lines
2.0 KiB
PHP
52 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ThemeTests;
|
|
|
|
use APIHelper\Request;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class AdminTest extends TestCase
|
|
{
|
|
public function testGetCurrentClientTheme(): void
|
|
{
|
|
$result = Request::makeRequest('admin/theme/get_current');
|
|
$this->assertTrue($result->wasSuccessful(), $result->generatePHPUnitMessage());
|
|
$data = $result->getResult();
|
|
$this->assertIsArray($data);
|
|
|
|
$this->assertArrayHasKey('name', $data);
|
|
$this->assertArrayHasKey('version', $data);
|
|
$this->assertArrayHasKey('author', $data);
|
|
$this->assertEquals('FOSSBilling', $data['author']);
|
|
}
|
|
|
|
public function testGetCurrentAdminTheme(): void
|
|
{
|
|
$result = Request::makeRequest('admin/theme/get_current', ['client' => false]);
|
|
$this->assertTrue($result->wasSuccessful(), $result->generatePHPUnitMessage());
|
|
$data = $result->getResult();
|
|
$this->assertIsArray($data);
|
|
|
|
$this->assertArrayHasKey('name', $data);
|
|
$this->assertArrayHasKey('version', $data);
|
|
$this->assertArrayHasKey('author', $data);
|
|
$this->assertEquals('FOSSBilling', $data['author']);
|
|
}
|
|
|
|
public function testInvalidThemeActionReturnsError(): void
|
|
{
|
|
$result = Request::makeRequest('admin/theme/non_existing_action');
|
|
$this->assertSame(404, $result->getStatusCode(), 'Invalid theme action should return HTTP 404.');
|
|
$this->assertFalse($result->wasSuccessful(), 'Invalid theme action should not be successful.');
|
|
// API not-found actions/endpoints are mapped to error code 740 (see src/library/Api/Handler.php).
|
|
$expectedNotFoundErrorCode = 740;
|
|
$this->assertSame($expectedNotFoundErrorCode, $result->getErrorCode(), 'Invalid theme action should return the API not-found error code.');
|
|
|
|
$errorMessage = $result->getErrorMessage();
|
|
$this->assertIsString($errorMessage, 'Error message should be a string.');
|
|
$this->assertNotSame('', trim($errorMessage), 'Error message should not be empty.');
|
|
}
|
|
}
|