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/ParserTest.php | |
parent | 6b07f5f4ebb3043efc4991debebb14529cb77aa5 (diff) |
Completed reference implementation, added tests
Diffstat (limited to 'tests/ParserTest.php')
-rw-r--r-- | tests/ParserTest.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/ParserTest.php b/tests/ParserTest.php new file mode 100644 index 0000000..9f13261 --- /dev/null +++ b/tests/ParserTest.php @@ -0,0 +1,37 @@ +<?php +declare(strict_types=1); + +/** + * @author: Alexander Kiryukhin <alexander@kiryukhin.su> + * @license: MIT + */ +use NeonXP\Dotenv\Parser\Parser; +use PHPUnit\Framework\TestCase; + +/** + * Class ParserTest + */ +class ParserTest extends TestCase +{ + public function testParseLines() + { + $tests = [ + "key1='value1' # comment" => ['key1', 'value1'], + "key2 = 'value2'" => ['key2', 'value2'], + "key3 = \"value3\" # comment" => ['key3', 'value3'], + "key4 =\"value4\"" => ['key4', 'value4'], + "key5 ='value5 # not comment'" => ['key5', 'value5 # not comment'], + "key6 = \"value6 # not comment\"" => ['key6', 'value6 # not comment'], + "boolean=true" => ['boolean', true], + "numeric = 123" => ['numeric', 123] + ]; + + $parser = new Parser(); + + foreach ($tests as $test => $expected) { + $result = $parser->parseLine($test); + $this->assertEquals($expected[0], $result->getKey()); + $this->assertEquals($expected[1], $result->getValue()); + } + } +}
\ No newline at end of file |