Skip to content

Commit 7e77bb0

Browse files
Make tests portable
1 parent 50d2052 commit 7e77bb0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/tests/Report/CoberturaTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
*/
1010
namespace SebastianBergmann\CodeCoverage\Report;
1111

12+
use const DIRECTORY_SEPARATOR;
1213
use const PHP_EOL;
1314
use function libxml_clear_errors;
1415
use function libxml_get_errors;
1516
use function libxml_use_internal_errors;
17+
use function realpath;
1618
use function sprintf;
1719
use function str_replace;
1820
use function trim;
@@ -83,9 +85,15 @@ private function assertAndValidate(string $expectationFile, string $coberturaXml
8385
{
8486
$this->assertStringMatchesFormatFile($expectationFile, $coberturaXml);
8587

88+
$dtdPath = realpath(__DIR__ . '/../../_files/Report/Cobertura/coverage-04.dtd');
89+
90+
if (DIRECTORY_SEPARATOR === '\\') {
91+
$dtdPath = 'file:///' . str_replace('\\', '/', $dtdPath);
92+
}
93+
8694
$coberturaXml = str_replace(
8795
'<?xml version="1.0" encoding="UTF-8"?>',
88-
'<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<!DOCTYPE coverage SYSTEM "' . __DIR__ . '/../../_files/Report/Cobertura/coverage-04.dtd">',
96+
'<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<!DOCTYPE coverage SYSTEM "' . $dtdPath . '">',
8997
$coberturaXml,
9098
);
9199

0 commit comments

Comments
 (0)