public function testSecretsAreSharedBetweenInstances()
{
$this->shmockAndDieselify('\\Bart\\Shell', function ($shell) {
// Only called *once*
// The next time it should use static cache
$shell->std_in_secret('What is your social?')->once()->return_value('078-05-1120');
// Let all other methods flow through actual class
});
// do this with a real instance so that we can get confidence
// ...that the $filePath and cache are being used
$this->doStuffWithTempDir(function (BaseTestCase $phpu, $dirName) {
Configuration::configure($dirName);
// Copy sample INI file to path Configuration will look for TestConfig INI
copy(BART_DIR . '/test/etc/conf-parser.conf', $dirName . '/test.conf');
$configs = new TestConfig(false);
$social = $configs->getSocialSecurityNumber();
$this->assertEquals('078-05-1120', $social, 'social');
// Create a new instance
// The secret should be statically cached
$configs2 = new TestConfig(false);
$social2 = $configs2->getSocialSecurityNumber();
$this->assertEquals('078-05-1120', $social2, 'social2');
});
}