Skip to content

Commit

Permalink
Add test nested post validation hook
Browse files Browse the repository at this point in the history
  • Loading branch information
DAGpro committed Sep 29, 2024
1 parent 771cc69 commit cf17d14
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Rule/NestedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Yiisoft\Validator\Tests\Support\Data\IteratorWithBooleanKey;
use Yiisoft\Validator\Tests\Support\Data\ObjectWithDifferentPropertyVisibility;
use Yiisoft\Validator\Tests\Support\Data\ObjectWithNestedObject;
use Yiisoft\Validator\Tests\Support\Data\ObjectWithPostValidationHook;
use Yiisoft\Validator\Tests\Support\Helper\OptionsHelper;
use Yiisoft\Validator\Tests\Support\Rule\StubRule\StubDumpedRule;
use Yiisoft\Validator\Tests\Support\RulesProvider\SimpleRulesProvider;
Expand Down Expand Up @@ -860,6 +861,25 @@ public function testWithOtherNestedAndEach(
$this->assertSame($expectedErrorMessagesIndexedByPath, $result->getErrorMessagesIndexedByPath());
}


public function testNestedPostValidationHook(): void
{
$object = new class () {

#[Nested(ObjectWithPostValidationHook::class)]
public ObjectWithPostValidationHook $postHook;

public function __construct()
{
$this->postHook = new ObjectWithPostValidationHook();
}
};

$validator = new Validator();
$validator->validate($object);
$this->assertTrue($object->postHook->hookCalled);
}

public function dataValidationPassed(): array
{
return [
Expand Down

0 comments on commit cf17d14

Please sign in to comment.