@@ -172,63 +172,71 @@ public function it_search_by_created_date(): void
172
172
/** @test */
173
173
public function it_search_by_resolved (): void
174
174
{
175
- QuestionFactory::new ([
175
+ $ questonsResolved = QuestionFactory::new ([
176
176
'resolved_at ' => Carbon::now (),
177
177
])
178
- ->count (5 )
179
178
->create ();
180
179
181
180
$ this ->json ('GET ' , route ('discussions.questions.index ' ))
182
181
->seeJsonContains ([
183
- 'to ' => 15 ,
182
+ 'resolved_at ' => $ questonsResolved ->resolved_at ,
183
+ ])
184
+ ->seeJsonContains ([
185
+ 'resolved_at ' => null ,
184
186
]);
185
187
186
188
$ this ->json ('GET ' , route ('discussions.questions.index ' , [
187
189
'resolved ' => true ,
188
190
]))
189
191
->seeJsonContains ([
190
- 'to ' => 5 ,
192
+ 'resolved_at ' => $ questonsResolved ->resolved_at ,
193
+ ])
194
+ ->seeJsonDoesntContains ([
195
+ 'resolved_at ' => null ,
191
196
]);
192
197
193
198
$ this ->json ('GET ' , route ('discussions.questions.index ' , [
194
199
'resolved ' => false ,
195
200
]))
201
+ ->seeJsonDoesntContains ([
202
+ 'resolved_at ' => $ questonsResolved ->resolved_at ,
203
+ ])
196
204
->seeJsonContains ([
197
- 'to ' => 10 ,
205
+ 'resolved_at ' => null ,
198
206
]);
199
207
}
200
208
201
209
/**
202
210
* @test
203
- * @dataProvider datesProvider
211
+ * @dataProvider invalidSearchablePropertiesValuesProvider
204
212
*/
205
213
public function it_fails_by_validations ($ param , $ expected )
206
214
{
207
215
$ this ->get (route ('discussions.questions.index ' , $ param ))
208
216
->assertResponseStatus ($ expected );;
209
217
}
210
218
211
- public function datesProvider ()
219
+ public function invalidSearchablePropertiesValuesProvider ()
212
220
{
213
221
return [
214
222
'Search author by string ' => [
215
223
['author ' => 'author ' ],
216
- Response::HTTP_UNPROCESSABLE_ENTITY
224
+ Response::HTTP_UNPROCESSABLE_ENTITY ,
217
225
],
218
226
'Search resolved with int ' => [
219
227
['resolved ' => 21333 ],
220
- Response::HTTP_UNPROCESSABLE_ENTITY
228
+ Response::HTTP_UNPROCESSABLE_ENTITY ,
221
229
],
222
230
'Search create only from date ' => [
223
231
['created[from] ' => Carbon::now ()->subMonth ()->subYears (2 )->toDateString ()],
224
- Response::HTTP_UNPROCESSABLE_ENTITY
232
+ Response::HTTP_UNPROCESSABLE_ENTITY ,
225
233
],
226
234
'Search with a "to" date less than "from" ' => [
227
235
[
228
236
'created[from] ' => Carbon::now ()->subMonth ()->subYears (2 )->toDateString (),
229
237
'created[to] ' => Carbon::now ()->subMonth ()->subYears (3 )->toDateString (),
230
238
],
231
- Response::HTTP_UNPROCESSABLE_ENTITY
239
+ Response::HTTP_UNPROCESSABLE_ENTITY ,
232
240
],
233
241
];
234
242
}
0 commit comments