Example #1
0
 /**
  * @covers \BrightNucleus\Config\Config::__construct
  * @covers \BrightNucleus\Config\Config::resolveOptions
  * @covers \BrightNucleus\Config\Config::configureOptions
  */
 public function testConfigFileWithDefaults()
 {
     $schema = new ConfigSchema(new Config(__DIR__ . '/fixtures/schema_config_file.php'));
     $config = new Config(['negative_integer' => -333], $schema);
     $this->assertTrue($config->hasKey('random_string'));
     $this->assertTrue($config->hasKey('positive_integer'));
     $this->assertTrue($config->hasKey('negative_integer'));
     $this->assertTrue($config->hasKey('positive_boolean'));
     $this->assertFalse($config->hasKey('negative_boolean'));
     $this->assertFalse($config->hasKey('some_other_key'));
     $this->assertEquals('default_test_value', $config->getKey('random_string'));
     $this->assertEquals(99, $config->getKey('positive_integer'));
     $this->assertEquals(-333, $config->getKey('negative_integer'));
     $this->assertTrue($config->getKey('positive_boolean'));
     $this->setExpectedException('BrightNucleus\\Config\\Exception\\KeyNotFoundException', 'The configuration key some_other_key does not exist.');
     $this->assertFalse($config->getKey('some_other_key'));
 }