Example #1
0
 /**
 	Returns whether the given input is a valid form option for the associated widget.
 
 	@param	$mInput			The input.
 	@return	bool			Whether the input is a valid form option.
 */
 protected function isValidInput($mInput)
 {
     $oHelper = new weeFormOptionsHelper($this->oWidget);
     return $oHelper->isInOptions($mInput);
 }
Example #2
0
<?php

class CastableInput_testOptionValidator
{
    public function __toString()
    {
        return '42';
    }
}
$oWidget = simplexml_load_string('<widget type="choice"/>');
$oHelper = new weeFormOptionsHelper($oWidget);
$o = new weeOptionValidator();
// weeOptionValidator::setValue should throw an DomainException when the value
// is not a scalar, an instance of Printable or an object castable to string.
try {
    $o->setValue(null);
} catch (DomainException $e) {
    $this->fail(_WT('weeOptionValidator::setValue should not throw a DomainException when the value is null.'));
}
try {
    $o->setValue(array());
    $this->fail(_WT('weeOptionValidator::setValue should throw a DomainException when the value is an array.'));
} catch (DomainException $e) {
}
try {
    $o->setValue(true);
    $this->fail(_WT('weeOptionValidator::setValue should throw a DomainException when the value is a boolean.'));
} catch (DomainException $e) {
}
try {
    $o->setValue(new stdClass());