Skip to content

Commit 28469f0

Browse files
committed
must normalize line endings for tests to pass on windows
1 parent f8abc1f commit 28469f0

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tests/phpDocumentor/GraphViz/Test/GraphTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,21 +358,29 @@ public function test__toString()
358358
{
359359
$graph = Graph::create('My First Graph');
360360
$this->assertSame(
361-
(string) $graph,
362-
('digraph "My First Graph" {' . PHP_EOL . PHP_EOL . '}')
361+
$this->normalizeLineEndings( (string) $graph ),
362+
$this->normalizeLineEndings( ('digraph "My First Graph" {' . PHP_EOL . PHP_EOL . '}' ))
363363
);
364364

365365
$graph->setLabel('PigeonPost');
366366
$this->assertSame(
367-
(string) $graph,
368-
('digraph "My First Graph" {' . PHP_EOL . 'label="PigeonPost"' . PHP_EOL . '}')
367+
$this->normalizeLineEndings( (string) $graph ),
368+
$this->normalizeLineEndings( ('digraph "My First Graph" {' . PHP_EOL . 'label="PigeonPost"' . PHP_EOL . '}' ))
369369
);
370370

371371
$graph->setStrict(true);
372372
$this->assertSame(
373-
(string) $graph,
374-
('strict digraph "My First Graph" {' . PHP_EOL . 'label="PigeonPost"' . PHP_EOL . '}')
373+
$this->normalizeLineEndings( (string) $graph ),
374+
$this->normalizeLineEndings( ('strict digraph "My First Graph" {' . PHP_EOL . 'label="PigeonPost"' . PHP_EOL . '}' ))
375375
);
376376
}
377377

378+
/**
379+
* Help avoid issue of "#Warning: Strings contain different line endings!" on Windows.
380+
*/
381+
private function normalizeLineEndings($string)
382+
{
383+
return preg_replace('~\R~u', "\r\n", $string);
384+
}
385+
378386
}

0 commit comments

Comments
 (0)