* * For the full copyright and license information, please view the "LICENSE.md" * file that was distributed with this source code. */ declare(strict_types=1); namespace Respect\Validation\Exceptions; use Respect\Validation\Test\TestCase; /** * @covers \Respect\Validation\Exceptions\NestedValidationException * * @author Alexandre Gomes Gaigalas * @author Gabriel Caruso * @author Henrique Moody */ class NestedValidationExceptionTest extends TestCase { /** * @test */ public function getChildrenShouldReturnExceptionAddedByAddRelated(): void { $composite = new AttributeException('input', 'id', [], 'trim'); $node = new IntValException('input', 'id', [], 'trim'); $composite->addChild($node); self::assertCount(1, $composite->getChildren()); self::assertContainsOnly(IntValException::class, $composite->getChildren()); } /** * @test */ public function addingTheSameInstanceShouldAddJustOneSingleReference(): void { $composite = new AttributeException('input', 'id', [], 'trim'); $node = new IntValException('input', 'id', [], 'trim'); $composite->addChild($node); $composite->addChild($node); $composite->addChild($node); self::assertCount(1, $composite->getChildren()); self::assertContainsOnly(IntValException::class, $composite->getChildren()); } }