Enabled phpunit, updates for ab_setup, enabled APC, and other todos

This commit is contained in:
Deon George 2012-08-23 20:14:46 +10:00
parent 878c159e3a
commit 23247a5d4e
8 changed files with 53 additions and 27 deletions

View File

@ -148,4 +148,12 @@ Route::set('default', '(<controller>(/<action>(/<id>)))', array('id' => '[a-zA-Z
'controller' => 'welcome',
'action' => 'index',
));
/**
* If APC is enabled, and we need to clear the cache
*/
if (file_exists(APPPATH.'CLEAR_APC_CACHE') AND function_exists('apc_clear_cache') AND ! Kohana::$is_cli) {
if (! apc_clear_cache() OR ! unlink(APPPATH.'CLEAR_APC_CACHE'))
throw new Kohana_Exception('Unable to clear the APC cache.');
}
?>

View File

@ -15,6 +15,26 @@ class Config extends lnApp_Config {
public $so;
public static $no_site_id_tables = array('setup','country','currency','language','tax');
/** Overloaded methods **/
public static function date($date) {
return date(Config::instance()->loadsite()->so->date_format,($date ? $date : time()));
}
public static function siteid($format=FALSE) {
return $format ? sprintf('%02s',Config::instance()->loadsite()->so->id) : Config::instance()->loadsite()->so->id;
}
public static function sitemode() {
return Config::instance()->loadsite()->so->status;
}
public static function time($date) {
return date(Config::instance()->loadsite()->so->time_format,($date ? $date : time()));
}
/** Local Methods **/
/**
* Load our site configuration from the DB
*
@ -25,7 +45,7 @@ class Config extends lnApp_Config {
if ($this->so AND $this->so->loaded())
return $this;
$this->so = ORM::factory('setup',array('nonssl_url'=>URL::base('http')));
$this->so = ORM::factory('setup',array('url'=>URL::base('http')));
if (! $this->so->loaded())
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
@ -55,18 +75,6 @@ class Config extends lnApp_Config {
return array_key_exists($module,static::modules()) ? TRUE : FALSE;
}
public static function sitename() {
return Company::name();
}
public static function siteid($format=FALSE) {
return $format ? sprintf('%02s',Config::instance()->loadsite()->so->id) : Config::instance()->loadsite()->so->id;
}
public static function sitemode() {
return Config::instance()->loadsite()->so->status;
}
public static function copywrite() {
return '(c) Open Source Billing Development Team';
}

View File

@ -11,13 +11,11 @@
*/
class Currency {
public static function display($amount) {
// @todo $cid and therefore precision should come from a global session value.
return Num::format(Currency::round($amount),2,TRUE);
return Num::format($amount,Config::instance()->so->decimal_place,TRUE);
}
public static function round($amount) {
// @todo This rounding needs to be system configurable.
return Num::round($amount,2);
return Num::round($amount,Config::instance()->so->decimal_place);
}
}
?>

View File

@ -22,7 +22,10 @@ abstract class lnApp_Config extends Kohana_Config {
* NOTE: Kohana doesnt provide a parent construct for the Kohana_Config class.
*/
public function __construct() {
if (Kohana::$is_cli) {
if (defined('PHPUNITTEST'))
$_SERVER['SERVER_NAME'] = PHPUNITTEST;
elseif (Kohana::$is_cli) {
if (! $site = CLI::options('site'))
throw new Kohana_Exception(_('Cant figure out the site, use --site= for CLI'));
else
@ -116,7 +119,7 @@ abstract class lnApp_Config extends Kohana_Config {
* Show a date using a site configured format
*/
public static function datetime($date) {
return date(Kohana::config('config.date_format').' '.Kohana::config('config.time_format'),$date);
return sprintf('%s %s',static::date($date),static::time($date));
}
/**

View File

@ -11,10 +11,8 @@
* @license http://dev.osbill.net/license.html
*/
return array(
'appname' => '',
'cache_type' => 'file',
'currency_format' => '2',
'date_format' => 'd-M-Y',
'time_format' => 'H:i:s',
'theme' => '', // @todo This should be in the DB
'email_from' => array('noreply@graytech.net.au'=>'Graytech Hosting'),
'email_admin_only'=> array(

View File

@ -36,7 +36,7 @@
<span class="text2"> &#124; </span>
<?php echo Config::login_uri(); ?>
</div>
<span><?php echo Config::sitename(); ?></span>
<span><?php echo Company::name(); ?></span>
</div>
<div id="header">
<h1><span>&nbsp;</span>&nbsp;</h1>

View File

@ -14,13 +14,15 @@ $application = 'application';
*/
$modules = 'modules';
$sysmodules = 'includes/kohana/modules';
/**
* The directory in which the Kohana resources are located. The system
* directory must contain the classes/kohana.php file.
*
* @see http://kohanaframework.org/guide/about.install#system
*/
$system = 'system';
$system = 'includes/kohana/system';
/**
* The default extension of resource files. If you change this, all resources
@ -67,6 +69,12 @@ if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules))
$modules = DOCROOT.$modules;
}
// Make the system relative to the docroot, for symlink'd index.php
if ( ! is_dir($sysmodules) AND is_dir(DOCROOT.$sysmodules))
{
$sysmodules = DOCROOT.$sysmodules;
}
// Make the system relative to the docroot
if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
{
@ -76,10 +84,11 @@ if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
// Define the absolute paths for configured directories
define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
define('SMDPATH', realpath($sysmodules).DIRECTORY_SEPARATOR);
define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
// Clean up the configuration vars
unset($application, $modules, $system);
unset($application, $modules, $sysmodules, $system);
/**
* Define the start time of the application, used for profiling.
@ -97,8 +106,10 @@ if ( ! defined('KOHANA_START_MEMORY'))
define('KOHANA_START_MEMORY', memory_get_usage());
}
define('PHPUNITTEST','10.1.3.242');
// Bootstrap the application
require APPPATH.'bootstrap'.EXT;
// Enable the unittest module
Kohana::modules(Kohana::modules() + array('unittest' => MODPATH.'unittest'));
Kohana::modules(Kohana::modules() + array('unittest' => MODPATH.'unittest'));

View File

@ -249,7 +249,7 @@ class Kohana_CoreTest extends Unittest_TestCase
return array(
array(array(), array()),
array(array('unittest' => MODPATH.'fo0bar'), array()),
array(array('unittest' => MODPATH.'unittest'), array('unittest' => $this->dirSeparator(MODPATH.'unittest/'))),
array(array('unittest' => SMDPATH.'unittest'), array('unittest' => $this->dirSeparator(SMDPATH.'unittest/'))),
);
}