1
+ <?php
2
+
3
+ namespace Tests \Feature ;
4
+
5
+ use App \Idea ;
6
+ use App \Ticket ;
7
+ use App \User ;
8
+ use Illuminate \Http \Response ;
9
+ use Illuminate \Support \Facades \Notification ;
10
+ use Tests \TestCase ;
11
+ use Illuminate \Foundation \Testing \RefreshDatabase ;
12
+
13
+ class TicketRatingTest extends TestCase
14
+ {
15
+ use RefreshDatabase;
16
+
17
+ /** @test */
18
+ public function can_rate_a_ticket_when_close ()
19
+ {
20
+ $ ticket = factory (Ticket::class)->states (['closed ' ])->create (["public_token " => "TOKEN " ]);
21
+ $ response = $ this ->get ("requester/tickets/TOKEN/rate?rating=3 " );
22
+
23
+ $ response ->assertStatus (Response::HTTP_OK );
24
+ $ this ->assertEquals (3 , $ ticket ->fresh ()->rating );
25
+ }
26
+
27
+ /** @test */
28
+ public function can_not_rate_a_ticket_without_a_rating ()
29
+ {
30
+ $ ticket = factory (Ticket::class)->states (['closed ' ])->create (["public_token " => "TOKEN " ]);
31
+ $ response = $ this ->get ("requester/tickets/TOKEN/rate " );
32
+
33
+ $ response ->assertStatus (Response::HTTP_UNPROCESSABLE_ENTITY );
34
+ $ this ->assertNull ($ ticket ->fresh ()->rating );
35
+ }
36
+
37
+ /** @test */
38
+ public function can_not_rate_a_ticket_when_not_closed ()
39
+ {
40
+ $ ticket = factory (Ticket::class)->create (["status " => Ticket::STATUS_OPEN , "public_token " => "TOKEN " ]);
41
+ $ response = $ this ->get ("requester/tickets/TOKEN/rate?rating=2 " );
42
+
43
+ $ response ->assertStatus (Response::HTTP_UNPROCESSABLE_ENTITY );
44
+ $ this ->assertNull ($ ticket ->fresh ()->rating );
45
+ }
46
+
47
+ public function can_not_rate_a_ticket_when_already_rated (){
48
+
49
+ }
50
+
51
+
52
+
53
+ /** @test */
54
+ public function the_rating_email_is_sent_when_order_closed_and_not_rated ()
55
+ {
56
+ }
57
+
58
+ public function the_rating_email_is_not_sent_when_order_closed_not_rated (){
59
+
60
+ }
61
+
62
+ /** @test */
63
+ public function the_idea_created_text_uses_the_ticket_language ()
64
+ {
65
+ Notification::fake ();
66
+ $ user = factory (User::class)->create ();
67
+ $ ticket = factory (Ticket::class)->create ([
68
+ "status " => Ticket::STATUS_OPEN ,
69
+ "body " => "Aquest es un comentari en català per veure que el detector d'idioma funciona "
70
+ ]);
71
+
72
+ $ response = $ this ->actingAs ($ user )->post ("tickets/ {$ ticket ->id }/idea " );
73
+
74
+ $ response ->assertStatus ( Response::HTTP_FOUND );
75
+ $ this ->assertContains ("Notificació | Banc d'Idees REVO " , $ ticket ->fresh ()->commentsAndNotes ->first ()->body );
76
+ }
77
+ }
0 commit comments