@@ -40,7 +40,11 @@ public function it_updates_questions(): void
40
40
];
41
41
42
42
$ this ->actingAs ($ this ->user );
43
- $ response = $ this ->call ('PATCH ' , '/questions/ ' . $ this ->question ->id , $ payload );
43
+ $ response = $ this ->call (
44
+ 'PATCH ' ,
45
+ route ('discussions.questions.update ' , ['questionId ' => $ this ->question ->id ]),
46
+ $ payload
47
+ );
44
48
self ::assertTrue ($ response ->isEmpty ());
45
49
46
50
$ this ->seeInDatabase ('questions ' , [
@@ -56,7 +60,7 @@ public function it_updates_questions(): void
56
60
public function it_fails_to_update_if_title_is_missing (): void
57
61
{
58
62
$ this ->actingAs ($ this ->user );
59
- $ this ->patch (' / questions/ ' . $ this ->question ->id )
63
+ $ this ->patch (route ( ' discussions. questions.update ' , [ ' questionId ' => $ this ->question ->id ]) )
60
64
->seeJsonStructure ([
61
65
'title ' ,
62
66
]);
@@ -66,9 +70,13 @@ public function it_fails_to_update_if_title_is_missing(): void
66
70
public function it_keeps_previous_description_if_none_is_sent (): void
67
71
{
68
72
$ this ->actingAs ($ this ->user );
69
- $ response = $ this ->call ('PATCH ' , '/questions/ ' . $ this ->question ->id , [
70
- 'title ' => $ this ->faker ->title ,
71
- ]);
73
+ $ response = $ this ->call (
74
+ 'PATCH ' ,
75
+ route ('discussions.questions.update ' , ['questionId ' => $ this ->question ->id ]),
76
+ [
77
+ 'title ' => $ this ->faker ->title ,
78
+ ]
79
+ );
72
80
73
81
self ::assertTrue ($ response ->isEmpty ());
74
82
self ::assertEquals ($ this ->question ->description , $ this ->question ->refresh ()->description );
@@ -78,9 +86,11 @@ public function it_keeps_previous_description_if_none_is_sent(): void
78
86
public function it_forbids_non_owner_to_update_questions (): void
79
87
{
80
88
$ this ->actingAs (UserFactory::new ()->make ()); // make another user
81
- $ this ->patch ('/questions/ ' . $ this ->question ->id , [
82
- 'title ' => $ this ->faker ->title ,
83
- ])
84
- ->assertResponseStatus (Response::HTTP_FORBIDDEN );
89
+ $ this ->patch (
90
+ route ('discussions.questions.update ' , ['questionId ' => $ this ->question ->id ]),
91
+ [
92
+ 'title ' => $ this ->faker ->title ,
93
+ ]
94
+ )->assertResponseStatus (Response::HTTP_FORBIDDEN );
85
95
}
86
96
}
0 commit comments