Files
majestic/tests/ConfigTest.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2011-10-06 13:10:48 +04:00
<?php
/*
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage UnitTests
* @since 2011-10-06
*
* Unit tests for Config class
*/
2011-10-06 18:04:05 +04:00
require_once dirname(__FILE__) . '/../Registry.php';
require_once dirname(__FILE__) . '/../Config.php';
2011-11-25 19:50:41 +04:00
require_once dirname(__FILE__) . '/../exception/GeneralException.php';
2011-10-06 13:10:48 +04:00
class ConfigTest extends PHPUnit_Framework_TestCase
{
2011-10-29 15:39:19 +04:00
2011-10-06 13:10:48 +04:00
private $_instance = null;
2011-10-29 15:39:19 +04:00
2011-10-06 13:10:48 +04:00
public function setUp()
{
$this->_instance = Config::getInstance();
}
2011-10-29 15:39:19 +04:00
2011-10-06 13:10:48 +04:00
public function testGetInstance()
{
$this->assertSame($this->_instance, Config::getInstance());
2011-10-29 15:39:19 +04:00
2011-10-06 13:10:48 +04:00
/**
2011-10-06 16:33:50 +04:00
* @TODO: Config - class does not instanciate, Registry instead!!! Use late static binding
2011-10-06 13:10:48 +04:00
*/
$this->assertNotEquals('Config', get_class(Config::getInstance()));
}
2011-10-29 15:39:19 +04:00
2011-10-06 13:10:48 +04:00
public function testArrayAsParam()
{
$arr = array(
2011-10-29 15:39:19 +04:00
'one' => 1,
'two' => 2,
'three' => 3,
4 => 'four'
);
2011-10-06 13:10:48 +04:00
Config::set(0, $arr);
$new_arr = Config::get(0);
$this->assertSame('ConfigArray', get_class($new_arr));
$this->assertSame('four', $new_arr->offsetGet(4));
$this->assertSame(1, $new_arr->one);
2011-10-29 15:39:19 +04:00
$this->assertNotEquals(1, $new_arr->offsetGet('two'));
2011-12-02 12:25:47 +04:00
$this->setExpectedException('GeneralException', 'Configuration variable');
$new_arr->some;
2011-10-06 13:10:48 +04:00
}
2011-10-29 15:39:19 +04:00
2011-10-06 13:10:48 +04:00
}