@@ -25,7 +25,7 @@ public function testRenderWithoutNode()
2525 $ tree = TreeHelper::createTree ($ output );
2626
2727 $ tree ->render ();
28- $ this ->assertSame ("\n" , $ output ->fetch ());
28+ $ this ->assertSame (PHP_EOL , $ output ->fetch ());
2929 }
3030
3131 public function testRenderSingleNode ()
@@ -35,7 +35,7 @@ public function testRenderSingleNode()
3535 $ tree = TreeHelper::createTree ($ output , $ rootNode );
3636
3737 $ tree ->render ();
38- $ this ->assertSame ("Root \n" , $ output ->fetch ());
38+ $ this ->assertSame ("Root \n" , self :: normalizeLineBreaks ( $ output ->fetch () ));
3939 }
4040
4141 public function testRenderTwoLevelTree ()
@@ -55,7 +55,7 @@ public function testRenderTwoLevelTree()
5555Root
5656├── Child 1
5757└── Child 2
58- TREE , trim ($ output ->fetch ()));
58+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
5959 }
6060
6161 public function testRenderThreeLevelTree ()
@@ -78,7 +78,7 @@ public function testRenderThreeLevelTree()
7878├── Child 1
7979│ └── SubChild 1
8080└── Child 2
81- TREE , trim ($ output ->fetch ()));
81+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
8282 }
8383
8484 public function testRenderMultiLevelTree ()
@@ -107,7 +107,7 @@ public function testRenderMultiLevelTree()
107107│ │ └── SubSubChild 1
108108│ └── SubChild 2
109109└── Child 2
110- TREE , trim ($ output ->fetch ()));
110+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
111111 }
112112
113113 public function testRenderSingleNodeTree ()
@@ -119,7 +119,7 @@ public function testRenderSingleNodeTree()
119119 $ tree ->render ();
120120 $ this ->assertSame (<<<TREE
121121Root
122- TREE , trim ($ output ->fetch ()));
122+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
123123 }
124124
125125 public function testRenderEmptyTree ()
@@ -131,7 +131,7 @@ public function testRenderEmptyTree()
131131 $ tree ->render ();
132132 $ this ->assertSame (<<<TREE
133133Root
134- TREE , trim ($ output ->fetch ()));
134+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
135135 }
136136
137137 public function testRenderDeeplyNestedTree ()
@@ -169,7 +169,7 @@ public function testRenderDeeplyNestedTree()
169169 └── Level 8
170170 └── Level 9
171171 └── Level 10
172- TREE , trim ($ output ->fetch ()));
172+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
173173 }
174174
175175 public function testRenderNodeWithMultipleChildren ()
@@ -192,7 +192,7 @@ public function testRenderNodeWithMultipleChildren()
192192├── Child 1
193193├── Child 2
194194└── Child 3
195- TREE , trim ($ output ->fetch ()));
195+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
196196 }
197197
198198 public function testRenderTreeWithDuplicateNodeNames ()
@@ -215,7 +215,7 @@ public function testRenderTreeWithDuplicateNodeNames()
215215├── Child
216216│ └── Child
217217└── Child
218- TREE , trim ($ output ->fetch ()));
218+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
219219 }
220220
221221 public function testRenderTreeWithComplexNodeNames ()
@@ -238,7 +238,7 @@ public function testRenderTreeWithComplexNodeNames()
238238├── Child 1 (special)
239239│ └── Node with spaces
240240└── Child_2@#$
241- TREE , trim ($ output ->fetch ()));
241+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
242242 }
243243
244244 public function testRenderTreeWithCycle ()
@@ -272,7 +272,7 @@ public function testRenderWideTree()
272272 $ tree = TreeHelper::createTree ($ output , $ rootNode );
273273 $ tree ->render ();
274274
275- $ lines = explode ("\n" , trim ($ output ->fetch ()));
275+ $ lines = explode ("\n" , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
276276 $ this ->assertCount (101 , $ lines );
277277 $ this ->assertSame ('Root ' , $ lines [0 ]);
278278 $ this ->assertSame ('└── Child 100 ' , end ($ lines ));
@@ -290,7 +290,7 @@ public function testCreateWithRoot()
290290root
291291├── child1
292292└── child2
293- TREE , trim ($ output ->fetch ()));
293+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
294294 }
295295
296296 public function testCreateWithNestedArray ()
@@ -309,7 +309,7 @@ public function testCreateWithNestedArray()
309309│ └── child2.2
310310│ └── child2.2.1
311311└── child3
312- TREE , trim ($ output ->fetch ()));
312+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
313313 }
314314
315315 public function testCreateWithoutRoot ()
@@ -323,7 +323,7 @@ public function testCreateWithoutRoot()
323323 $ this ->assertSame (<<<TREE
324324├── child1
325325└── child2
326- TREE , trim ($ output ->fetch ()));
326+ TREE , self :: normalizeLineBreaks ( trim ($ output ->fetch () )));
327327 }
328328
329329 public function testCreateWithEmptyArray ()
@@ -334,6 +334,11 @@ public function testCreateWithEmptyArray()
334334 $ tree = TreeHelper::createTree ($ output , null , $ array );
335335
336336 $ tree ->render ();
337- $ this ->assertSame ('' , trim ($ output ->fetch ()));
337+ $ this ->assertSame ('' , self ::normalizeLineBreaks (trim ($ output ->fetch ())));
338+ }
339+
340+ private static function normalizeLineBreaks ($ text )
341+ {
342+ return str_replace (\PHP_EOL , "\n" , $ text );
338343 }
339344}
0 commit comments