Esempio n. 1
0
File: date.php Progetto: extend/wee
<?php

class CastableInput_testDateValidator
{
    public function __toString()
    {
        return '1987-10-29';
    }
}
$sFormerTimezone = @date_default_timezone_get();
date_default_timezone_set('Europe/Paris');
try {
    $sYesterday = strftime('%Y-%m-%d', strtotime('yesterday'));
    $sTomorrow = strftime('%Y-%m-%d', strtotime('tomorrow'));
    // weeDateValidator should throw a DomainException when the value to validate is not a string or an instance of Printable or an object castable to string.
    $o = new weeDateValidator();
    try {
        $o->setValue(new stdClass());
        $this->fail(_WT('weeDateValidator should throw a DomainException when the value is an object which is neither an instance of Printable nor an object castable to string.'));
    } catch (DomainException $e) {
    }
    try {
        $o->setValue(true);
        $this->fail(_WT('weeDateValidator should throw a DomainException when the value is a boolean.'));
    } catch (DomainException $e) {
    }
    try {
        $o->setValue(null);
        $this->fail(_WT('weeDateValidator should throw a DomainException when the value is null.'));
    } catch (DomainException $e) {
    }
Esempio n. 2
0
<?php

$o = new weeDateValidator(array('invalid_error' => 'What you gave me was not a date!'));
$o->setValue('fail');
if ($o->hasError()) {
    echo $o->getError();
}
// What you gave me was not a date!