Example #1
0
} catch (DomainException $e) {
    $this->fail(_WT('weeOptionValidator::setValue should not throw a DomainException when the value is an instance of Printable.'));
}
try {
    $o->setValue(new CastableInput_testOptionValidator());
} catch (DomainException $e) {
    $this->fail(_WT('weeOptionValidator::setValue should not throw a DomainException when the value is an object castable to string.'));
}
try {
    $o->setValue(42);
} catch (DomainException $e) {
    $this->fail(_WT('weeOptionValidator::setValue should not throw a DomainException when the value is an integer.'));
}
try {
    $o->setValue(42.42);
} catch (DomainException $e) {
    $this->fail(_WT('weeOptionValidator::setValue should not throw a DomainException when the value is a float.'));
}
try {
    $o->setValue('42');
} catch (DomainException $e) {
    $this->fail(_WT('weeOptionValidator::setValue should not throw a DomainException when the value is a string.'));
}
// The following validation should fail.
$o->setFormData($oWidget, array());
$this->isTrue($o->hasError(), _WT('weeOptionValidator::hasError should return true when the value is not present in the widget options.'));
// The following validation should succeed.
$o = new weeOptionValidator();
$oHelper->addOption(42);
$o->setValue(42)->setFormData($oWidget, array());
$this->isFalse($o->hasError(), _WT('weeOptionValidator::hasError should return false when the value is present in the widget options.'));