Skip to content

Commit 92cf9d9

Browse files
committed
add test
1 parent 91afbe0 commit 92cf9d9

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

tests/Validation/ValidationValidatorTest.php

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3880,6 +3880,32 @@ public function testPassingSlashVulnerability()
38803880
$this->assertTrue($v->fails());
38813881
}
38823882

3883+
public function testPlaceholdersAreReplaced()
3884+
{
3885+
$trans = $this->getIlluminateArrayTranslator();
3886+
3887+
$v = new Validator($trans, [
3888+
'matrix' => ['\\' => ['invalid'], '1\\' => ['invalid']],
3889+
], [
3890+
'matrix.*.*' => 'integer',
3891+
]);
3892+
$this->assertTrue($v->fails());
3893+
3894+
$v = new Validator($trans, [
3895+
'matrix' => ['\\' => [1], '1\\' => [1]],
3896+
], [
3897+
'matrix.*.*' => 'integer',
3898+
]);
3899+
$this->assertTrue($v->passes());
3900+
3901+
$v = new Validator($trans, [
3902+
'foo' => ['bar' => 'valid'], 'foo.bar' => 'invalid', 'foo->bar' => 'valid',
3903+
], [
3904+
'foo\.bar' => 'required|in:valid',
3905+
]);
3906+
$this->assertTrue($v->fails());
3907+
}
3908+
38833909
public function testCoveringEmptyKeys()
38843910
{
38853911
$trans = $this->getIlluminateArrayTranslator();
@@ -3891,35 +3917,8 @@ public function testImplicitEachWithAsterisksWithArrayValues()
38913917
{
38923918
$trans = $this->getIlluminateArrayTranslator();
38933919

3894-
$v = new Validator($trans, ['foo' => [1, 2, 3]], ['foo' => 'size:4']);
3895-
$this->assertFalse($v->passes());
3896-
3897-
$v = new Validator($trans, ['foo' => [1, 2, 3, 4]], ['foo' => 'size:4']);
3898-
$this->assertTrue($v->passes());
3899-
3900-
$v = new Validator($trans, ['foo' => [1, 2, 3, 4]], ['foo.*' => 'integer', 'foo.0' => 'required']);
3901-
$this->assertTrue($v->passes());
3902-
3903-
$v = new Validator($trans, ['foo' => [['bar' => [1, 2, 3]], ['bar' => [1, 2, 3]]]], ['foo.*.bar' => 'size:4']);
3904-
$this->assertFalse($v->passes());
3905-
3906-
$v = new Validator($trans,
3907-
['foo' => [['bar' => [1, 2, 3]], ['bar' => [1, 2, 3]]]], ['foo.*.bar' => 'min:3']);
3908-
$this->assertTrue($v->passes());
3909-
3910-
$v = new Validator($trans,
3911-
['foo' => [['bar' => [1, 2, 3]], ['bar' => [1, 2, 3]]]], ['foo.*.bar' => 'between:3,6']);
3912-
$this->assertTrue($v->passes());
3913-
3914-
$v = new Validator($trans,
3915-
['foo' => [['name' => 'first', 'votes' => [1, 2]], ['name' => 'second', 'votes' => ['something', 2]]]],
3916-
['foo.*.votes' => ['Required', 'Size:2']]);
3917-
$this->assertTrue($v->passes());
3918-
3919-
$v = new Validator($trans,
3920-
['foo' => [['name' => 'first', 'votes' => [1, 2, 3]], ['name' => 'second', 'votes' => ['something', 2]]]],
3921-
['foo.*.votes' => ['Required', 'Size:2']]);
3922-
$this->assertFalse($v->passes());
3920+
$v = new Validator($trans, ['foo' => ['bar.baz' => '']], ['foo' => 'required']);
3921+
$this->assertEquals(['foo' => ['bar.baz' => '']], $v->validated());
39233922
}
39243923

39253924
public function testValidateNestedArrayWithCommonParentChildKey()

0 commit comments

Comments
 (0)