Skip to content

Commit

Permalink
Made dummy config class
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Aug 16, 2019
1 parent 64d50e8 commit 1d1706e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
5 changes: 3 additions & 2 deletions public_html/admin/install/classes/installer.class.php
Expand Up @@ -4704,11 +4704,12 @@ private function installEngine($installType, $installStep)
$site_slogan = urldecode($site_slogan);
$site_slogan = $this->cleanString($site_slogan);

require_once $_CONF['path_system'] . 'classes/ConfigInterface.php';
require_once $_CONF['path_system'] . 'classes/config.class.php';
require_once PATH_INSTALL . 'config-install.php';
install_config();

$config = config::get_instance();
install_config($config);

$config->set('site_name', $site_name);
$config->set('site_slogan', $site_slogan);
$config->set('site_url', urldecode($site_url));
Expand Down
7 changes: 4 additions & 3 deletions public_html/admin/install/config-install.php
Expand Up @@ -8,7 +8,7 @@
// | |
// | Initial configuration setup. |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2007-2010 by the following authors: |
// | Copyright (C) 2007-2019 by the following authors: |
// | |
// | Authors: Aaron Blankstein - kantai AT gmail DOT com |
// +---------------------------------------------------------------------------+
Expand All @@ -29,17 +29,18 @@
// | |
// +---------------------------------------------------------------------------+

use Geeklog\ConfigInterface;

if (stripos($_SERVER['PHP_SELF'], basename(__FILE__)) !== false) {
die('This file can not be used on its own!');
}

function install_config()
function install_config(ConfigInterface $c)
{
global $_CONF, $_TABLES;

// Parameters for add function: $param_name, $default_value, $type, $subgroup, $fieldset=null, $selection_array=null, $sort=0, $set=true, $group='Core', $tab=null
$me = 'Core';
$c = config::get_instance();

// Subgroup: Site
$c->add('sg_site', NULL, 'subgroup', 0, 0, NULL, 0, TRUE, $me, 0);
Expand Down
14 changes: 14 additions & 0 deletions system/classes/ConfigInterface.php
@@ -0,0 +1,14 @@
<?php

namespace Geeklog;

/**
* Interface ConfigInterface
* @package Geeklog
*/
interface ConfigInterface
{
public static function get_instance();
public function add($param_name, $default_value, $type, $subgroup, $fieldset = null,
$selection_array = null, $sort = 0, $set = true, $group = 'Core', $tab = null);
}
4 changes: 3 additions & 1 deletion system/classes/config.class.php
Expand Up @@ -31,7 +31,9 @@
// | |
// +---------------------------------------------------------------------------+

class config
use Geeklog\ConfigInterface;

class config implements ConfigInterface
{
/**
* Path to db-config.php file
Expand Down
7 changes: 4 additions & 3 deletions tests/language/langConfValidationTest.php
@@ -1,5 +1,6 @@
<?php

use Geeklog\ConfigInterface;
use \PHPUnit\Framework\TestCase as TestCase;

/**
Expand Down Expand Up @@ -62,13 +63,13 @@ protected function setUp()
$system_timezone = @date_default_timezone_get();
date_default_timezone_set($system_timezone);

$this->c = config::get_instance();
$this->c = DummyConfig::get_instance();

include Tst::$root . 'language/english.php';
include Tst::$public . 'admin/configuration_validation.php';
require_once Tst::$public . 'admin/install/config-install.php';

install_config();
install_config($this->c);
}

/**
Expand Down Expand Up @@ -264,7 +265,7 @@ public function testXMLSitemapPluginLanguages()
*
* This class is a dummy for testing the langConfValidation class
*/
class config
class DummyConfig implements ConfigInterface
{
private $cfg;

Expand Down

0 comments on commit 1d1706e

Please sign in to comment.