diff --git a/test/AllTests.php b/test/AllTests.php index 51c3599f1..83dec0ce6 100644 --- a/test/AllTests.php +++ b/test/AllTests.php @@ -27,6 +27,7 @@ require_once './test/PMA_sanitize_test.php'; require_once './test/PMA_pow_test.php'; require_once './test/Environment_test.php'; require_once './test/escape_js_string.php'; +require_once './test/PMA_isValid_test.php'; class AllTests { @@ -49,6 +50,7 @@ class AllTests $suite->addTestSuite('PMA_sanitize_test'); $suite->addTestSuite('PMA_pow_test'); $suite->addTestSuite('PMA_escapeJsString_test'); + $suite->addTestSuite('PMA_isValid_test'); return $suite; } } diff --git a/test/PMA_isValid_test.php b/test/PMA_isValid_test.php new file mode 100644 index 000000000..80f910be8 --- /dev/null +++ b/test/PMA_isValid_test.php @@ -0,0 +1,102 @@ +assertFalse(isset($var)); + } + public function testNotSet() + { + $this->assertFalse(PMA_isValid($var)); + } + public function testEmptyString() + { + $var = ''; + $this->assertFalse(PMA_isValid($var)); + } + public function testNotEmptyString() + { + $var = '0'; + $this->assertTrue(PMA_isValid($var)); + } + public function testZero() + { + $var = 0; + $this->assertTrue(PMA_isValid($var)); + } + public function testNullFail() + { + $var = null; + $this->assertFalse(PMA_isValid($var)); + } + public function testNotSetArray() + { + $this->assertFalse(PMA_isValid($array['x'])); + } + public function testScalarString() + { + $var = 'string'; + $this->assertTrue(PMA_isValid($var, 'scalar')); + } + public function testScalarInt() + { + $var = 1; + $this->assertTrue(PMA_isValid($var, 'scalar')); + } + public function testScalarFloat() + { + $var = 1.1; + $this->assertTrue(PMA_isValid($var, 'scalar')); + } + public function testScalarBool() + { + $var = true; + $this->assertTrue(PMA_isValid($var, 'scalar')); + } + public function testNotScalarArray() + { + $var = array('test'); + $this->assertFalse(PMA_isValid($var), 'scalar'); + } + public function testNotScalarNull() + { + $var = null; + $this->assertFalse(PMA_isValid($var), 'scalar'); + } + public function testNumericInt() + { + $var = 1; + $this->assertTrue(PMA_isValid($var), 'numeric'); + } + public function testNumericFloat() + { + $var = 1.1; + $this->assertTrue(PMA_isValid($var), 'numeric'); + } + public function testNumericZero() + { + $var = 0; + $this->assertTrue(PMA_isValid($var), 'numeric'); + } + public function testNumericString() + { + $var = '+0.1'; + $this->assertTrue(PMA_isValid($var), 'numeric'); + } +} +?> \ No newline at end of file