diff --git a/config.php.in b/config.php.in index 27903c0c..7672661e 100644 --- a/config.php.in +++ b/config.php.in @@ -360,7 +360,7 @@ define('NOW', time()); * normally you don't have to change anything below */ -require_once 'SYSCONFDIR/piler/config-site.php'; +if(file_exists('SYSCONFDIR/piler/config-site.php')) { require_once 'SYSCONFDIR/piler/config-site.php'; } ini_set('session.cookie_lifetime', $config['SESSION_EXPIRY']); diff --git a/webui/system/language.php b/webui/system/language.php index 72332080..f56e2f29 100644 --- a/webui/system/language.php +++ b/webui/system/language.php @@ -12,7 +12,10 @@ class Language { if($session->get("lang")) { $file = DIR_LANGUAGE . $session->get("lang") . '/messages.php'; - define('LANG', $session->get("lang")); + if(defined('LANG')) {} + else { + define('LANG', $session->get("lang")); + } } else { $pref_langs = $this->get_preferred_languages(); diff --git a/webui/tests/EmailTest.php b/webui/tests/EmailTest.php index 1861c439..a1f9199d 100644 --- a/webui/tests/EmailTest.php +++ b/webui/tests/EmailTest.php @@ -2,12 +2,11 @@ use PHPUnit\Framework\TestCase; -define('DIR_BASE', $_ENV['DIR_BASE']); -define('MAX_EMAIL_LEN', 41); - -include_once(DIR_BASE . "system/model.php"); -include_once(DIR_BASE . "model/search/search.php"); - +require_once dirname(dirname(__FILE__)) . '/config.php'; +require_once dirname(dirname(__FILE__)) . '/system/model.php'; +require_once dirname(dirname(__FILE__)) . '/system/loader.php'; +require_once dirname(dirname(__FILE__)) . '/system/language.php'; +require_once dirname(dirname(__FILE__)) . '/system/misc.php'; final class SearchSearchTest extends TestCase { @@ -27,7 +26,15 @@ final class SearchSearchTest extends TestCase { */ public function test_get_boundary($input, $expected_result) { - $result = ModelSearchSearch::fix_email_address_for_sphinx($input); + $loader = new Loader(); + Registry::set('load', $loader); + $language = new Language(); + Registry::set('language', $language); + + $loader->load->model('search/search'); + $m = new ModelSearchSearch(); + + $result = $m->fix_email_address_for_sphinx($input); $this->assertEquals($result, $expected_result); } diff --git a/webui/tests/FormatTest.php b/webui/tests/FormatTest.php index c9714619..6bf3f6b2 100644 --- a/webui/tests/FormatTest.php +++ b/webui/tests/FormatTest.php @@ -2,9 +2,11 @@ use PHPUnit\Framework\TestCase; -include_once("system/model.php"); -include_once("system/misc.php"); -include_once("model/health/health.php"); +require_once dirname(dirname(__FILE__)) . '/config.php'; +require_once dirname(dirname(__FILE__)) . '/system/model.php'; +require_once dirname(dirname(__FILE__)) . '/system/loader.php'; +require_once dirname(dirname(__FILE__)) . '/system/language.php'; +require_once dirname(dirname(__FILE__)) . '/system/misc.php'; final class FormatTest extends TestCase { @@ -22,7 +24,15 @@ final class FormatTest extends TestCase */ public function test_format_time_1($timeval, $expected_result) { - $result = ModelHealthHealth::format_time($timeval); + $loader = new Loader(); + Registry::set('load', $loader); + $language = new Language(); + Registry::set('language', $language); + + $loader->load->model('health/health'); + $m = new ModelHealthHealth(); + + $result = $m->format_time($timeval); $this->assertEquals($result, $expected_result); }