Added unittest for PMA_ifSetOr()

This commit is contained in:
Herman van Rink
2009-10-16 08:10:26 +00:00
parent a38d4ff355
commit b55c48b8d8
2 changed files with 50 additions and 1 deletions

View File

@@ -30,7 +30,6 @@
* echo PMA_ifSetOr($cfg['ForceSSL'], false, 'boolean'); // true * echo PMA_ifSetOr($cfg['ForceSSL'], false, 'boolean'); // true
* </code> * </code>
* *
* @todo create some testsuites
* @uses PMA_isValid() * @uses PMA_isValid()
* @see PMA_isValid() * @see PMA_isValid()
* @param mixed $var param to check * @param mixed $var param to check

50
test/PMA_ifSetOr_test.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for PMA_ifSetOr()
*
* @version $Id$
* @package phpMyAdmin-test
*/
/**
*
*/
require_once 'PHPUnit/Framework.php';
require_once './libraries/core.lib.php';
/**
* @package phpMyAdmin-test
*/
class PMA_ifSetOr_test extends PHPUnit_Framework_TestCase
{
public function testVarSet()
{
$default = 'foo';
$in = 'bar';
$out = PMA_ifSetOr($in, $default);
$this->assertEquals($in, $out);
}
public function testVarSetWrongType()
{
$default = 'foo';
$in = 'bar';
$out = PMA_ifSetOr($in, $default, 'boolean');
$this->assertEquals($out, $default);
}
public function testVarNotSet()
{
$default = 'foo';
// $in is not set!
$out = PMA_ifSetOr($in, $default);
$this->assertEquals($out, $default);
}
public function testVarNotSetNoDefault()
{
// $in is not set!
$out = PMA_ifSetOr($in);
$this->assertEquals($out, null);
}
}
?>