Skip to content

Commit 9a3cad2

Browse files
Merge branch '11.0'
2 parents 1bca380 + 48ea584 commit 9a3cad2

File tree

9 files changed

+85
-8
lines changed

9 files changed

+85
-8
lines changed

.psalm/baseline.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@
731731
<code><![CDATA[listTestsXml]]></code>
732732
<code><![CDATA[logEventsText]]></code>
733733
<code><![CDATA[logEventsText]]></code>
734+
<code><![CDATA[logEventsText]]></code>
735+
<code><![CDATA[logEventsVerboseText]]></code>
734736
<code><![CDATA[logEventsVerboseText]]></code>
735737
<code><![CDATA[logEventsVerboseText]]></code>
736738
<code><![CDATA[logfileJunit]]></code>

src/Runner/PhptTestCase.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,11 @@ private function cleanupForCoverage(): RawCodeCoverageData
638638
$coverage = RawCodeCoverageData::fromXdebugWithoutPathCoverage([]);
639639
$files = $this->getCoverageFiles();
640640

641-
$buffer = @file_get_contents($files['coverage']);
641+
$buffer = false;
642+
643+
if (is_file($files['coverage'])) {
644+
$buffer = @file_get_contents($files['coverage']);
645+
}
642646

643647
if ($buffer !== false) {
644648
$coverage = @unserialize($buffer);

src/Runner/ResultCache/DefaultResultCache.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use function file_put_contents;
1818
use function is_array;
1919
use function is_dir;
20+
use function is_file;
2021
use function json_decode;
2122
use function json_encode;
2223
use PHPUnit\Framework\TestStatus\TestStatus;
@@ -85,7 +86,11 @@ public function time(string $id): float
8586

8687
public function load(): void
8788
{
88-
$contents = @file_get_contents($this->cacheFilename);
89+
if (!is_file($this->cacheFilename)) {
90+
return;
91+
}
92+
93+
$contents = file_get_contents($this->cacheFilename);
8994

9095
if ($contents === false) {
9196
return;

src/TextUI/Application.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use function class_exists;
1414
use function explode;
1515
use function function_exists;
16+
use function is_file;
1617
use function is_readable;
1718
use function method_exists;
1819
use function printf;
@@ -538,7 +539,9 @@ private function writeRandomSeedInformation(Printer $printer, Configuration $con
538539
private function registerLogfileWriters(Configuration $configuration): void
539540
{
540541
if ($configuration->hasLogEventsText()) {
541-
@unlink($configuration->logEventsText());
542+
if (is_file($configuration->logEventsText())) {
543+
unlink($configuration->logEventsText());
544+
}
542545

543546
EventFacade::instance()->registerTracer(
544547
new EventLogger(
@@ -549,7 +552,9 @@ private function registerLogfileWriters(Configuration $configuration): void
549552
}
550553

551554
if ($configuration->hasLogEventsVerboseText()) {
552-
@unlink($configuration->logEventsVerboseText());
555+
if (is_file($configuration->logEventsVerboseText())) {
556+
unlink($configuration->logEventsVerboseText());
557+
}
553558

554559
EventFacade::instance()->registerTracer(
555560
new EventLogger(

src/Util/PHP/AbstractPhpProcess.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use function array_merge;
1515
use function assert;
1616
use function escapeshellarg;
17+
use function file_exists;
1718
use function file_get_contents;
1819
use function ini_get_all;
1920
use function restore_error_handler;
@@ -136,13 +137,12 @@ public function runTestJob(string $job, Test $test, string $processResultFile):
136137
{
137138
$_result = $this->runJob($job);
138139

139-
$processResult = @file_get_contents($processResultFile);
140+
$processResult = '';
140141

141-
if ($processResult !== false) {
142+
if (file_exists($processResultFile)) {
143+
$processResult = file_get_contents($processResultFile);
142144

143145
@unlink($processResultFile);
144-
} else {
145-
$processResult = '';
146146
}
147147

148148
$this->processChildResult(
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/5764
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/';
8+
9+
require_once __DIR__ . '/../../../bootstrap.php';
10+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
11+
--EXPECTF--
12+
PHPUnit %s by Sebastian Bergmann and contributors.
13+
14+
Runtime: %s
15+
Configuration: %s
16+
17+
There was 1 PHPUnit test runner warning:
18+
19+
1) No tests found in class "PHPUnit\TestFixture\Issue5764\Issue5764Test".
20+
21+
No tests executed!
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
\set_error_handler(static function (int $err_lvl, string $err_msg, string $err_file, int $err_line): bool
11+
{
12+
throw new ErrorException($err_msg, 0, $err_lvl, $err_file, $err_line);
13+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd"
4+
bootstrap="error-handler.php"
5+
>
6+
<testsuites>
7+
<testsuite name="default">
8+
<directory>tests</directory>
9+
</testsuite>
10+
</testsuites>
11+
</phpunit>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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\Issue5764;
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class Issue5764Test extends TestCase
15+
{
16+
}

0 commit comments

Comments
 (0)