IT-Service: Dateianhang beim Ticket
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m45s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m56s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m2s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m23s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m17s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m38s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m23s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 21:16:11 +00:00
parent e9283752c6
commit 011a421b29
111 changed files with 561 additions and 451 deletions

View file

@ -6,6 +6,7 @@ use App\Models\Setting;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Client\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Http;
use Inertia\Testing\AssertableInertia as Assert;
use Inhaus\Plugins\ItService\Filament\Pages\ItServiceSettings;
@ -107,6 +108,35 @@ class ItServiceTest extends TestCase
});
}
public function test_ticket_attachment_is_sent_like_the_wordpress_plugin(): void
{
Http::fake([
'*/tickets' => Http::response(['id' => 43, 'status' => 'open']),
'*/ticket-categories' => Http::response(['categories' => []]),
'*/ticket-locations' => Http::response(['locations' => []]),
]);
$file = UploadedFile::fake()->createWithContent('fehler.png', 'PNGDATA');
$this->actingAs($this->user)->post('/it-service/tickets', ['subject' => 'Drucker', 'description' => 'Siehe Bild', 'attachment' => $file])
->assertRedirect('/it-service/tickets/43');
Http::assertSent(function (Request $request) {
if ($request->method() !== 'POST') {
return false;
}
$body = json_decode($request->body(), true);
$this->assertSame('fehler.png', $body['attachment_name']);
$this->assertStringStartsWith('data:', $body['attachment_b64']);
$this->assertStringEndsWith(';base64,'.base64_encode('PNGDATA'), $body['attachment_b64']);
return true;
});
$this->actingAs($this->user)->post('/it-service/tickets', ['subject' => 'X', 'description' => 'Y', 'attachment' => UploadedFile::fake()->create('virus.exe', 10)])
->assertSessionHasErrors('attachment');
}
public function test_ticket_detail_reply_and_foreign_tickets(): void
{
Http::fake([