Skip to content

Commit a5adb0e

Browse files
committed
add labels tests
1 parent 1579c4d commit a5adb0e

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

tests/Feature/CategoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
});
2525

2626
it('gets categories by visibility status', function () {
27-
$categories = Category::factory()->times(10)->create([
27+
Category::factory()->times(10)->create([
2828
'is_visible' => true,
2929
]);
3030

tests/Feature/LabelTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
11
<?php
2+
3+
use Coderflex\LaravelTicket\Models\Label;
4+
use Coderflex\LaravelTicket\Models\Ticket;
5+
6+
it('can attach category to a ticket', function () {
7+
$label = Label::factory()->create();
8+
$ticket = Ticket::factory()->create();
9+
10+
$label->tickets()->attach($ticket);
11+
12+
$this->assertEquals($label->tickets->count(), 1);
13+
});
14+
15+
it('can deattach category to a ticket', function () {
16+
$label = Label::factory()->create();
17+
$ticket = Ticket::factory()->create();
18+
19+
$ticket->attachLabels($label);
20+
21+
$label->tickets()->detach($ticket);
22+
23+
$this->assertEquals($label->tickets->count(), 0);
24+
});
25+
26+
it('gets categories by visibility status', function () {
27+
Label::factory()->times(7)->create([
28+
'is_visible' => true,
29+
]);
30+
31+
Label::factory()->times(6)->create([
32+
'is_visible' => false,
33+
]);
34+
35+
$this->assertEquals(Label::count(), 13);
36+
$this->assertEquals(Label::visible()->count(), 7);
37+
$this->assertEquals(Label::hidden()->count(), 6);
38+
});

0 commit comments

Comments
 (0)