Skip to content

Commit 7c8e3c9

Browse files
Slamdunksebastianbergmann
authored andcommitted
[#5258] Fix JunitXmlLogger prepared state after each test's finish
1 parent e1e8aab commit 7c8e3c9

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Logging/JUnit/JunitXmlLogger.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ private function handleFinish(Info $telemetryInfo, int $numberOfAssertionsPerfor
261261

262262
$this->currentTestCase = null;
263263
$this->time = null;
264+
$this->prepared = false;
264265
}
265266

266267
/**

tests/end-to-end/regression/5258.phpt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22
https://github.com/sebastianbergmann/phpunit/issues/5258
33
--FILE--
44
<?php declare(strict_types=1);
5+
$junitFile = tempnam(sys_get_temp_dir(), __FILE__);
6+
57
$_SERVER['argv'][] = '--do-not-cache-result';
68
$_SERVER['argv'][] = '--no-configuration';
79
$_SERVER['argv'][] = '--log-junit';
8-
$_SERVER['argv'][] = '/dev/null';
10+
$_SERVER['argv'][] = $junitFile;
911
$_SERVER['argv'][] = __DIR__ . '/5258/Issue5258Test.php';
1012

1113
require_once __DIR__ . '/../../bootstrap.php';
1214

1315
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
14-
--XFAIL--
15-
https://github.com/sebastianbergmann/phpunit/issues/5258
16+
17+
print file_get_contents($junitFile);
18+
19+
unlink($junitFile);
1620
--EXPECTF--
1721
PHPUnit %s by Sebastian Bergmann and contributors.
1822

@@ -24,3 +28,12 @@ Time: %s, Memory: %s MB
2428

2529
OK, but some tests were skipped!
2630
Tests: 2, Assertions: 1, Skipped: 1.
31+
<?xml version="1.0" encoding="UTF-8"?>
32+
<testsuites>
33+
<testsuite name="PHPUnit\TestFixture\Issue5258\Issue5258Test" file="%sIssue5258Test.php" tests="2" assertions="1" errors="0" failures="0" skipped="1" time="%f">
34+
<testcase name="testOne" file="%sIssue5258Test.php" line="%d" class="PHPUnit\TestFixture\Issue5258\Issue5258Test" classname="PHPUnit.TestFixture.Issue5258.Issue5258Test" assertions="1" time="%f"/>
35+
<testcase name="testTwo" file="%sIssue5258Test.php" line="%d" class="PHPUnit\TestFixture\Issue5258\Issue5258Test" classname="PHPUnit.TestFixture.Issue5258.Issue5258Test" assertions="0" time="0.000000">
36+
<skipped/>
37+
</testcase>
38+
</testsuite>
39+
</testsuites>

0 commit comments

Comments
 (0)