function testInputFailure() { $string = '1234'; $object = new stdclass(); $int = 1234; $float = 12.24; $bool = true; try { AssertiveTemplate::input($object, 'string'); $this->assertTrue(false); } catch (Exception $e) { $this->assertTrue(true); } try { AssertiveTemplate::input($int, 'stdclass'); $this->assertTrue(false); } catch (Exception $e) { $this->assertTrue(true); } try { AssertiveTemplate::input($float, 'int'); $this->assertTrue(false); } catch (Exception $e) { $this->assertTrue(true); } try { AssertiveTemplate::input($bool, 'float'); $this->assertTrue(false); } catch (Exception $e) { $this->assertTrue(true); } try { AssertiveTemplate::input($string, 'bool'); $this->assertTrue(false); } catch (Exception $e) { $this->assertTrue(true); } }
<?php AssertiveTemplate::input($title, 'string'); AssertiveTemplate::input($aBlock, 'Block'); AssertiveTemplate::input($max, 'int', 1); echo "{$block}\n"; for ($i = 0; $i < $max; $i++) { echo "{$title}\n"; }
/** * Set the PathFinder to use when looking for Assertive Templates * @param PathFinder $pathFinder */ public static function setPathFinder(PathFinder $pathFinder) { self::$paths = $pathFinder; }
/** * Returns a multi-dimensional array that describes the inputs * of a part. Data available: * array[$inputName]['required'] = boolean * array[$inputName]['type'] = string type representation * * @param string Part name relative to AssertiveTemplate's paths. * @param string Always use 'Part' here. * @returns array Representation of required inputs. */ public static function getInputs($part, $class = 'Part') { return parent::getInputs($part . '.part.php', $class); }