Files
FOSSBilling/tests/Modules/Extension/GuestTest.php
T
Copilotandadmdly 0c9a5fe6a7 Refactor test doubles, fix cron admin mock inconsistency, and add missing coverage (#3486)
* Initial plan

* Refactor test helpers: extract named doubles, fix mock inconsistencies, add return types and negative test cases

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/e732bafd-6bd7-40c6-b976-f13240612867

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix CI failures: use named class instead of addMethods(), fix checkInvoiceAuth assertion

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/c519e2d3-203c-4eba-962a-547a5f1ddfe0

Co-authored-by: admdly <2807620+admdly@users.noreply.github.com>

* Fix testTryTokenLoginRejectsCronAdminToken: give dbAdmin and cronAdmin the same ID so the ID-match check throws the expected exception

Agent-Logs-Url: https://github.com/FOSSBilling/FOSSBilling/sessions/ae7acf19-c6bf-43c4-abaf-d50a321d69b3

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>
2026-05-06 14:59:18 +01:00

40 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace ExtensionTests;
use APIHelper\Request;
use PHPUnit\Framework\TestCase;
final class GuestTest extends TestCase
{
public function testSettings(): void
{
$result = Request::makeRequest('guest/extension/settings', ['ext' => 'index']);
$this->assertTrue($result->wasSuccessful(), $result->generatePHPUnitMessage());
$this->assertIsArray($result->getResult());
}
public function testSettingsMissingExt(): void
{
$result = Request::makeRequest('guest/extension/settings', ['ext' => '']);
$this->assertFalse($result->wasSuccessful(), $result->generatePHPUnitMessage());
$this->assertEquals('Parameter ext is missing', $result->getErrorMessage());
}
public function testExtensionIsActive(): void
{
$result = Request::makeRequest('guest/extension/is_on', ['mod' => 'index']);
$this->assertTrue($result->wasSuccessful(), $result->generatePHPUnitMessage());
$this->assertTrue($result->getResult());
}
public function testExtensionIsNotActive(): void
{
$result = Request::makeRequest('guest/extension/is_on', ['mod' => 'serviceapikey']);
$this->assertTrue($result->wasSuccessful(), $result->generatePHPUnitMessage());
$this->assertFalse($result->getResult());
}
}