Skip to content

Commit

Permalink
[#5258] Fix JunitXmlLogger prepared state after each test's finish
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk authored and sebastianbergmann committed Feb 27, 2023
1 parent e1e8aab commit 7c8e3c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Logging/JUnit/JunitXmlLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ private function handleFinish(Info $telemetryInfo, int $numberOfAssertionsPerfor

$this->currentTestCase = null;
$this->time = null;
$this->prepared = false;
}

/**
Expand Down
19 changes: 16 additions & 3 deletions tests/end-to-end/regression/5258.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
https://github.com/sebastianbergmann/phpunit/issues/5258
--FILE--
<?php declare(strict_types=1);
$junitFile = tempnam(sys_get_temp_dir(), __FILE__);

$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--log-junit';
$_SERVER['argv'][] = '/dev/null';
$_SERVER['argv'][] = $junitFile;
$_SERVER['argv'][] = __DIR__ . '/5258/Issue5258Test.php';

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

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--XFAIL--
https://github.com/sebastianbergmann/phpunit/issues/5258

print file_get_contents($junitFile);

unlink($junitFile);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

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

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

0 comments on commit 7c8e3c9

Please sign in to comment.