X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=tests%2FConfigTest.php;h=2896d393c55dc481ef5088d090d36a5657b5e4d0;hp=6e14186f51b356cdfbcd0d6a17f4a8342b440d72;hb=c78c33ca9cf6231625c9736383c8dfd504480629;hpb=361e6320e50a8bb1a3ccb675388b8042361669ae diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 6e14186f..2896d393 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -5,33 +5,33 @@ print (basename(__FILE__).": Init...\n"); @chdir(".."); // Load config file -require(dirname(dirname(__FILE__)) . '/inc/config.php'); +require dirname(dirname(__FILE__)) . '/framework/config.php'; // Load all include files -require($cfg->readConfig('base_path') . 'inc/includes.php'); +require $cfg->getConfigEntry('framework_base_path') . 'includes.php'; // Load all game classes -require($cfg->readConfig('base_path') . 'inc/classes.php'); +require $cfg->getConfigEntry('framework_base_path') . 'classes.php'; // Set default application -FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'ship-simu'); +FrameworkConfiguration::getInstance()->setConfigEntry('default_application', 'shipsimu'); // Set testing mode (no starter.php will be loaded!) define('TEST_MODE', true); // Load the PHPUnit framework -require_once('PHPUnit/Framework.php'); +require 'PHPUnit/Framework.php'; print (basename(__FILE__).": Init completed.\n\n"); /** * A test case for the configuration sub system * - * @author Roland Haeder + * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * @see http://www.phpunit.de * * This program is free software: you can redistribute it and/or modify @@ -58,11 +58,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase { // Now try the test $testPassed = false; try { - // Get a configuration instance - $cfg = FrameworkConfiguration::getInstance(); - // Now find a configuration variable that does not exist - $dummy = $cfg->readConfig('does_not_exist'); + $dummy = FrameworkConfiguration::getInstance()->getConfigEntry('does_not_exist'); } catch (ConfigEntryNotFoundException $expected) { // This exception was expected, so it is fine $testPassed = true; @@ -87,11 +84,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase { // Now try the test $testPassed = false; try { - // Get a configuration instance - $cfg = FrameworkConfiguration::getInstance(); - // Try to read an empty configuration variable - $dummy = $cfg->readConfig(""); + $dummy = FrameworkConfiguration::getInstance()->getConfigEntry(''); } catch (ConfigEntryIsEmptyException $expected) { // This exception was expected, so it is fine $testPassed = true; @@ -116,11 +110,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase { // Now try the test $testPassed = false; try { - // Get a configuration instance - $cfg = FrameworkConfiguration::getInstance(); - // Try to read an empty configuration variable - $cfg->setConfigEntry("", 'will_never_be_set'); + FrameworkConfiguration::getInstance()->setConfigEntry('', 'will_never_be_set'); } catch (ConfigEntryIsEmptyException $expected) { // This exception was expected, so it is fine $testPassed = true; @@ -140,18 +131,15 @@ class ConfigTest extends PHPUnit_Framework_TestCase { * * @return void */ - public function testWriteReadConfigEntry () { + public function testWritegetConfigEntryEntry () { // Try it here $value = "This is a test value"; try { - // Get a configuration instance - $cfg = FrameworkConfiguration::getInstance(); - // Try to read an empty configuration variable - $cfg->setConfigEntry('test_key', "{$value}"); + FrameworkConfiguration::getInstance()->setConfigEntry('test_key', "{$value}"); // Read the config entry we have just written - $readValue = $cfg->readConfig('test_key'); + $readValue = FrameworkConfiguration::getInstance()->getConfigEntry('test_key'); // Now test the values $this->assertEquals($value, $readValue); @@ -161,5 +149,3 @@ class ConfigTest extends PHPUnit_Framework_TestCase { } } } - -?>