Apply suggested fixes from Copilot Autofix across multiple files (#3896)

* Apply suggested fix to src/modules/Invoice/tests/Unit/ServiceTest.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/modules/Invoice/tests/Unit/ServiceTest.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/modules/Massmailer/Service.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/modules/Staff/tests/Unit/Api/AdminTest.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/ResponseFactoryTest.php from Copilot Autofix

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

* Fix file/download response content disposition

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This commit is contained in:
Adam DaleyandCopilot Autofix powered by AI authored and GitHub committed 2026-07-05 02:32:47 +01:00
1 parent e57dee4f5c
commit 9b35d576d7
5 files changed
+40 -12

No files matched your search

@@ -14,6 +14,7 @@ namespace FOSSBilling\Http;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
final readonly class ResponseFactory
{
@@ -51,7 +52,7 @@ final readonly class ResponseFactory
{
$response = new BinaryFileResponse($path);
$response->headers->set('Content-Type', $contentType);
$response->setContentDisposition('attachment', $filename);
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $filename);
return $response;
}
@@ -59,6 +60,7 @@ final readonly class ResponseFactory
public function download(string $filename, mixed $path): BinaryFileResponse
{
$response = $this->file($filename, 'application/octet-stream', $path);
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename);
$response->headers->set('Content-Description', 'File Transfer');
return $response;
+9 -10
View File
@@ -46,7 +46,7 @@ test('gets search query with various parameters', function (array $data, string
expect($result[1])->toBeArray();
expect(str_contains((string) $result[0], $expectedStr))->toBeTrue($result[0]);
expect(array_diff_key($result[1], $expectedParams))->toBe([]);
expect($result[1])->toMatchArray($expectedParams);
})->with([
[[], 'FROM invoice p', []],
[
@@ -108,31 +108,31 @@ test('gets search query with various parameters', function (array $data, string
],
],
[
['created_at' => '1353715200'],
['created_at' => '2012-11-23 12:34:56'],
"AND DATE_FORMAT(p.created_at, '%Y-%m-%d') = :created_at",
[
'created_at' => '1353715200',
'created_at' => '2012-11-23',
],
],
[
['date_from' => '1353715200'],
['date_from' => '2012-11-23 12:34:56'],
'AND UNIX_TIMESTAMP(p.created_at) >= :date_from',
[
'date_from' => '1353715200',
'date_from' => 1353674096,
],
],
[
['date_to' => '1353715200'],
['date_to' => '2012-11-23 12:34:56'],
'AND UNIX_TIMESTAMP(p.created_at) <= :date_to',
[
'date_to' => '1353715200',
'date_to' => 1353674096,
],
],
[
['paid_at' => '1353715200'],
['paid_at' => '2012-11-23 12:34:56'],
"AND DATE_FORMAT(p.paid_at, '%Y-%m-%d') = :paid_at",
[
'paid_at' => '1353715200',
'paid_at' => '2012-11-23',
],
],
[
@@ -823,7 +823,6 @@ test('admin mark as paid with custom gateway rejects transaction linked to anoth
});
test('counts income', function (): void {
$service = new Service();
$serviceMock = Mockery::mock(Service::class)->makePartial()->shouldAllowMockingProtectedMethods();
$invoiceModel = new Model_Invoice();
+1 -1
View File
@@ -117,7 +117,7 @@ class Service implements \FOSSBilling\InjectionAwareInterface
`created_at` varchar(35) DEFAULT NULL,
`updated_at` varchar(35) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;
';
$this->di['dbal']->executeStatement($sql);
@@ -214,6 +214,31 @@ test('change password password do not match', function (): void {
->toThrow(FOSSBilling\Exception::class, 'Passwords do not match');
});
test('change password weak password', function (): void {
$api = new Box\Mod\Staff\Api\Admin();
$data = [
'id' => '1',
'password' => 'weak',
'password_confirm' => 'weak',
];
$validatorMock = Mockery::mock(FOSSBilling\Validate::class);
$validatorMock
->shouldReceive('passwordsMatch')
->atLeast()->once();
$validatorMock
->shouldReceive('isPasswordStrong')
->atLeast()->once()
->andThrow(new FOSSBilling\InformationException('Password is too weak.'));
$di = container();
$di['validator'] = $validatorMock;
$api->setDi($di);
expect(fn () => $api->change_password($data))
->toThrow(FOSSBilling\Exception::class);
});
test('create', function (): void {
$api = new Box\Mod\Staff\Api\Admin();
$data = [
@@ -55,9 +55,11 @@ test('response factory creates binary file and download responses', function ():
expect($fileResponse)->toBeInstanceOf(BinaryFileResponse::class)
->and($fileResponse->headers->get('Content-Type'))->toBe('text/plain')
->and($fileResponse->headers->get('Content-Disposition'))->toStartWith('inline;')
->and($fileResponse->headers->get('Content-Disposition'))->toContain('report.txt')
->and($downloadResponse->headers->get('Content-Type'))->toBe('application/octet-stream')
->and($downloadResponse->headers->get('Content-Description'))->toBe('File Transfer')
->and($downloadResponse->headers->get('Content-Disposition'))->toStartWith('attachment;')
->and($downloadResponse->headers->get('Content-Disposition'))->toContain('archive.zip');
} finally {
if (is_string($file) && file_exists($file)) {