Date example

/** * Creates an Ext js date field. * * @param string $name * @param string $label * * @return Date */
    protected function createDateField($name$label$defaultValue, array $options = [])
    {
        $element = new Date($name);
        $element->fromArray($options);
        $element->setLabel($label);
        $element->setDefaultValue($defaultValue);

        return $element;
    }

    /** * Creates an Ext js text field with auto suffix `em` * * @param string $name * @param string $label * * @return Em */
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class DateValidatorTest extends ConstraintValidatorTestCase
{
    protected function createValidator(): DateValidator
    {
        return new DateValidator();
    }

    public function testNullIsValid()
    {
        $this->validator->validate(null, new Date());

        $this->assertNoViolation();
    }

    public function testEmptyStringIsValid()
    {
        $this->validator->validate('', new Date());

        $this->assertNoViolation();
    }

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