Skip to content

Commit

Permalink
Merge branch '10.5' into 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 22, 2024
2 parents afa8d61 + 86376e0 commit 5b30505
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@
<code><![CDATA[listTestsXml]]></code>
<code><![CDATA[logEventsText]]></code>
<code><![CDATA[logEventsText]]></code>
<code><![CDATA[logEventsText]]></code>
<code><![CDATA[logEventsVerboseText]]></code>
<code><![CDATA[logEventsVerboseText]]></code>
<code><![CDATA[logEventsVerboseText]]></code>
<code><![CDATA[logfileJunit]]></code>
Expand Down
6 changes: 5 additions & 1 deletion src/Runner/PhptTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,11 @@ private function cleanupForCoverage(): RawCodeCoverageData
$coverage = RawCodeCoverageData::fromXdebugWithoutPathCoverage([]);
$files = $this->getCoverageFiles();

$buffer = @file_get_contents($files['coverage']);
$buffer = false;

if (is_file($files['coverage'])) {
$buffer = @file_get_contents($files['coverage']);
}

if ($buffer !== false) {
$coverage = @unserialize($buffer);
Expand Down
7 changes: 6 additions & 1 deletion src/Runner/ResultCache/DefaultResultCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use function file_put_contents;
use function is_array;
use function is_dir;
use function is_file;
use function json_decode;
use function json_encode;
use PHPUnit\Framework\TestStatus\TestStatus;
Expand Down Expand Up @@ -85,7 +86,11 @@ public function time(string $id): float

public function load(): void
{
$contents = @file_get_contents($this->cacheFilename);
if (!is_file($this->cacheFilename)) {
return;
}

$contents = file_get_contents($this->cacheFilename);

if ($contents === false) {
return;
Expand Down
9 changes: 7 additions & 2 deletions src/TextUI/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace PHPUnit\TextUI;

use const PHP_EOL;
use function is_file;
use function is_readable;
use function printf;
use function realpath;
Expand Down Expand Up @@ -509,7 +510,9 @@ private function writeRandomSeedInformation(Printer $printer, Configuration $con
private function registerLogfileWriters(Configuration $configuration): void
{
if ($configuration->hasLogEventsText()) {
@unlink($configuration->logEventsText());
if (is_file($configuration->logEventsText())) {
unlink($configuration->logEventsText());
}

EventFacade::instance()->registerTracer(
new EventLogger(
Expand All @@ -520,7 +523,9 @@ private function registerLogfileWriters(Configuration $configuration): void
}

if ($configuration->hasLogEventsVerboseText()) {
@unlink($configuration->logEventsVerboseText());
if (is_file($configuration->logEventsVerboseText())) {
unlink($configuration->logEventsVerboseText());
}

EventFacade::instance()->registerTracer(
new EventLogger(
Expand Down
8 changes: 4 additions & 4 deletions src/Util/PHP/AbstractPhpProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use function array_merge;
use function assert;
use function escapeshellarg;
use function file_exists;
use function file_get_contents;
use function ini_get_all;
use function restore_error_handler;
Expand Down Expand Up @@ -136,13 +137,12 @@ public function runTestJob(string $job, Test $test, string $processResultFile):
{
$_result = $this->runJob($job);

$processResult = @file_get_contents($processResultFile);
$processResult = '';

if ($processResult !== false) {
if (file_exists($processResultFile)) {
$processResult = file_get_contents($processResultFile);

@unlink($processResultFile);
} else {
$processResult = '';
}

$this->processChildResult(
Expand Down
21 changes: 21 additions & 0 deletions tests/end-to-end/regression/5764/5764.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/5764
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--configuration';
$_SERVER['argv'][] = __DIR__ . '/';

require_once __DIR__ . '/../../../bootstrap.php';
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s
Configuration: %s

There was 1 PHPUnit test runner warning:

1) No tests found in class "PHPUnit\TestFixture\Issue5764\Issue5764Test".

No tests executed!
13 changes: 13 additions & 0 deletions tests/end-to-end/regression/5764/error-handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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.
*/
\set_error_handler(static function (int $err_lvl, string $err_msg, string $err_file, int $err_line): bool
{
throw new ErrorException($err_msg, 0, $err_lvl, $err_file, $err_line);
});
11 changes: 11 additions & 0 deletions tests/end-to-end/regression/5764/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd"
bootstrap="error-handler.php"
>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
16 changes: 16 additions & 0 deletions tests/end-to-end/regression/5764/tests/Issue5764Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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\TestFixture\Issue5764;

use PHPUnit\Framework\TestCase;

final class Issue5764Test extends TestCase
{
}

0 comments on commit 5b30505

Please sign in to comment.