From 23247a5d4e5265650937907b654c011efe4b0764 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 23 Aug 2012 20:14:46 +1000 Subject: [PATCH] Enabled phpunit, updates for ab_setup, enabled APC, and other todos --- application/bootstrap.php | 8 +++++ application/classes/config.php | 34 ++++++++++++------- application/classes/currency.php | 6 ++-- application/classes/lnapp/config.php | 7 ++-- application/config/config.php | 4 +-- application/views/yaml/page.php | 2 +- .../kohana/modules/unittest/bootstrap.php | 17 ++++++++-- .../kohana/system/tests/kohana/CoreTest.php | 2 +- 8 files changed, 53 insertions(+), 27 deletions(-) diff --git a/application/bootstrap.php b/application/bootstrap.php index a19eaff7..de02b7d5 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -148,4 +148,12 @@ Route::set('default', '((/(/)))', 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.'); +} ?> diff --git a/application/classes/config.php b/application/classes/config.php index d75320a7..7521eda4 100644 --- a/application/classes/config.php +++ b/application/classes/config.php @@ -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'; } diff --git a/application/classes/currency.php b/application/classes/currency.php index a3a9153f..73db2391 100644 --- a/application/classes/currency.php +++ b/application/classes/currency.php @@ -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); } } ?> diff --git a/application/classes/lnapp/config.php b/application/classes/lnapp/config.php index c3e46550..36b68fbd 100644 --- a/application/classes/lnapp/config.php +++ b/application/classes/lnapp/config.php @@ -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)); } /** diff --git a/application/config/config.php b/application/config/config.php index 76934912..c6292f4c 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -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( diff --git a/application/views/yaml/page.php b/application/views/yaml/page.php index a4c1ab45..b6254f3e 100644 --- a/application/views/yaml/page.php +++ b/application/views/yaml/page.php @@ -36,7 +36,7 @@ | - +