Commit 39295795b3bd02a545ddab6cb8c6e6f73e391535
1 parent
c1030e88
Add testing support - if the kt_test global variable is set, set up the
testing environment. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5390 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
31 additions
and
6 deletions
config/dmsDefaults.php
| ... | ... | @@ -154,13 +154,15 @@ class KTInit { |
| 154 | 154 | // KTEntity is the database-backed base class |
| 155 | 155 | require_once(KT_LIB_DIR . '/ktentity.inc'); |
| 156 | 156 | |
| 157 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 158 | + | |
| 157 | 159 | $dsn = array( |
| 158 | - 'phptype' => $default->dbType, | |
| 159 | - 'username' => $default->dbUser, | |
| 160 | - 'password' => $default->dbPass, | |
| 161 | - 'hostspec' => $default->dbHost, | |
| 162 | - 'database' => $default->dbName, | |
| 163 | - 'port' => $default->dbPort, | |
| 160 | + 'phptype' => $oKTConfig->get('db/dbType'), | |
| 161 | + 'username' => $oKTConfig->get('db/dbUser'), | |
| 162 | + 'password' => $oKTConfig->get('db/dbPass'), | |
| 163 | + 'hostspec' => $oKTConfig->get('db/dbHost'), | |
| 164 | + 'database' => $oKTConfig->get('db/dbName'), | |
| 165 | + 'port' => $oKTConfig->get('db/dbPort'), | |
| 164 | 166 | ); |
| 165 | 167 | |
| 166 | 168 | $options = array( |
| ... | ... | @@ -457,6 +459,24 @@ class KTInit { |
| 457 | 459 | } |
| 458 | 460 | } |
| 459 | 461 | // }}} |
| 462 | + | |
| 463 | + // {{{ initTesting | |
| 464 | + function initTesting() { | |
| 465 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 466 | + $sConfigFile = trim(@file_get_contents(KT_DIR . "/config/test-config-path")); | |
| 467 | + if (empty($sConfigFile)) { | |
| 468 | + $sConfigFile = 'config/test.ini'; | |
| 469 | + } | |
| 470 | + if (!KTUtil::isAbsolutePath($sConfigFile)) { | |
| 471 | + $sConfigFile = sprintf("%s/%s", KT_DIR, $sConfigFile); | |
| 472 | + } | |
| 473 | + if (!file_exists($sConfigFile)) { | |
| 474 | + $this->handleInitError(PEAR::raiseError('Test infrastructure not configured')); | |
| 475 | + exit(0); | |
| 476 | + } | |
| 477 | + $oKTConfig->loadFile($sConfigFile); | |
| 478 | + } | |
| 479 | + // }}} | |
| 460 | 480 | } |
| 461 | 481 | // }}} |
| 462 | 482 | |
| ... | ... | @@ -464,6 +484,7 @@ $KTInit = new KTInit(); |
| 464 | 484 | |
| 465 | 485 | $KTInit->prependPath(KT_DIR . '/thirdparty/pear'); |
| 466 | 486 | $KTInit->prependPath(KT_DIR . '/thirdparty/Smarty'); |
| 487 | +$KTInit->prependPath(KT_DIR . '/thirdparty/simpletest'); | |
| 467 | 488 | require_once('PEAR.php'); |
| 468 | 489 | |
| 469 | 490 | // Give everyone access to legacy PHP functions |
| ... | ... | @@ -480,6 +501,10 @@ $KTInit->initConfig(); |
| 480 | 501 | |
| 481 | 502 | $KTInit->setupI18n(); |
| 482 | 503 | |
| 504 | +if ($GLOBALS['kt_test']) { | |
| 505 | + $KTInit->initTesting(); | |
| 506 | +} | |
| 507 | + | |
| 483 | 508 | $oKTConfig =& KTConfig::getSingleton(); |
| 484 | 509 | $KTInit->setupServerVariables(); |
| 485 | 510 | ... | ... |