respect-validation/tests/unit/Exceptions/NestedValidationExceptionTest.php
Henrique Moody fd2bae7352
Enforce the use of "@covers" annotation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-07-23 21:37:38 +02:00

48 lines
1.4 KiB
PHP

<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
*
* 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 PHPUnit\Framework\TestCase;
/**
* @covers \Respect\Validation\Exceptions\NestedValidationException
*/
class NestedValidationExceptionTest extends TestCase
{
/**
* @test
*/
public function getRelatedShouldReturnExceptionAddedByAddRelated(): void
{
$composite = new AttributeException('input', 'id', [], 'trim');
$node = new IntValException('input', 'id', [], 'trim');
$composite->addRelated($node);
self::assertCount(1, $composite->getRelated(true));
self::assertContainsOnly($node, $composite->getRelated());
}
/**
* @test
*/
public function addingTheSameInstanceShouldAddJustASingleReference(): void
{
$composite = new AttributeException('input', 'id', [], 'trim');
$node = new IntValException('input', 'id', [], 'trim');
$composite->addRelated($node);
$composite->addRelated($node);
$composite->addRelated($node);
self::assertCount(1, $composite->getRelated(true));
self::assertContainsOnly($node, $composite->getRelated());
}
}