PMASA-2011-1 fixes
[phpmyadmin-themes.git] / test / PMA_isValid_test.php
blobfd561ff5dcfbe89f1a4736938df496a31d472c54
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * tests for PMA_pow()
6 * @version $Id$
7 * @package phpMyAdmin-test
8 */
10 /**
13 require_once 'PHPUnit/Framework.php';
14 require_once './libraries/core.lib.php';
16 /**
17 * @package phpMyAdmin-test
19 class PMA_isValid_test extends PHPUnit_Framework_TestCase
21 public function testVarNotSetAfterTest()
23 PMA_isValid($var);
24 $this->assertFalse(isset($var));
26 public function testNotSet()
28 $this->assertFalse(PMA_isValid($var));
30 public function testEmptyString()
32 $var = '';
33 $this->assertFalse(PMA_isValid($var));
35 public function testNotEmptyString()
37 $var = '0';
38 $this->assertTrue(PMA_isValid($var));
40 public function testZero()
42 $var = 0;
43 $this->assertTrue(PMA_isValid($var));
45 public function testNullFail()
47 $var = null;
48 $this->assertFalse(PMA_isValid($var));
50 public function testNotSetArray()
52 $this->assertFalse(PMA_isValid($array['x']));
54 public function testScalarString()
56 $var = 'string';
57 $this->assertTrue(PMA_isValid($var, 'scalar'));
59 public function testScalarInt()
61 $var = 1;
62 $this->assertTrue(PMA_isValid($var, 'scalar'));
64 public function testScalarFloat()
66 $var = 1.1;
67 $this->assertTrue(PMA_isValid($var, 'scalar'));
69 public function testScalarBool()
71 $var = true;
72 $this->assertTrue(PMA_isValid($var, 'scalar'));
74 public function testNotScalarArray()
76 $var = array('test');
77 $this->assertFalse(PMA_isValid($var, 'scalar'));
79 public function testNotScalarNull()
81 $var = null;
82 $this->assertFalse(PMA_isValid($var, 'scalar'));
84 public function testNumericInt()
86 $var = 1;
87 $this->assertTrue(PMA_isValid($var, 'numeric'));
89 public function testNumericFloat()
91 $var = 1.1;
92 $this->assertTrue(PMA_isValid($var, 'numeric'));
94 public function testNumericZero()
96 $var = 0;
97 $this->assertTrue(PMA_isValid($var, 'numeric'));
99 public function testNumericString()
101 $var = '+0.1';
102 $this->assertTrue(PMA_isValid($var, 'numeric'));
104 public function testValueInArray()
106 $var = 'a';
107 $this->assertTrue(PMA_isValid($var, array('a', 'b', )));
109 public function testValueNotInArray()
111 $var = 'c';
112 $this->assertFalse(PMA_isValid($var, array('a', 'b', )));