diff --git a/tests/Foundation/FoundationFormRequestTest.php b/tests/Foundation/FoundationFormRequestTest.php index 5c11b4d6ee9c..41d95b4e0111 100644 --- a/tests/Foundation/FoundationFormRequestTest.php +++ b/tests/Foundation/FoundationFormRequestTest.php @@ -35,6 +35,17 @@ public function test_validated_method_returns_the_validated_data() } public function test_validated_method_returns_the_validated_data_nested_rules() + { + $payload = ['nested' => ['foo' => 'bar', 'baz' => ''], 'array' => [1, 2]]; + + $request = $this->createRequest($payload, FoundationTestFormRequestNestedStub::class); + + $request->validateResolved(); + + $this->assertEquals(['nested' => ['foo' => 'bar'], 'array' => [1, 2]], $request->validated()); + } + + public function test_validated_method_returns_the_validated_data_nested() { $payload = ['nested' => ['foo' => 'bar', 'with' => 'extras']]; @@ -45,7 +56,7 @@ public function test_validated_method_returns_the_validated_data_nested_rules() $this->assertEquals(['nested' => ['foo' => 'bar']], $request->validated()); } - public function test_validated_method_returns_the_validated_data_nested_array_rules() + public function test_validated_method_returns_the_validated_data_nested_array() { $payload = ['nested' => [['bar' => 'baz', 'with' => 'extras'], ['bar' => 'baz2', 'with' => 'extras']]]; diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 171c96d4587a..8b4cbb70f443 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -4006,6 +4006,21 @@ public function testValidateReturnsValidatedData() } public function testValidateReturnsValidatedDataNestedRules() + { + $post = ['nested' => ['foo' => 'bar', 'baz' => ''], 'array' => [1, 2]]; + + $rules = ['nested.foo' => 'required', 'array.*' => 'integer']; + + $v = new Validator($this->getIlluminateArrayTranslator(), $post, $rules); + $v->sometimes('type', 'required', function () { + return false; + }); + $data = $v->validate(); + + $this->assertEquals(['nested' => ['foo' => 'bar'], 'array' => [1, 2]], $data); + } + + public function testValidateReturnsValidatedDataNested() { $post = ['nested' => ['foo' => 'bar', 'with' => 'extras', 'type' => 'admin']]; @@ -4018,7 +4033,7 @@ public function testValidateReturnsValidatedDataNestedRules() $this->assertEquals(['nested' => ['foo' => 'bar']], $data); } - public function testValidateReturnsValidatedDataNestedArrayRules() + public function testValidateReturnsValidatedDataNestedArray() { $post = ['nested' => [['bar' => 'baz', 'with' => 'extras', 'type' => 'admin'], ['bar' => 'baz2', 'with' => 'extras', 'type' => 'admin']]];