Enabled phpunit, updates for ab_setup, enabled APC, and other todos
This commit is contained in:
parent
878c159e3a
commit
23247a5d4e
@ -148,4 +148,12 @@ Route::set('default', '(<controller>(/<action>(/<id>)))', array('id' => '[a-zA-Z
|
|||||||
'controller' => 'welcome',
|
'controller' => 'welcome',
|
||||||
'action' => 'index',
|
'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.');
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -15,6 +15,26 @@ class Config extends lnApp_Config {
|
|||||||
public $so;
|
public $so;
|
||||||
public static $no_site_id_tables = array('setup','country','currency','language','tax');
|
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
|
* Load our site configuration from the DB
|
||||||
*
|
*
|
||||||
@ -25,7 +45,7 @@ class Config extends lnApp_Config {
|
|||||||
if ($this->so AND $this->so->loaded())
|
if ($this->so AND $this->so->loaded())
|
||||||
return $this;
|
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())
|
if (! $this->so->loaded())
|
||||||
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
|
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;
|
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() {
|
public static function copywrite() {
|
||||||
return '(c) Open Source Billing Development Team';
|
return '(c) Open Source Billing Development Team';
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,11 @@
|
|||||||
*/
|
*/
|
||||||
class Currency {
|
class Currency {
|
||||||
public static function display($amount) {
|
public static function display($amount) {
|
||||||
// @todo $cid and therefore precision should come from a global session value.
|
return Num::format($amount,Config::instance()->so->decimal_place,TRUE);
|
||||||
return Num::format(Currency::round($amount),2,TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function round($amount) {
|
public static function round($amount) {
|
||||||
// @todo This rounding needs to be system configurable.
|
return Num::round($amount,Config::instance()->so->decimal_place);
|
||||||
return Num::round($amount,2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -22,7 +22,10 @@ abstract class lnApp_Config extends Kohana_Config {
|
|||||||
* NOTE: Kohana doesnt provide a parent construct for the Kohana_Config class.
|
* NOTE: Kohana doesnt provide a parent construct for the Kohana_Config class.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
if (Kohana::$is_cli) {
|
if (defined('PHPUNITTEST'))
|
||||||
|
$_SERVER['SERVER_NAME'] = PHPUNITTEST;
|
||||||
|
|
||||||
|
elseif (Kohana::$is_cli) {
|
||||||
if (! $site = CLI::options('site'))
|
if (! $site = CLI::options('site'))
|
||||||
throw new Kohana_Exception(_('Cant figure out the site, use --site= for CLI'));
|
throw new Kohana_Exception(_('Cant figure out the site, use --site= for CLI'));
|
||||||
else
|
else
|
||||||
@ -116,7 +119,7 @@ abstract class lnApp_Config extends Kohana_Config {
|
|||||||
* Show a date using a site configured format
|
* Show a date using a site configured format
|
||||||
*/
|
*/
|
||||||
public static function datetime($date) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,10 +11,8 @@
|
|||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
return array(
|
return array(
|
||||||
|
'appname' => '',
|
||||||
'cache_type' => 'file',
|
'cache_type' => 'file',
|
||||||
'currency_format' => '2',
|
|
||||||
'date_format' => 'd-M-Y',
|
|
||||||
'time_format' => 'H:i:s',
|
|
||||||
'theme' => '', // @todo This should be in the DB
|
'theme' => '', // @todo This should be in the DB
|
||||||
'email_from' => array('noreply@graytech.net.au'=>'Graytech Hosting'),
|
'email_from' => array('noreply@graytech.net.au'=>'Graytech Hosting'),
|
||||||
'email_admin_only'=> array(
|
'email_admin_only'=> array(
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<span class="text2"> | </span>
|
<span class="text2"> | </span>
|
||||||
<?php echo Config::login_uri(); ?>
|
<?php echo Config::login_uri(); ?>
|
||||||
</div>
|
</div>
|
||||||
<span><?php echo Config::sitename(); ?></span>
|
<span><?php echo Company::name(); ?></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<h1><span> </span> </h1>
|
<h1><span> </span> </h1>
|
||||||
|
@ -14,13 +14,15 @@ $application = 'application';
|
|||||||
*/
|
*/
|
||||||
$modules = 'modules';
|
$modules = 'modules';
|
||||||
|
|
||||||
|
$sysmodules = 'includes/kohana/modules';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The directory in which the Kohana resources are located. The system
|
* The directory in which the Kohana resources are located. The system
|
||||||
* directory must contain the classes/kohana.php file.
|
* directory must contain the classes/kohana.php file.
|
||||||
*
|
*
|
||||||
* @see http://kohanaframework.org/guide/about.install#system
|
* @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
|
* 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;
|
$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
|
// Make the system relative to the docroot
|
||||||
if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
|
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 the absolute paths for configured directories
|
||||||
define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
|
define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
|
||||||
define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
|
define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
|
||||||
|
define('SMDPATH', realpath($sysmodules).DIRECTORY_SEPARATOR);
|
||||||
define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
|
define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// Clean up the configuration vars
|
// Clean up the configuration vars
|
||||||
unset($application, $modules, $system);
|
unset($application, $modules, $sysmodules, $system);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the start time of the application, used for profiling.
|
* 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('KOHANA_START_MEMORY', memory_get_usage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define('PHPUNITTEST','10.1.3.242');
|
||||||
|
|
||||||
// Bootstrap the application
|
// Bootstrap the application
|
||||||
require APPPATH.'bootstrap'.EXT;
|
require APPPATH.'bootstrap'.EXT;
|
||||||
|
|
||||||
// Enable the unittest module
|
// Enable the unittest module
|
||||||
Kohana::modules(Kohana::modules() + array('unittest' => MODPATH.'unittest'));
|
Kohana::modules(Kohana::modules() + array('unittest' => MODPATH.'unittest'));
|
||||||
|
@ -249,7 +249,7 @@ class Kohana_CoreTest extends Unittest_TestCase
|
|||||||
return array(
|
return array(
|
||||||
array(array(), array()),
|
array(array(), array()),
|
||||||
array(array('unittest' => MODPATH.'fo0bar'), 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/'))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user