Skip to content

Commit e9f8129

Browse files
Merge branch '10.5' into 11.5
2 parents 25c813d + d099069 commit e9f8129

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

ChangeLog-11.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes of the PHPUnit 11.5 release series are documented in this fi
1111
### Fixed
1212

1313
* [#6095](https://github.com/sebastianbergmann/phpunit/issues/6095): Expectation is not counted correctly when a doubled method is called more often than is expected
14+
* [#6098](https://github.com/sebastianbergmann/phpunit/issues/6098): No `system-out` element in JUnit XML logfile
1415

1516
## [11.5.2] - 2024-12-21
1617

src/Logging/JUnit/JunitXmlLogger.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use PHPUnit\Event\Test\MarkedIncomplete;
3232
use PHPUnit\Event\Test\PreparationStarted;
3333
use PHPUnit\Event\Test\Prepared;
34+
use PHPUnit\Event\Test\PrintedUnexpectedOutput;
3435
use PHPUnit\Event\Test\Skipped;
3536
use PHPUnit\Event\TestSuite\Started;
3637
use PHPUnit\Event\UnknownSubscriberTypeException;
@@ -194,6 +195,16 @@ public function testPrepared(): void
194195
$this->prepared = true;
195196
}
196197

198+
public function testPrintedUnexpectedOutput(PrintedUnexpectedOutput $event): void
199+
{
200+
$systemOut = $this->document->createElement(
201+
'system-out',
202+
Xml::prepareString($event->output()),
203+
);
204+
205+
$this->currentTestCase->appendChild($systemOut);
206+
}
207+
197208
/**
198209
* @throws InvalidArgumentException
199210
*/
@@ -288,6 +299,7 @@ private function registerSubscribers(Facade $facade): void
288299
new TestPreparationStartedSubscriber($this),
289300
new TestPreparationFailedSubscriber($this),
290301
new TestPreparedSubscriber($this),
302+
new TestPrintedUnexpectedOutputSubscriber($this),
291303
new TestFinishedSubscriber($this),
292304
new TestErroredSubscriber($this),
293305
new TestFailedSubscriber($this),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\Logging\JUnit;
11+
12+
use PHPUnit\Event\Test\PrintedUnexpectedOutput;
13+
use PHPUnit\Event\Test\PrintedUnexpectedOutputSubscriber;
14+
15+
/**
16+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
17+
*
18+
* @internal This class is not covered by the backward compatibility promise for PHPUnit
19+
*/
20+
final readonly class TestPrintedUnexpectedOutputSubscriber extends Subscriber implements PrintedUnexpectedOutputSubscriber
21+
{
22+
public function notify(PrintedUnexpectedOutput $event): void
23+
{
24+
$this->logger()->testPrintedUnexpectedOutput($event);
25+
}
26+
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6098
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--no-output';
8+
$_SERVER['argv'][] = '--log-junit';
9+
$_SERVER['argv'][] = 'php://stdout';
10+
$_SERVER['argv'][] = __DIR__ . '/6098/Issue6098Test.php';
11+
12+
require_once __DIR__ . '/../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
<?xml version="1.0" encoding="UTF-8"?>
17+
<testsuites>
18+
<testsuite name="PHPUnit\TestFixture\Issue6098\Issue6098Test" file="%sIssue6098Test.php" tests="1" assertions="1" errors="0" failures="0" skipped="0" time="%f">
19+
<testcase name="testOne" file="%sIssue6098Test.php" line="16" class="PHPUnit\TestFixture\Issue6098\Issue6098Test" classname="PHPUnit.TestFixture.Issue6098.Issue6098Test" assertions="1" time="%f">
20+
<system-out>output</system-out>
21+
</testcase>
22+
</testsuite>
23+
</testsuites>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\Issue6098;
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class Issue6098Test extends TestCase
15+
{
16+
public function testOne(): void
17+
{
18+
print 'output';
19+
20+
$this->assertTrue(true);
21+
}
22+
}

0 commit comments

Comments
 (0)