From b16712ec45a020df22ee9b059757f48081cf9bd1 Mon Sep 17 00:00:00 2001 From: Jim DeLois Date: Tue, 14 Jun 2016 14:46:04 -0400 Subject: [PATCH] Bugfix: Initializing the Configuration's `Mappers` Property Resolves improvframework/configuration#7 --- src/Configuration.php | 2 +- tests/unit/ConfigurationTest.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Configuration.php b/src/Configuration.php index 467e197..aa1c76c 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -26,7 +26,7 @@ class Configuration /** * @var Mapper[] */ - private $mappers; + private $mappers = []; /** * @param array $config diff --git a/tests/unit/ConfigurationTest.php b/tests/unit/ConfigurationTest.php index 61dae9b..be8ed0c 100644 --- a/tests/unit/ConfigurationTest.php +++ b/tests/unit/ConfigurationTest.php @@ -129,7 +129,7 @@ public function mappingValues() /** * @test */ - public function withPrefix() + public function withPrefixWithMappers() { $data = [ 'OUTER_PREFIX_ONE' => 'One', @@ -161,4 +161,19 @@ public function withPrefix() $sut->get('THING'); } + + /** + * @test + * @see https://github.com/improvframework/configuration/issues/7 + */ + public function withPrefixWithoutMappers() + { + $data = [ 'OUTER_PREFIX_ONE' => 'One' ]; + + // This call would raise an error as per: + // https://github.com/improvframework/configuration/issues/7 + $sut = (new Configuration($data, 'OUTER_'))->withPrefix('PREFIX_'); + + self::assertInstanceOf(Configuration::class, $sut); + } }