<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Tests :: NitroSettings |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2003-2006 June Systems BV |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it |
// | under the terms of the GNU Lesser General Public License as published by |
// | the Free Software Foundation; either version 2.1 of the License, or (at |
// | your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public License |
// | along with this library; if not, write to the Free Software Foundation, |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
// +---------------------------------------------------------------------------+
// | Authors: Jesper Avot <hide@address.com> |
// +---------------------------------------------------------------------------+
//
// $Id: NitroSettings.inc.php 229 2008-04-17 09:20:31Z oli $
//
/**
* Set error_reporting
*/
error_reporting(E_ALL & ~E_NOTICE);
/**
* Include required files
*/
require_once NITRO_ROOT.'Nitro/NitroSettings.inc.php';
/**
* NitroSettings TestCase
*/
class NitroSettings_Test extends Nitro_TestCase {
function NitroSettings_Test($Name = "NitroSettings_Test")
{
parent::Nitro_TestCase($Name);
}
function setUp()
{
$this->NitroSettings = new NitroSettings();
$this->NitroSettings->Settings = array();
}
function test_GetSettingsDefinition()
{
$this->AssertEquals(array(), $this->NitroSettings->GetSettingsDefinition());
}
function test_GetSettingsFromDefinition()
{
$this->AssertEquals(FALSE, $this->NitroSettings->GetSettingsFromDefinition(''));
$this->AssertEquals(array(), $this->NitroSettings->GetSettingsFromDefinition(array()));
}
function test_GetSettingsFromDefinition_1()
{
$expected = array(
'P' => FALSE,
'A' => FALSE
);
$actual = array(
'P' => array('SessionVariable' => FALSE, 'FormVariable' => 'Fake', 'Default' => FALSE),
'A' => array('SessionVariable' => FALSE, 'FormVariable' => 'Fake2', 'Default' => FALSE)
);
$this->AssertEquals($expected, $this->NitroSettings->GetSettingsFromDefinition($actual));
}
function test_GetSettingsFromDefinition_2()
{
$expected = array(
'P' => $_REQUEST['P'],
'A' => $_REQUEST['A']
);
$actual = array(
'P' => array('SessionVariable' => FALSE, 'FormVariable' => 'P', 'Default' => FALSE),
'A' => array('SessionVariable' => FALSE, 'FormVariable' => 'A', 'Default' => FALSE)
);
$this->AssertEquals($expected, $this->NitroSettings->GetSettingsFromDefinition($actual));
}
function test_GetSettings()
{
$this->AssertEquals(array(), $this->NitroSettings->GetSettings());
}
}
?>