Skip to content

Commit 1b4ee56

Browse files
committed
add test case
1 parent 17782a0 commit 1b4ee56

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/Fixtures/TestController.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,29 @@ public function withInlineValidatorMake(Request $request)
646646

647647
}
648648
}
649+
public function withInlineValidatorMakeValidate(Request $request)
650+
{
651+
// Some stuff
652+
Validator::make($request, [
653+
// The id of the user. Example: 9
654+
'user_id' => 'int|required',
655+
// The id of the room.
656+
'room_id' => ['string', 'in:3,5,6'],
657+
// Whether to ban the user forever. Example: false
658+
'forever' => 'boolean',
659+
// Just need something here. No-example
660+
'another_one' => 'numeric',
661+
'even_more_param' => 'array',
662+
'book.name' => 'string',
663+
'book.author_id' => 'integer',
664+
'book.pages_count' => 'integer',
665+
'ids.*' => 'integer',
666+
// The first name of the user. Example: John
667+
'users.*.first_name' => ['string'],
668+
// The last name of the user. Example: Doe
669+
'users.*.last_name' => 'string',
670+
])->validate();
671+
}
649672

650673
public function withInlineRequestValidateWithBag(Request $request)
651674
{

tests/Strategies/GetFromInlineValidatorTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,19 @@ public function can_fetch_from_validator_make()
208208
$this->assertIsArray($results['ids']['example']);
209209
}
210210

211+
/** @test */
212+
public function can_fetch_from_validator_make_validate()
213+
{
214+
$endpoint = $this->endpoint(function (ExtractedEndpointData $e) {
215+
$e->method = new \ReflectionMethod(TestController::class, 'withInlineValidatorMakeValidate');
216+
});
217+
218+
$results = $this->fetchViaBodyParams($endpoint);
219+
220+
$this->assertArraySubset(self::$expected, $results);
221+
$this->assertIsArray($results['ids']['example']);
222+
}
223+
211224
/** @test */
212225
public function respects_query_params_comment()
213226
{

0 commit comments

Comments
 (0)