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 69ed2d8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Validation/ValidationForEachTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,28 @@ 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.bar' => ['validation.accepted'],
], $v->getMessageBag()->toArray());
}

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

0 comments on commit 69ed2d8

Please sign in to comment.