mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Better tests for BaseConfig
This commit is contained in:
parent
3449ccaa98
commit
7110d9f866
@ -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');
|
||||
|
@ -2,4 +2,8 @@ FOO=bar
|
||||
BAR=baz
|
||||
SPACED="with spaces"
|
||||
|
||||
NULL=
|
||||
NULL=
|
||||
|
||||
SimpleConfig.onedeep=baz
|
||||
SimpleConfig.default.name=ci4
|
||||
simple.name=simpleton
|
@ -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
|
||||
];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user