new helpdesk module
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Helpdesk\Tests\Unit;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Modules\Helpdesk\Models\Comment;
|
||||
use Modules\Helpdesk\Models\GitCommit;
|
||||
use Modules\Helpdesk\Tests\Concerns\BuildsHelpdeskFixtures;
|
||||
use Tests\TestCase;
|
||||
|
||||
final class ModelRelationshipTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
use BuildsHelpdeskFixtures;
|
||||
|
||||
public function test_ticket_loads_company_project_team_category_priority_status_and_git_commits(): void
|
||||
{
|
||||
$fixtures = $this->seedLookupData();
|
||||
$repository = $this->repository(['project_id' => $fixtures['project']->id]);
|
||||
$ticket = $this->ticket([
|
||||
'status_id' => $fixtures['open']->id,
|
||||
'priority_id' => $fixtures['high']->id,
|
||||
'category_id' => $fixtures['category']->id,
|
||||
'team_id' => $fixtures['team']->id,
|
||||
'project_id' => $fixtures['project']->id,
|
||||
]);
|
||||
|
||||
GitCommit::query()->create([
|
||||
'repository_id' => $repository->id,
|
||||
'ticket_id' => $ticket->id,
|
||||
'hash' => str_repeat('a', 40),
|
||||
'short_hash' => 'aaaaaaa',
|
||||
'branch' => 'develop',
|
||||
'author_name' => 'Developer',
|
||||
'author_email' => 'dev@example.com',
|
||||
'message' => 'Fix HD reference handling',
|
||||
'url' => 'https://example.com/commit/a',
|
||||
'committed_at' => now(),
|
||||
]);
|
||||
|
||||
$ticket->refresh()->load(['status', 'priority', 'category', 'team', 'project', 'gitCommits']);
|
||||
|
||||
self::assertSame('Open', $ticket->status?->name);
|
||||
self::assertSame('High', $ticket->priority?->name);
|
||||
self::assertSame('Support', $ticket->category?->name);
|
||||
self::assertSame('Support Team', $ticket->team?->name);
|
||||
self::assertSame('WMS Core', $ticket->project?->title);
|
||||
self::assertCount(1, $ticket->gitCommits);
|
||||
}
|
||||
|
||||
public function test_comments_support_nested_replies(): void
|
||||
{
|
||||
$ticket = $this->ticket();
|
||||
$user = $this->user();
|
||||
$comment = Comment::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'user_id' => $user->id,
|
||||
'body' => '<p>Parent response</p>',
|
||||
'is_internal' => false,
|
||||
]);
|
||||
Comment::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_id' => $comment->id,
|
||||
'user_id' => $user->id,
|
||||
'body' => '<p>Nested response</p>',
|
||||
'is_internal' => false,
|
||||
]);
|
||||
|
||||
self::assertSame('Nested response', strip_tags((string) $comment->replies()->firstOrFail()->body));
|
||||
self::assertCount(1, $ticket->comments()->with('replies')->get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user