Skip to content

Commit

Permalink
Merge pull request #14 from matks/allow-multiple-loads
Browse files Browse the repository at this point in the history
Handle multiple loads of same file through PHPConfigurationFileLoader
  • Loading branch information
PierreRambaud authored Mar 4, 2021
2 parents 6d88aba + d79a121 commit e68212a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PHPConfigurationLoader/PHPConfigurationFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(string $filepath)
public function load(): array
{
if ($this->configurationCache === null) {
$this->configurationCache = require_once $this->filepath;
$this->configurationCache = require $this->filepath;
}

return $this->configurationCache;
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPConfigurationLoader/PHPConfigurationFileLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ public function testBadFilepath()

$loader = new PHPConfigurationFileLoader(__DIR__ . '/../Data/a.php');
}

public function testLoadTwiceTheSameFile()
{
$loader1 = new PHPConfigurationFileLoader(__DIR__ . '/../Data/dummyConfigurationFile.php');

$loader2 = new PHPConfigurationFileLoader(__DIR__ . '/../Data/dummyConfigurationFile.php');

$this->assertEquals(['abc'], $loader1->load());
$this->assertEquals(['abc'], $loader2->load());
}
}

0 comments on commit e68212a

Please sign in to comment.