Skip to content

Commit

Permalink
Merge pull request #8 from jimdelois/bugfix-empty-mappers-invalid-arg…
Browse files Browse the repository at this point in the history
…ument

Bugfix: Initializing the Configuration's `Mappers` Property
  • Loading branch information
jimdelois committed Jun 14, 2016
2 parents 7b134ce + b16712e commit 0e17b4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Configuration
/**
* @var Mapper[]
*/
private $mappers;
private $mappers = [];

/**
* @param array $config
Expand Down
17 changes: 16 additions & 1 deletion tests/unit/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function mappingValues()
/**
* @test
*/
public function withPrefix()
public function withPrefixWithMappers()
{
$data = [
'OUTER_PREFIX_ONE' => 'One',
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 0e17b4e

Please sign in to comment.