Better tests for BaseConfig

This commit is contained in:
Lonnie Ezell 2016-06-01 21:48:20 -05:00
parent 3449ccaa98
commit 7110d9f866
3 changed files with 64 additions and 1 deletions

View File

@ -20,6 +20,54 @@ class BaseConfigTest extends CIUnitTestCase
//--------------------------------------------------------------------
public function testBasicValues()
{
$dotenv = new DotEnv($this->fixturesFolder, '.env');
$dotenv->load();
$config = new \SimpleConfig();
$this->assertEquals('bar', $config->FOO);
}
//--------------------------------------------------------------------
public function testPrefixedValues()
{
$dotenv = new DotEnv($this->fixturesFolder, '.env');
$dotenv->load();
$config = new \SimpleConfig();
$this->assertEquals('baz', $config->onedeep);
}
//--------------------------------------------------------------------
public function testPrefixedArrayValues()
{
$dotenv = new DotEnv($this->fixturesFolder, '.env');
$dotenv->load();
$config = new \SimpleConfig();
$this->assertEquals('ci4', $config->default['name']);
}
//--------------------------------------------------------------------
public function testArrayValues()
{
$dotenv = new DotEnv($this->fixturesFolder, '.env');
$dotenv->load();
$config = new \SimpleConfig();
$this->assertEquals('simpleton', $config->simple['name']);
}
//--------------------------------------------------------------------
public function testSetsDefaultValues()
{
$dotenv = new DotEnv($this->fixturesFolder, 'commented.env');

View File

@ -3,3 +3,7 @@ BAR=baz
SPACED="with spaces"
NULL=
SimpleConfig.onedeep=baz
SimpleConfig.default.name=ci4
simple.name=simpleton

View File

@ -9,4 +9,15 @@ class SimpleConfig extends \CodeIgniter\Config\BaseConfig
public $first = 'foo';
public $second = 'bar';
public $FOO;
public $onedeep;
public $default = [
'name' => null
];
public $simple = [
'name' => null
];
}