Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix: deprecations should not raise exceptions #918

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/WrapperRunner/ApplicationForWrapperWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PHPUnit\Runner\Baseline\CannotLoadBaselineException;
use PHPUnit\Runner\Baseline\Reader;
use PHPUnit\Runner\CodeCoverage;
use PHPUnit\Runner\DeprecationCollector\Facade as DeprecationCollector;
use PHPUnit\Runner\ErrorHandler;
use PHPUnit\Runner\Extension\ExtensionBootstrapper;
use PHPUnit\Runner\Extension\Facade as ExtensionFacade;
Expand Down Expand Up @@ -170,12 +171,6 @@ private function bootstrap(): void
$extensionRequiresCodeCoverageCollection = $extensionFacade->requiresCodeCoverageCollection();
}

CodeCoverage::instance()->init(
$this->configuration,
CodeCoverageFilterRegistry::instance(),
$extensionRequiresCodeCoverageCollection,
);

if ($this->configuration->hasLogfileJunit()) {
new JunitXmlLogger(
DefaultPrinter::from($this->configuration->logfileJunit()),
Expand Down Expand Up @@ -212,6 +207,7 @@ private function bootstrap(): void
}

TestResultFacade::init();
DeprecationCollector::init();

if ($this->configuration->source()->useBaseline()) {
$baselineFile = $this->configuration->source()->baseline();
Expand All @@ -229,6 +225,13 @@ private function bootstrap(): void
}

EventFacade::instance()->seal();

CodeCoverage::instance()->init(
$this->configuration,
CodeCoverageFilterRegistry::instance(),
$extensionRequiresCodeCoverageCollection,
);

EventFacade::emitter()->testRunnerStarted();

if ($this->configuration->executionOrder() === TestSuiteSorter::ORDER_RANDOMIZED) {
Expand Down
22 changes: 22 additions & 0 deletions test/Unit/WrapperRunner/WrapperRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,28 @@ public function testBaselineIsRespected(): void

Time: %s, Memory: %s MB

OK%a
EOF;
self::assertStringMatchesFormat($expectedOutput, $runnerResult->output);
self::assertEquals(RunnerInterface::SUCCESS_EXIT, $runnerResult->exitCode);
}

#[Group('github')]
public function testDeprecationsShouldNotRaiseException(): void
{
$this->bareOptions['--configuration'] = $this->fixture('github' . DIRECTORY_SEPARATOR . 'GH915' . DIRECTORY_SEPARATOR . 'phpunit.xml');

$runnerResult = $this->runRunner();

$expectedOutput = <<<'EOF'
Processes: %s
Runtime: PHP %s
Configuration: %s

. 1 / 1 (100%)

Time: %s, Memory: %s MB

OK%a
EOF;
self::assertStringMatchesFormat($expectedOutput, $runnerResult->output);
Expand Down
16 changes: 16 additions & 0 deletions test/fixtures/github/GH915/IssueTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace ParaTest\Tests\fixtures\github\GH915;

use PHPUnit\Framework\TestCase;

/** @internal */
final class IssueTest extends TestCase
{
public function testasd(): void
{
self::assertSame(1, 1);
}
}
12 changes: 12 additions & 0 deletions test/fixtures/github/GH915/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../vendor/phpunit/phpunit/phpunit.xsd"
stopOnDeprecation="true"
>
<testsuites>
<testsuite name="Github issue">
<file>IssueTest.php</file>
</testsuite>
</testsuites>
</phpunit>
Loading