mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-09 21:43:22 +09:00
* Initial plan * Refine test naming and endpoint error assertion Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/c72c8914-fa26-41e3-8318-66a8eb660534 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>
53 lines
2.0 KiB
PHP
53 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->assertFalse($result->wasSuccessful(), 'Invalid theme action should not be successful.');
|
|
|
|
if (method_exists($result, 'getStatusCode')) {
|
|
$this->assertSame(404, $result->getStatusCode(), 'Invalid theme action should return HTTP 404.');
|
|
}
|
|
|
|
$errorMessage = $result->getErrorMessage();
|
|
$this->assertIsString($errorMessage, 'Error message should be a string.');
|
|
$this->assertNotSame('', trim($errorMessage), 'Error message should not be empty.');
|
|
$this->assertStringContainsString('non_existing_action', $errorMessage, 'Error message should reference the invalid action or endpoint.');
|
|
}
|
|
}
|