TestCustomValidator example

use PHPUnit\Framework\ExpectationFailedException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\DateTime;
use Symfony\Component\Validator\Constraints\NotNull;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class ConstraintValidatorTestCaseTest extends ConstraintValidatorTestCase
{
    protected function createValidator(): TestCustomValidator
    {
        return new TestCustomValidator();
    }

    public function testAssertingContextualValidatorRemainingExpectationsThrow()
    {
        $this->expectValidateValueAt(0, 'k1', 'ccc', [
            new NotNull(),
        ]);
        $this->expectValidateValueAt(1, 'k2', 'ccc', [
            new DateTime(),
        ]);

        
Home | Imprint | This part of the site doesn't use cookies.