Example #1
0
File: time.php Project: extend/wee
<?php

class CastableInput_testTimeValidator
{
    public function __toString()
    {
        return '09:42';
    }
}
$sFormerTimezone = @date_default_timezone_get();
date_default_timezone_set('Europe/Paris');
try {
    // weeTimeValidator 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 weeTimeValidator();
    try {
        $o->setValue(new stdClass());
        $this->fail(_WT('weeTimeValidator 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('weeTimeValidator should throw a DomainException when the value is a boolean.'));
    } catch (DomainException $e) {
    }
    try {
        $o->setValue(null);
        $this->fail(_WT('weeTimeValidator should throw a DomainException when the value is null.'));
    } catch (DomainException $e) {
    }
    try {
        $o->setValue(array());
Example #2
0
<?php

$o = new weeTimeValidator(array('max' => '09:42', 'max_error' => 'The value you gave is greater than %max%.'));
$o->setValue('09:43');
if ($o->hasError()) {
    echo $o->getError();
}
// The value you gave is greater than 09:42.