protected function setUp()
    {
        $masterContent = <<<CONFFILE
[externals]
external.conf

[includes]
db.conf

[variables]
logger.level:
    staging = info
    default = warning
CONFFILE;
        $externalContent = <<<CONFFILE
[variables]
# db.conf
pass:
    prod = veryComplexPass
CONFFILE;
        $dbContent = <<<CONFFILE
[variables]
pass:
    dev = 1234
    prod = <external>
    default = root
CONFFILE;
        $files = array(Application::DEFAULT_MASTER_FILE => $masterContent, 'external.conf' => $externalContent, 'db.conf' => $dbContent);
        $parser = new Parser(new Filesystem(new InMemory($files)));
        $parser->enableIncludeSupport()->enableExternalSupport()->parse(Application::DEFAULT_MASTER_FILE);
        $this->provider = new VariableProvider($parser);
    }
Exemple #2
0
    private function initializeParserAndConfFiles()
    {
        $masterContent = <<<CONFFILE
[externals]
external.conf

[includes]
db.conf

[variables]
logger.worker.level:
    staging = info
    default = warning

logger.worker.file:
    default = worker.log

logger.queue.file:
    default = queue.log

logger.debug:
    dev = true
    default = false
CONFFILE;
        $externalContent = <<<CONFFILE
[variables]
# db.conf
pass:
    prod = veryComplexPass
CONFFILE;
        $dbContent = <<<CONFFILE
[variables]
@pass:
    dev = 1234
    prod = <external>
    default = root

host:
    dev = dev-sql
    staging = [stg-sql1, stg-sql2, stg-sql3 ]
CONFFILE;
        $files = array(Application::DEFAULT_MASTER_FILE => $masterContent, 'external.conf' => $externalContent, 'db.conf' => $dbContent);
        $parser = new Parser(new Filesystem(new InMemory($files)));
        $parser->enableIncludeSupport()->enableExternalSupport();
        return $parser;
    }
Exemple #3
0
 private function initializeConfiguration()
 {
     $this['configuration.fileSystem.adapter'] = function ($c) {
         return new Local($c['configuration.path']);
     };
     $this['configuration.fileSystem'] = function ($c) {
         return new Filesystem($c['configuration.fileSystem.adapter']);
     };
     $this['parser'] = $this->share(function ($c) {
         $parser = new Parser($c['configuration.fileSystem']);
         $parser->enableIncludeSupport()->enableExternalSupport()->enableGroupSupport()->setLogger($c['logger'])->parse($c['configuration.masterFile']);
         return $parser;
     });
     $this['configuration'] = $this->share(function ($c) {
         $parser = $c['parser'];
         return new Reader($parser->getVariables(), $parser->getExternalVariables(), $parser->getGroups(), $parser->getDefaultEnvironmentsForGroups());
     });
 }
Exemple #4
0
    public function testGroupsUsageInExternalFile()
    {
        $masterContent = <<<CONFFILE
[externals]
secured.conf

[groups]
qa = [staging]

[variables]
db.pass:
    staging = <external>
    default = fail
CONFFILE;
        $securedContent = <<<CONFFILE
[variables]
db.pass:
    qa = success
CONFFILE;
        $parser = new Parser(new Filesystem(new InMemory(array(self::MASTERFILE_PATH => $masterContent, 'secured.conf' => $securedContent))));
        $parser->enableIncludeSupport()->enableExternalSupport()->enableGroupSupport();
        $variables = $parser->parse(self::MASTERFILE_PATH);
        $reader = new Reader($variables, $parser->getExternalVariables(), $parser->getGroups());
        $this->assertSame('success', $reader->read('db.pass', 'staging'));
    }
Exemple #5
0
    /**
     * @expectedException \RuntimeException
     */
    public function testMultipleDefaultEnvironmentForASameGroup()
    {
        $masterContent = <<<CONFFILE
[groups]
dev = [ dev1, *dev2,*dev3]
CONFFILE;
        $parser = new Parser(new Filesystem(new InMemory(array(self::MASTERFILE_PATH => $masterContent))));
        $parser->enableIncludeSupport()->enableExternalSupport()->enableGroupSupport()->parse(self::MASTERFILE_PATH);
    }