blob: ed9e7573dcb6d18a2fff54b9c83300cbc5fdaa17 (
plain) (
blame)
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
|
<?php
declare(strict_types=1);
/**
* @author: Alexander Kiryukhin <alexander@kiryukhin.su>
* @license: MIT
*/
use PHPUnit\Framework\TestCase;
/**
* Class CompilerTest
*/
class CompilerTest extends TestCase
{
public function testParseLines()
{
$collection = [
'KEY1' => 'VALUE1',
'KEY2' => '${KEY1} ${KEY3}',
'KEY3' => 'VALUE3',
'KEY4' => 'Test ${KEY2} => ${KEY3}'
];
$tests = [
'KEY1' => 'VALUE1',
'KEY2' => 'VALUE1 VALUE3',
'KEY3' => 'VALUE3',
'KEY4' => 'Test VALUE1 VALUE3 => VALUE3',
];
$compiler = new \NeonXP\Dotenv\Compiler\Compiler();
$collectionOfarrays = [];
foreach ($collection as $key => $value) {
$collectionOfarrays[] = ['key' => $key, 'value' => $value];
}
$compiler->setRawCollection($collectionOfarrays);
foreach ($tests as $key => $expected) {
$result = $compiler->compile(['key' => $key, 'value' => $collection[$key]]);
$this->assertEquals($key, $result['key']);
$this->assertEquals($expected, $result['value']);
}
}
}
|