Skip to content

Commit

Permalink
Merge branch 'cedriclange-master'
Browse files Browse the repository at this point in the history
See #327
  • Loading branch information
kenjis committed Apr 12, 2020
1 parent eb79054 commit d602561
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions application/tests/_ci_phpunit_test/CIPHPUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class CIPHPUnitTest
{
private static $loader_class = 'CI_Loader';
private static $config_class = 'CI_Config';
private static $controller_class;
private static $autoload_dirs;

Expand Down Expand Up @@ -98,6 +99,7 @@ public static function init(array $autoload_dirs = null)

// This code is here, not to cause errors with HMVC
self::replaceLoader();
self::replaceConfig();

// Restore $_SERVER. We need this for NetBeans
$_SERVER = $_server_backup;
Expand Down Expand Up @@ -185,6 +187,22 @@ protected static function replaceLoader()
self::loadLoader();
}

protected static function replaceConfig()
{
$my_config_file =
APPPATH . 'core/' . config_item('subclass_prefix') . 'Config.php';

if (file_exists($my_config_file))
{
self::$config_class = config_item('subclass_prefix') . 'Config';
if ( ! class_exists(self::$config_class))
{
require $my_config_file;
}
}
self::loadConfig();
}

protected static function replaceHelpers()
{
$helpers = ['url_helper', 'download_helper'];
Expand Down Expand Up @@ -220,4 +238,10 @@ public static function loadLoader()
$loader = new self::$loader_class;
load_class_instance('Loader', $loader);
}

public static function loadConfig()
{
$config= new self::$config_class;
load_class_instance('Config', $config);
}
}
1 change: 1 addition & 0 deletions application/tests/_ci_phpunit_test/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function reset_instance()
CIPHPUnitTestSuperGlobal::set_Global('LANG', $LANG);

CIPHPUnitTest::loadLoader();
CIPHPUnitTest::loadConfig();

// Remove CodeIgniter instance
$CI = new CIPHPUnitTestNullCodeIgniter();
Expand Down

0 comments on commit d602561

Please sign in to comment.