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); + } }