Files
WMS/Modules/Helpdesk/Tests/Feature/TicketSourceAttachmentFilesTest.php
T
2026-09-21 10:14:57 +01:00

51 lines
1.9 KiB
PHP
Executable File

<?php
declare(strict_types=1);
namespace Modules\Helpdesk\Tests\Feature;
use Tests\TestCase;
final class TicketSourceAttachmentFilesTest extends TestCase
{
/**
* Source-code uploads must be extension based because browsers and Symfony
* often report source files as text/plain or application/octet-stream.
*/
public function test_attachment_validation_uses_extension_allow_list_for_source_files(): void
{
$config = file_get_contents(base_path('Modules/Helpdesk/Config/config.php'));
$this->assertIsString($config);
$this->assertStringContainsString("'allowed_extensions'", $config);
$this->assertStringContainsString("'php'", $config);
$this->assertStringContainsString("'js'", $config);
$this->assertStringContainsString("'rpg'", $config);
$this->assertStringContainsString("'rpgle'", $config);
}
/**
* All Helpdesk upload entry points should use the shared source-safe rules.
*/
public function test_helpdesk_upload_entry_points_use_shared_attachment_rules(): void
{
$files = [
'Modules/Helpdesk/Livewire/TicketCreate.php',
'Modules/Helpdesk/Livewire/TicketEdit.php',
'Modules/Helpdesk/Livewire/TicketShow.php',
'Modules/Helpdesk/Http/Controllers/TicketStoreController.php',
'Modules/Helpdesk/Http/Controllers/TicketCommentStoreController.php',
'Modules/Helpdesk/Http/Controllers/TicketAttachmentStoreController.php',
];
foreach ($files as $file) {
$contents = file_get_contents(base_path($file));
$this->assertIsString($contents);
$this->assertStringContainsString('extensions:', $contents, $file);
$this->assertStringNotContainsString('mimes:', $contents, $file);
$this->assertStringNotContainsString('AttachmentValidation', $contents, $file);
}
}
}