Skip to content

Commit 92ba1f6

Browse files
Added more parser escape sequence tests
1 parent 8e75dad commit 92ba1f6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/Dotenv/ParserTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,35 @@ public function testQuotesParse()
1515
$this->assertSame(['FOO', "BAR \n"], Parser::parse("FOO=\"BAR \n\""));
1616
}
1717

18+
public function testNewlineParse()
19+
{
20+
$this->assertSame(['FOO', "\n"], Parser::parse('FOO="\n"'));
21+
}
22+
23+
public function testTabParse()
24+
{
25+
$this->assertSame(['FOO', "\t"], Parser::parse('FOO=\'\t\''));
26+
}
27+
28+
public function testNonEscapeParse1()
29+
{
30+
$this->assertSame(['FOO', '\n\v'], Parser::parse('FOO=\n\v'));
31+
}
32+
33+
public function testNonEscapeParse2()
34+
{
35+
$this->assertSame(['FOO', '\q'], Parser::parse('FOO=\q'));
36+
}
37+
38+
/**
39+
* @expectedException \Dotenv\Exception\InvalidFileException
40+
* @expectedExceptionMessage Failed to parse dotenv file due to an unexpected escape sequence. Failed at ["\q"].
41+
*/
42+
public function testBadEscapeParse()
43+
{
44+
Parser::parse('FOO="\q"');
45+
}
46+
1847
public function testWhitespaceParse()
1948
{
2049
$this->assertSame(['FOO', "\n"], Parser::parse("FOO=\"\n\""));

0 commit comments

Comments
 (0)