<?php class CastableInput_testNumberValidator { public function __toString() { return '42'; } } $o = new weeNumberValidator(); $this->isEqual(array('format' => 'int'), $o->getArgs(), _WT('weeNumberValidator does not return the expected default `format` argument.')); // weeNumberValidator should throw a DomainException when the value to validate is neither an integer, // a float or a string, an instance of Printable or an object castable to string. try { $o->setValue(new stdClass()); $this->fail(_WT('weeNumberValidator 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('weeNumberValidator should throw a DomainException when the value is a boolean.')); } catch (DomainException $e) { } try { $o->setValue(null); $this->fail(_WT('weeNumberValidator should throw a DomainException when the value is null.')); } catch (DomainException $e) { } try { $o->setValue(array()); $this->fail(_WT('weeNumberValidator should throw a DomainException when the value is an array.'));
public function __construct(array $aArgs = array()) { array_key_exists('prime', $aArgs) && is_bool($aArgs['prime']) or burn('DomainException', 'The `prime` argument should be a boolean.'); parent::__construct($aArgs); }