Skip to content

Commit 923eddd

Browse files
committed
add more tests
1 parent d99b8ce commit 923eddd

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/Concerns/InteractsWithTickets.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public function archive(): self
1616
$this->update([
1717
'status' => Status::ARCHIVED->value,
1818
]);
19-
2019
return $this;
2120
}
2221

tests/Feature/TicketRelationsTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
});
8989

9090
it('can create a message inside the ticket by another user', function () {
91-
$user = $this->actingAs(User::factory()->create());
91+
$this->actingAs($user = User::factory()->create());
9292
$anotherUser = User::factory()->create();
9393

9494
$ticket = Ticket::factory()->create();
@@ -98,3 +98,14 @@
9898
$this->assertEquals($ticket->messages->count(), 1);
9999
$this->assertEquals($ticket->messages->first()->user_id, $anotherUser->id);
100100
});
101+
102+
it('associate a comment ticket to the current user, if no user are defined', function () {
103+
$this->actingAs($user = User::factory()->create());
104+
105+
$ticket = Ticket::factory()->create();
106+
107+
$ticket->messageAsUser(null, 'How are you today?');
108+
109+
$this->assertEquals($ticket->messages->count(), 1);
110+
$this->assertEquals($ticket->messages->first()->user_id, $user->id);
111+
});

tests/Feature/TicketTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,20 @@
230230
$this->assertTrue($lockedTicket->isLocked());
231231
});
232232

233+
it('ensures ticket methods as chainable', function () {
234+
$ticket = Ticket::factory()->create([
235+
'status' => 'open',
236+
'is_locked' => false,
237+
]);
238+
239+
$ticket->archive()
240+
->markAsLocked();
241+
242+
$this->assertTrue($ticket->isArchived());
243+
$this->assertTrue($ticket->isLocked());
244+
});
245+
246+
233247
it('can delete a ticket', function () {
234248
$ticket = Ticket::factory()->create();
235249

0 commit comments

Comments
 (0)