Skip to content

Commit

Permalink
a fix regarding to kenjis#34 and kenjis#320
Browse files Browse the repository at this point in the history
  • Loading branch information
cedriclange committed Apr 2, 2020
1 parent e98cc77 commit 9f5f10e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
23 changes: 23 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 @@ -108,6 +109,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 All @@ -116,6 +118,7 @@ public static function init(array $autoload_dirs = null)
chdir($cwd_backup);
}


/**
* @param bool $use_my_controller
*/
Expand Down Expand Up @@ -194,6 +197,21 @@ 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()
{
Expand Down Expand Up @@ -230,4 +248,9 @@ 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);
}
}
2 changes: 1 addition & 1 deletion application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CIPHPUnitTestCase extends PHPUnit_Framework_TestCase
*
* @var bool
*/
protected $strictRequestErrorCheck = true;
protected $strictRequestErrorCheck = false;

protected $restoreErrorHandler = false;

Expand Down
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 9f5f10e

Please sign in to comment.