|
11 | 11 | class ComposerTest extends TestCase |
12 | 12 | { |
13 | 13 |
|
| 14 | + private Composer $composer; |
| 15 | + |
| 16 | + protected function setUp(): void |
| 17 | + { |
| 18 | + parent::setUp(); |
| 19 | + |
| 20 | + $this->composer = new Composer(); |
| 21 | + } |
| 22 | + |
14 | 23 | public function testCompose(): void |
15 | 24 | { |
16 | | - $composer = new Composer(); |
17 | 25 | $file = new EnvFile(); |
18 | 26 |
|
19 | 27 | $file->blocks[] = new CommentBlock("test1"); |
20 | 28 | $file->blocks[] = new CommentBlock("test2"); |
21 | 29 |
|
22 | | - $result = $composer->compose($file); |
| 30 | + $result = $this->composer->compose($file); |
23 | 31 | $this->assertEquals("#test1\n#test2", $result); |
24 | 32 | } |
25 | 33 |
|
26 | 34 | public function testEOL(): void |
27 | 35 | { |
28 | | - $composer = new Composer(); |
29 | 36 | $file = new EnvFile(); |
30 | 37 |
|
31 | 38 | $file->blocks[] = new CommentBlock("test1"); |
32 | 39 | $file->blocks[] = new CommentBlock("test2"); |
33 | 40 |
|
34 | | - $file->EOL = EOLType::UNIX; |
35 | | - $this->assertEquals("#test1\n#test2", $composer->compose($file)); |
36 | | - |
37 | | - $file->EOL = EOLType::WINDOWS; |
38 | | - $this->assertEquals("#test1\r\n#test2", $composer->compose($file)); |
39 | | - |
40 | | - $composer->EOL = EOLType::UNIX; |
41 | | - $this->assertEquals("#test1\n#test2", $composer->compose($file)); |
| 41 | + $this->assertEquals("#test1\n#test2", $this->composer->compose($file, EOLType::UNIX)); |
| 42 | + $this->assertEquals("#test1\r\n#test2", $this->composer->compose($file, EOLType::WINDOWS)); |
| 43 | + $this->assertEquals("#test1\n#test2", $this->composer->compose($file, EOLType::UNIX)); |
42 | 44 | } |
43 | 45 |
|
44 | 46 | } |
0 commit comments