Esempio n. 1
0
    public function testGroupsAreReadableIfADefaultEnvIsDefined()
    {
        $masterContent = <<<CONFFILE
[groups]
qa = [ *staging, preprod ]

[variables]
db.pass:
    dev = 1234
    qa = password
    staging = password_staging
    prod = root
CONFFILE;
        $parser = new Parser(new Filesystem(new InMemory(array(self::MASTERFILE_PATH => $masterContent))));
        $parser->enableIncludeSupport()->enableExternalSupport()->enableGroupSupport();
        $variables = $parser->parse(self::MASTERFILE_PATH);
        $reader = new Reader($variables, $parser->getExternalVariables(), $parser->getGroups(), $parser->getDefaultEnvironmentsForGroups());
        $this->assertSame($reader->read('db.pass', 'qa'), $reader->read('db.pass', 'staging'));
    }
Esempio n. 2
0
    public function testDefaultEnvironmentForGroups()
    {
        $masterContent = <<<CONFFILE
[groups]
# comment
qa = [ *staging, preprod ]
dev = [ dev1,  *  dev2,dev3]
 # comment
production=[prod]
CONFFILE;
        $parser = new Parser(new Filesystem(new InMemory(array(self::MASTERFILE_PATH => $masterContent))));
        $parser->enableIncludeSupport()->enableExternalSupport()->enableGroupSupport()->parse(self::MASTERFILE_PATH);
        $groups = $parser->getGroups();
        $expected = array('dev' => array('dev1', 'dev2', 'dev3'), 'qa' => array('staging', 'preprod'), 'production' => array('prod'));
        $this->assertSameArraysExceptOrder($expected, $groups);
        $envs = $parser->getDefaultEnvironmentsForGroups();
        $expected = array('dev' => 'dev2', 'qa' => 'staging', 'production' => null);
        $this->assertSameArraysExceptOrder($expected, $envs);
    }