Skip to content

Commit

Permalink
Merge pull request #1947 from vibbow/pr_fix_config_registrar
Browse files Browse the repository at this point in the history
Fix BaseConfig didn't load Registrar files properly
  • Loading branch information
lonnieezell authored Apr 17, 2019
2 parents d2465a8 + 925b8c8 commit 8592ee1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 9 additions & 2 deletions system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 5 additions & 3 deletions tests/system/Config/BaseConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
Expand Down

0 comments on commit 8592ee1

Please sign in to comment.