forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseConfigTest.php
More file actions
99 lines (68 loc) · 2.29 KB
/
Copy pathBaseConfigTest.php
File metadata and controls
99 lines (68 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php namespace CodeIgniter\Config;
use CodeIgniter\Test\CIUnitTestCase;
class BaseConfigTest extends CIUnitTestCase
{
protected $fixturesFolder;
//--------------------------------------------------------------------
public function setup()
{
$this->fixturesFolder = __DIR__.'/fixtures';
if (! class_exists('SimpleConfig', false))
{
require $this->fixturesFolder.'/SimpleConfig.php';
}
}
//--------------------------------------------------------------------
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');
$dotenv->load();
$config = new \SimpleConfig();
$this->assertEquals('foo', $config->first);
$this->assertEquals('bar', $config->second);
}
//--------------------------------------------------------------------
public function testRecognizesLooseValues()
{
$dotenv = new DotEnv($this->fixturesFolder, 'loose.env');
$dotenv->load();
$config = new \SimpleConfig();
$this->assertEquals(0, $config->QZERO);
$this->assertSame("0", $config->QZEROSTR);
$this->assertEquals(" ", $config->QEMPTYSTR);
$this->assertFalse($config->QFALSE);
}
//--------------------------------------------------------------------
}