Skip to content

Commit

Permalink
failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmastech committed Jun 4, 2023
1 parent 4f3d472 commit 911fc3f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Validation/ValidationForEachTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ public function testForEachCallbacksCanContainMultipleRegexRules()
], $v->getMessageBag()->toArray());
}

public function testConditionalRulesCanBeAddedToForEach()
{
$v = new Validator($this->getIlluminateArrayTranslator(),
[
'foo' => [
[
'bar' => true
],
[
'bar' => false
]
]
],
[
'foo.*' => Rule::forEach(fn(mixed $value, string $attribute) => [
'bar' => Rule::when(true, ['accepted'], ['declined'])
])
]
);

$this->assertEquals([
'foo.1' => 'validation.accepted',
], $v->getMessageBag()->toArray());
}

protected function getTranslator()
{
return m::mock(TranslatorContract::class);
Expand Down

0 comments on commit 911fc3f

Please sign in to comment.