示例#1
0
 public function testLoadFileConstructEnv()
 {
     putenv('TESTVAR1=constructTestValue1');
     putenv('TESTVAR2=constructTestValue2');
     putenv('API_SERVICE_HOST=apihost');
     putenv('API_SERVICE_PORT=8080');
     $file = dirname(__DIR__) . '/testData/envtest.ini';
     $provider = new \Packaged\Config\Provider\Ini\IniConfigProvider($file, true);
     $this->assertEquals('constructTestValue1', $provider->getItem('default', 'var1'));
     $this->assertEquals('constructTestValue2', $provider->getItem('default', 'var2'));
     $this->assertEquals('constructTestValue1-constructTestValue2', $provider->getItem('default', 'var1and2'));
     $this->assertEquals('defaultValue', $provider->getItem('default', 'nonexistentDefault'));
     $this->assertEquals('', $provider->getItem('default', 'nonexistentNoDefault'));
     $this->assertEquals('http://apihost:8080', $provider->getItem('default', 'api'));
 }