1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
<?php
declare(strict_types=1);
namespace Lcobucci\JWT\Tests\Validation;
use Lcobucci\JWT\Validation\ConstraintViolation;
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
use PHPUnit\Framework\Attributes as PHPUnit;
use PHPUnit\Framework\TestCase;
#[PHPUnit\CoversClass(RequiredConstraintsViolated::class)]
#[PHPUnit\UsesClass(ConstraintViolation::class)]
final class RequiredConstraintsViolatedTest extends TestCase
{
#[PHPUnit\Test]
public function fromViolationsShouldConfigureMessageAndViolationList(): void
{
$violation = new ConstraintViolation('testing');
$exception = RequiredConstraintsViolated::fromViolations($violation);
self::assertSame(
"The token violates some mandatory constraints, details:\n- testing",
$exception->getMessage(),
);
self::assertSame([$violation], $exception->violations());
}
}
|