// Integers $this->isTrue(weeStringValidator::test(0), _WT('weeStringValidator fails to validate the number 0.')); $this->isTrue(weeStringValidator::test(1), _WT('weeStringValidator fails to validate the number 1.')); $this->isTrue(weeStringValidator::test(-1), _WT('weeStringValidator fails to validate the number -1.')); $this->isTrue(weeStringValidator::test(111), _WT('weeStringValidator fails to validate the number 111.')); $this->isTrue(weeStringValidator::test(-111), _WT('weeStringValidator fails to validate the number -111.')); $this->isTrue(weeStringValidator::test(20000000), _WT('weeStringValidator fails to validate the number 20000000.')); // Floats $this->isTrue(weeStringValidator::test(1.0), _WT('weeStringValidator fails to validate the number 1.0.')); $this->isTrue(weeStringValidator::test(1.1), _WT('weeStringValidator fails to validate the number 1.1.')); // Booleans $this->isTrue(weeStringValidator::test(true), _WT('weeStringValidator fails to validate the boolean true.')); $this->isTrue(weeStringValidator::test(false), _WT('weeStringValidator fails to validate the boolean false.')); // Arrays $this->isFalse(weeStringValidator::test(array(1, 2, 3, 'test', false)), _WT('weeStringValidator returns true for an array.')); // Length tests $this->isTrue(weeStringValidator::test('oeuf', array('len' => 4)), _WT('weeStringValidator fails to validate a string of 4 characters when len = 4.')); $this->isFalse(weeStringValidator::test('oeuf', array('len' => 5)), _WT('weeStringValidator returns true for a string of 4 characters when len = 5.')); $this->isFalse(weeStringValidator::test('oeuf', array('len' => 3)), _WT('weeStringValidator returns true for a string of 4 characters when len = 3.')); $this->isTrue(weeStringValidator::test('oeuf', array('min' => 4)), _WT('weeStringValidator fails to validate a string of 4 characters when min = 4.')); $this->isTrue(weeStringValidator::test('oeuf', array('min' => 1)), _WT('weeStringValidator fails to validate a string of 4 characters when min = 1.')); $this->isFalse(weeStringValidator::test('oeuf', array('min' => 10)), _WT('weeStringValidator returns true for a string of 4 characters when min = 10.')); $this->isTrue(weeStringValidator::test('oeuf', array('max' => 4)), _WT('weeStringValidator fails to validate a string of 4 characters when max = 4.')); $this->isFalse(weeStringValidator::test('oeuf', array('max' => 1)), _WT('weeStringValidator returns true for a string of 4 characters when max = 1.')); $this->isTrue(weeStringValidator::test('oeuf', array('max' => 10)), _WT('weeStringValidator fails to validate a string of 4 characters when max = 10.')); // NUL character $this->isFalse(weeStringValidator::test("string possible hack if this string is used to open file, for example"), _WT('weeStringValidator returns true for a string containing null characters.')); // Objects $this->isTrue(weeStringValidator::test(new weeDummyPrintable('42')), _WT('weeStringValidator::test should return true when the value is an instance of Printable which returns a valid string.')); $this->isTrue(weeStringValidator::test(new CastableInput_testStringValidator()), _WT('weeStringValidator::test should return true when the value is an object castable to string which casts to a valid string.'));
<?php weeStringValidator::test($s, array('min' => 1)) or burn('UnexpectedValueException', 'The given string is empty.');