diff --git a/system/Config/BaseConfig.php b/system/Config/BaseConfig.php index 9b1b0be94940..0442e45bb55a 100644 --- a/system/Config/BaseConfig.php +++ b/system/Config/BaseConfig.php @@ -181,8 +181,15 @@ protected function registerProperties() if (! static::$didDiscovery) { - $locator = \Config\Services::locator(); - static::$registrars = $locator->search('Config/Registrar.php'); + $locator = \Config\Services::locator(); + $registrarsFiles = $locator->search('Config/Registrar.php'); + + foreach ($registrarsFiles as $file) + { + $className = $locator->getClassname($file); + static::$registrars[] = new $className(); + } + static::$didDiscovery = true; } diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index ee0616dfbc78..32b551de90de 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -198,8 +198,9 @@ public function testNotEnabled() $modulesConfig = config('Modules'); $modulesConfig->enabled = false; - $config = new \RegistrarConfig(); - $expected = $config::$registrars; + $config = new \RegistrarConfig(); + $config::$registrars = []; + $expected = $config::$registrars; $method = $this->getPrivateMethodInvoker($config, 'registerProperties'); $method(); @@ -212,7 +213,8 @@ public function testDidDiscovery() $modulesConfig = config('Modules'); $modulesConfig->enabled = true; - $config = new \RegistrarConfig(); + $config = new \RegistrarConfig(); + $config::$registrars = []; $this->setPrivateProperty($config, 'didDiscovery', false); $method = $this->getPrivateMethodInvoker($config, 'registerProperties');