* @license PHP License * @package WB * @subpackage unittest */ /** * Unit Test * * TestBaseClass * * @version 0.1.0 * @package WB * @subpackage unittest */ class TestCaseBase_Config extends UnitTestCase { /** * config loader * @var WBConfig */ private $config; /** * config unserializer * @var WBConfig_Unserializer */ private $unser; /** * config serializer * @var WBConfig_Serializer */ private $ser; public function __construct() { WBClass::load('WBUnitTest_SQLUte'); // WBUnitTest_SQLUte::source( __FILE__, 'construct' ); $this->config = WBClass::create('WBConfig'); $this->unser = WBClass::create('WBConfig_Unserializer'); $this->ser = WBClass::create('WBConfig_Serializer'); } /** * destruct * * Remove testing tables */ public function __destruct() { //WBUnitTest_SQLUte::source( __FILE__, 'destruct' ); } public function testClassLoading() { WBClass::load('WBConfig'); $this->assertTrue(class_exists('WBConfig', false)); $this->assertIsA($this->config, 'WBConfig'); $this->assertTrue(class_exists('WBConfig_Loader', false)); $this->assertTrue(class_exists('WBConfig_Loader_File', false)); WBClass::load('WBConfig_Unserializer'); $this->assertTrue(class_exists('WBConfig_Unserializer', false)); $this->assertIsA($this->unser, 'WBConfig_Unserializer'); WBClass::load('WBConfig_Serializer'); $this->assertTrue(class_exists('WBConfig_Serializer', false)); $this->assertIsA($this->ser, 'WBConfig_Serializer'); } public function testLoadconfigTable() { $this->config->setLoader('File'); $this->assertTrue($this->config->load('table', true), 'Could not load config file "table".'); $tmp = $this->config->get(); $this->assertTrue(isset($tmp['obscurecode'])); $this->assertTrue(isset($tmp['user'])); $this->assertTrue(isset($tmp['usergroup'])); $this->assertTrue(isset($tmp['group'])); $tmp = $this->config->get('user'); $this->assertTrue(isset($tmp['primary'])); $tmp = $this->config->get('user/primary'); $this->assertEqual($tmp, 'uid'); } public function testLoaderConfigTable() { $this->config->setLoader('ConfigTable'); $this->assertTrue(class_exists('WBConfig_Loader_ConfigTable', false)); $this->assertFalse($this->config->load('doesnotexist', true), 'Loaded non existing config from config table'); } public function testLoaderFile() { $this->config->setLoader('File'); } } ?>