Files
kimai2/tests/Validator/ValidationFailedExceptionTest.php
2025-08-11 18:57:42 +02:00

38 lines
1.2 KiB
PHP

<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Validator;
use App\Validator\ValidationFailedException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\ConstraintViolationList;
#[CoversClass(ValidationFailedException::class)]
class ValidationFailedExceptionTest extends TestCase
{
public function testException(): void
{
$list = new ConstraintViolationList();
$sut = new ValidationFailedException($list);
self::assertEquals(400, $sut->getCode());
self::assertEquals('Validation Failed', $sut->getMessage());
self::assertSame($list, $sut->getViolations());
}
public function testConstruct(): void
{
$list = new ConstraintViolationList();
$sut = new ValidationFailedException($list, 'Something went wrong');
self::assertEquals(400, $sut->getCode());
self::assertEquals('Something went wrong', $sut->getMessage());
self::assertSame($list, $sut->getViolations());
}
}