Skip to content

Commit

Permalink
Merge branch '10.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 5, 2023
2 parents 36667b1 + 61037fc commit e5c9d1b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
17 changes: 16 additions & 1 deletion src/Logging/JUnit/JunitXmlLogger.php
Expand Up @@ -84,6 +84,7 @@ final class JunitXmlLogger
private ?DOMElement $currentTestCase = null;
private ?HRTime $time = null;
private bool $prepared = false;
private bool $preparationFailed = false;

/**
* @throws EventFacadeIsSealedException
Expand Down Expand Up @@ -186,7 +187,16 @@ public function testPreparationStarted(PreparationStarted $event): void
* @throws InvalidArgumentException
* @throws NoDataSetFromDataProviderException
*/
public function testPrepared(Prepared $event): void
public function testPreparationFailed(): void
{
$this->preparationFailed = true;
}

/**
* @throws InvalidArgumentException
* @throws NoDataSetFromDataProviderException
*/
public function testPrepared(): void
{
$this->prepared = true;
}
Expand All @@ -196,6 +206,10 @@ public function testPrepared(Prepared $event): void
*/
public function testFinished(Finished $event): void
{
if ($this->preparationFailed) {
return;
}

$this->handleFinish($event->telemetryInfo(), $event->numberOfAssertionsPerformed());
}

Expand Down Expand Up @@ -283,6 +297,7 @@ private function registerSubscribers(Facade $facade): void
new TestSuiteStartedSubscriber($this),
new TestSuiteFinishedSubscriber($this),
new TestPreparationStartedSubscriber($this),
new TestPreparationFailedSubscriber($this),
new TestPreparedSubscriber($this),
new TestFinishedSubscriber($this),
new TestErroredSubscriber($this),
Expand Down
30 changes: 30 additions & 0 deletions src/Logging/JUnit/Subscriber/TestPreparationFailedSubscriber.php
@@ -0,0 +1,30 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Logging\JUnit;

use PHPUnit\Event\InvalidArgumentException;
use PHPUnit\Event\Test\PreparationFailed;
use PHPUnit\Event\Test\PreparationFailedSubscriber;
use PHPUnit\Event\TestData\NoDataSetFromDataProviderException;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class TestPreparationFailedSubscriber extends Subscriber implements PreparationFailedSubscriber
{
/**
* @throws InvalidArgumentException
* @throws NoDataSetFromDataProviderException
*/
public function notify(PreparationFailed $event): void
{
$this->logger()->testPreparationFailed();
}
}
2 changes: 1 addition & 1 deletion src/Logging/JUnit/Subscriber/TestPreparedSubscriber.php
Expand Up @@ -25,6 +25,6 @@ final class TestPreparedSubscriber extends Subscriber implements PreparedSubscri
*/
public function notify(Prepared $event): void
{
$this->logger()->testPrepared($event);
$this->logger()->testPrepared();
}
}
2 changes: 0 additions & 2 deletions tests/end-to-end/regression/5561.phpt
@@ -1,7 +1,5 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/5561
--XFAIL--
https://github.com/sebastianbergmann/phpunit/issues/5561
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
Expand Down

0 comments on commit e5c9d1b

Please sign in to comment.