From 9f5f10ed5576995dfa620d55012610016a3dd131 Mon Sep 17 00:00:00 2001 From: CEDRIC MATASO Date: Thu, 2 Apr 2020 21:37:08 +0200 Subject: [PATCH] a fix regarding to #34 and #320 --- .../tests/_ci_phpunit_test/CIPHPUnitTest.php | 23 +++++++++++++++++++ .../_ci_phpunit_test/CIPHPUnitTestCase.php | 2 +- .../tests/_ci_phpunit_test/functions.php | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/application/tests/_ci_phpunit_test/CIPHPUnitTest.php b/application/tests/_ci_phpunit_test/CIPHPUnitTest.php index fed6963c..79480777 100644 --- a/application/tests/_ci_phpunit_test/CIPHPUnitTest.php +++ b/application/tests/_ci_phpunit_test/CIPHPUnitTest.php @@ -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; @@ -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; @@ -116,6 +118,7 @@ public static function init(array $autoload_dirs = null) chdir($cwd_backup); } + /** * @param bool $use_my_controller */ @@ -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() { @@ -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); + } } diff --git a/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php b/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php index ec484e70..508862fd 100644 --- a/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php +++ b/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php @@ -36,7 +36,7 @@ class CIPHPUnitTestCase extends PHPUnit_Framework_TestCase * * @var bool */ - protected $strictRequestErrorCheck = true; + protected $strictRequestErrorCheck = false; protected $restoreErrorHandler = false; diff --git a/application/tests/_ci_phpunit_test/functions.php b/application/tests/_ci_phpunit_test/functions.php index f44fb2ad..f6d861f7 100644 --- a/application/tests/_ci_phpunit_test/functions.php +++ b/application/tests/_ci_phpunit_test/functions.php @@ -74,6 +74,7 @@ function reset_instance() CIPHPUnitTestSuperGlobal::set_Global('LANG', $LANG); CIPHPUnitTest::loadLoader(); + CIPHPUnitTest::loadConfig(); // Remove CodeIgniter instance $CI = new CIPHPUnitTestNullCodeIgniter();