added some test for PMA_isValid

This commit is contained in:
Sebastian Mendel
2007-03-21 16:52:15 +00:00
parent dd5d1163b1
commit 758c0b5d03
2 changed files with 104 additions and 0 deletions

View File

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

102
test/PMA_isValid_test.php Normal file
View File

@@ -0,0 +1,102 @@
<?php
/* vim: expandtab sw=4 ts=4 sts=4: */
/**
* tests for PMA_pow()
*
* @version $Id: PMA_pow_test.php 10140 2007-03-20 08:32:55Z cybot_tm $
* @package phpMyAdmin-test
*/
/**
*
*/
require_once 'PHPUnit/Framework.php';
require_once './libraries/core.lib.php';
class PMA_isValid_test extends PHPUnit_Framework_TestCase
{
public function testVarNotSetAfterTest()
{
PMA_isValid($var);
$this->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');
}
}
?>