mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-09 05:24:58 +09:00
* Bump Dockerfile syntax to 1.18 * Add getStatusCode to Response and update test * Expect error code 740 for invalid theme action * Use Docker-based CI/test image and live test script * Add PHP 8.5 to CI matrix * Add Buildx caching and optimize Docker build * Add CI timeouts, quoting fixes, and release tree build * Add concurrency, caching, and cleanup to CI * Grant permissions for preview-build job * Map error code 740 to HTTP 404 and update test * Update cache-scope names in GitHub workflows * Remove redundant status guard in theme admin test Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/b20f484f-0aaa-4afc-ae43-adb264bb05aa Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * Grant cache export permissions to CI build job Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/a088c94f-a176-40fb-9e0b-ee3cac2aeb5b Co-authored-by: admdly <2807620+admdly@users.noreply.github.com> * Disable cache for release artifact build * Fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@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> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
52 lines
2.1 KiB
PHP
52 lines
2.1 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.');
|
|
$this->assertSame(740, $result->getErrorCode(), 'Invalid theme action should return error code 740.');
|
|
|
|
$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.');
|
|
$this->assertStringContainsString('does not exist', $errorMessage, 'Invalid theme action should report a missing endpoint/action.');
|
|
}
|
|
}
|