diff options
author | Александр Кирюхин <alexander@kiryukhin.su> | 2018-01-19 03:13:16 +0300 |
---|---|---|
committer | Александр Кирюхин <alexander@kiryukhin.su> | 2018-01-19 03:13:16 +0300 |
commit | 6f452ea995c25a30f214a530fddc6e9d236bdfce (patch) | |
tree | b6538c4e7bd600f3dd4bcaf0d1340155d95da373 /tests/CompilerTest.php | |
parent | 6b07f5f4ebb3043efc4991debebb14529cb77aa5 (diff) |
Completed reference implementation, added tests
Diffstat (limited to 'tests/CompilerTest.php')
-rw-r--r-- | tests/CompilerTest.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/CompilerTest.php b/tests/CompilerTest.php new file mode 100644 index 0000000..9a820ec --- /dev/null +++ b/tests/CompilerTest.php @@ -0,0 +1,44 @@ +<?php +declare(strict_types=1); + +/** + * @author: Alexander Kiryukhin <alexander@kiryukhin.su> + * @license: MIT + */ + +use NeonXP\Dotenv\Types\KeyValue; +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(); + $collectionOfKeyValues = []; + foreach ($collection as $key => $value) { + $collectionOfKeyValues[] = new KeyValue($key, $value); + } + $compiler->setRawCollection($collectionOfKeyValues); + + foreach ($tests as $key => $expected) { + $result = $compiler->compileKeyValue(new KeyValue($key, $collection[$key])); + $this->assertEquals($key, $result->getKey()); + $this->assertEquals($expected, $result->getValue()); + } + } +}
\ No newline at end of file |