Files
FOSSBilling/tests/Unit/Server/Manager/DirectadminTest.php
T
137a10dbf3 Apply autofixes and update CODEOWNERS for code quality (#3959)
* Apply suggested fix to tests/Unit/FOSSBilling/RateLimiterTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/RateLimiterTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/library/Server/Manager/Directadmin.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to tests/Unit/FOSSBilling/Api/AbstractApiTest.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Remove tests path from CODEOWNERS

* Apply suggested fix to src/modules/Order/Service.php from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Fix uncancel emails and zero-credit payments

* Preserve orders when invoice generation fails

* Fix RateLimiterTest CI failures from prior autofix commits

- Add a public RateLimiter::getStatus() so tests can read the token
  limit for a policy without hardcoding it (getRateLimitState() now
  reuses it).
- Fix consumeOrThrow test's toThrow() call: Pest expects the assertion
  closure as the first argument (with the exception type-hinted), not
  as a second argument alongside the class string.

* Fix DirectAdmin apostrophe entity decoding to avoid trailing semicolon

str_replace('&#39', "'", $data) also matched the fully-terminated
&#39; entity, replacing just the &#39 part and leaving the semicolon
behind (e.g. "O&#39;Brien" became "O';Brien"). Replace the terminated
form first, then the legacy unterminated form, so both decode to a
plain apostrophe.

* Fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-11 16:20:59 +01:00

32 lines
974 B
PHP

<?php
declare(strict_types=1);
function invokeDirectadminParseResponse(Server_Manager_Directadmin $manager, string $data): array
{
$reflection = new ReflectionClass($manager);
$method = $reflection->getMethod('parseResponse');
return $method->invokeArgs($manager, [$data]);
}
beforeEach(function (): void {
$this->manager = new Server_Manager_Directadmin([
'host' => 'directadmin.example.com',
'username' => 'admin',
'password' => 'secret',
]);
});
test('parseResponse decodes the fully-terminated apostrophe entity without a trailing semicolon', function (): void {
$result = invokeDirectadminParseResponse($this->manager, 'name=O&#39;Brien');
expect($result['name'])->toBe("O'Brien");
});
test('parseResponse decodes the legacy unterminated apostrophe entity', function (): void {
$result = invokeDirectadminParseResponse($this->manager, 'name=O&#39Brien');
expect($result['name'])->toBe("O'Brien");
});