Skip to content

Commit

Permalink
Merge pull request #16172 from niden/T16171-config-insensitive
Browse files Browse the repository at this point in the history
T16171 config insensitive
  • Loading branch information
niden authored Oct 19, 2022
2 parents 7575519 + 2ae6c6a commit ab001b7
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [5.0.5](https://github.com/phalcon/cphalcon/releases/tag/v5.0.5) (xxxx-xx-xx)

## Fixed
- Fixed `Phalcon\Config\Config::setData` to pass the `insensitive` flag to child objects [#16171](https://github.com/phalcon/cphalcon/issues/16171)
- Fixed `Phalcon\Config\Adapter\Groupped::__construct` to pass the `insensitive` flag to child objects [#16171](https://github.com/phalcon/cphalcon/issues/16171)

# [5.0.4](https://github.com/phalcon/cphalcon/releases/tag/v5.0.4) (2022-10-17)

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Config/Adapter/Grouped.zep
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Grouped extends Config
}

let configArray = configInstance["config"],
configInstance = new Config(configArray);
configInstance = new Config(configArray, this->insensitive);
} else {
let configInstance = (new ConfigFactory())->load(configInstance);
}
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Config/Config.zep
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class Config extends Collection implements ConfigInterface
let this->lowerKeys[key] = element;

if typeof value === "array" {
let data[element] = new Config(value);
let data[element] = new Config(value, this->insensitive);
} else {
let data[element] = value;
}
Expand Down
38 changes: 38 additions & 0 deletions tests/unit/Config/Config/ConfigCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,42 @@ public function testStandardConfigSimpleArray(UnitTester $I)
$actual = new Config($settings);
$I->assertEquals($expected, $actual);
}

/**
* Test insensitive in sub arrays
*
* @param UnitTester $I
*
* @return void
*
* @issue 16171
* @author Phalcon Team <team@phalcon.io>
* @since 2022-10-19
*/
public function configConfigConfigInsensitive(UnitTester $I)
{
$settings = [
'database' => [
'adapter' => 'Mysql',
'host' => 'localhost',
'username' => 'scott',
'password' => 'cheetah',
'name' => 'test_db',
],
'other' => [1, 2, 3, 4],
];
$config = new Config($settings, false);

/** @var Config $database */
$database = $config->get('database');

$class = Config::class;
$I->assertInstanceOf($class, $database);

$actual = $database->has('adapter');
$I->assertTrue($actual);

$actual = $database->has('ADAPTER');
$I->assertFalse($actual);
}
}

0 comments on commit ab001b7

Please sign in to comment.