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"; }