-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathConfigFactoryConfigTest.php
55 lines (47 loc) · 1.71 KB
/
ConfigFactoryConfigTest.php
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
<?php
namespace Gt\Config\Test;
use Gt\Config\ConfigFactory;
use Gt\Config\Test\Helper\Helper;
class ConfigFactoryConfigTest extends ConfigTestCase {
public function testCreateForProject():void {
$filePath = implode(DIRECTORY_SEPARATOR, [
$this->tmp,
"config.ini",
]);
$filePathDefault = implode(DIRECTORY_SEPARATOR, [
$this->tmp,
"config.default.ini",
]);
$filePathDev = implode(DIRECTORY_SEPARATOR, [
$this->tmp,
"config.dev.ini",
]);
$filePathProduction = implode(DIRECTORY_SEPARATOR, [
$this->tmp,
"config.production.ini",
]);
file_put_contents($filePathDefault, Helper::INI_DEFAULT);
file_put_contents($filePath, Helper::INI_SIMPLE);
file_put_contents($filePathDev, Helper::INI_OVERRIDE_DEV);
file_put_contents($filePathProduction, Helper::INI_OVERRIDE_PROD);
$config = ConfigFactory::createForProject($this->tmp);
self::assertEquals("ExampleApp", $config->get("app.namespace"));
self::assertEquals("dev789override", $config->get("block1.value.nested"));
self::assertEquals("this appears by default", $config->get("block1.value.existsByDefault"));
self::assertEquals("my.production.database", $config->get("database.host"));
self::assertEquals("example", $config->get("database.schema"));
}
public function testCreateFromPathName():void {
$filePath = implode(DIRECTORY_SEPARATOR, [
$this->tmp,
"config.ini",
]);
file_put_contents($filePath, Helper::INI_SIMPLE);
$config = ConfigFactory::createFromPathName($filePath);
$sectionNames = $config->getSectionNames();
self::assertContains("app", $sectionNames);
self::assertContains("block1", $sectionNames);
self::assertContains("database", $sectionNames);
self::assertNotContains("extra", $sectionNames);
}
}