-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFileWriterConfigTest.php
53 lines (48 loc) · 1.3 KB
/
FileWriterConfigTest.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
<?php
namespace Gt\Config\Test;
use Gt\Config\Config;
use Gt\Config\ConfigSection;
use Gt\Config\FileWriter;
use Gt\Config\Test\Helper\Helper;
class FileWriterConfigTest extends ConfigTestCase {
public function testWrite():void {
$sectionValues = [
"one" => [
"firstKeyOfOne" => "value",
"secondKeyOfOne" => "another-value",
],
"two" => [
"firstKeyOfTwo" => 12345,
"secondKeyOfTwo" => true,
],
"three" => [
"fk-of-3" => "this?has!weird charac~'#ters",
"sk-of-3" => false,
]
];
$sectionOne = new ConfigSection("one", $sectionValues["one"]);
$sectionTwo = new ConfigSection("two", $sectionValues["two"]);
$sectionThree = new ConfigSection("three", $sectionValues["three"]);
$config = self::createMock(Config::class);
$config->method("getSectionNames")
->willReturn(array_keys($sectionValues));
$config->method("getSection")
->willReturn(
$sectionOne,
$sectionTwo,
$sectionThree
);
$writer = new FileWriter($config);
$tmpFilePath = Helper::getTmpDir("output.ini");
$writer->writeIni($tmpFilePath);
$parsedData = parse_ini_file($tmpFilePath, true);
foreach($sectionValues as $sectionName => $section) {
foreach($section as $key => $value) {
self::assertEquals(
$value,
$parsedData[$sectionName][$key]
);
}
}
}
}