Skip to content

Commit 0f80c15

Browse files
Merge branch '11.5' into 12.3
2 parents 1dbf4d8 + 935785a commit 0f80c15

File tree

11 files changed

+113
-10
lines changed

11 files changed

+113
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ jobs:
174174
run: php ./tools/composer install --no-ansi --no-interaction --no-progress
175175

176176
- name: Run tests with PHPUnit
177-
run: php ./phpunit --testsuite unit --order-by depends,random
177+
run: php ./phpunit --testsuite unit --order-by depends,random --display-all-issues
178178

179179
end-to-end-tests:
180180
name: End-to-End Tests
@@ -232,7 +232,7 @@ jobs:
232232
run: php ./tools/composer install --no-ansi --no-interaction --no-progress
233233

234234
- name: Run tests with PHPUnit
235-
run: php ./phpunit --testsuite end-to-end --order-by depends,random
235+
run: php ./phpunit --testsuite end-to-end --order-by depends,random --display-all-issues
236236

237237
code-coverage:
238238
name: Code Coverage

ChangeLog-12.3.md

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

77
### Changed
88

9+
* [#6353](https://github.com/sebastianbergmann/phpunit/pull/6353): Disable performance optimization for tests requiring on Xdebug
910
* [#6357](https://github.com/sebastianbergmann/phpunit/pull/6357): Also collect `E_DEPRECATED` issues when building the test suite
1011

1112
## [12.3.9] - 2025-09-11

src/Framework/TestCase.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ final public function run(): void
366366
$this,
367367
$this->runClassInSeparateProcess && !$this->runTestInSeparateProcess,
368368
$this->preserveGlobalState,
369+
$this->requiresXdebug(),
369370
);
370371
}
371372

@@ -2302,6 +2303,11 @@ private function requirementsNotSatisfied(): bool
23022303
return (new Requirements)->requirementsNotSatisfiedFor(static::class, $this->methodName) !== [];
23032304
}
23042305

2306+
private function requiresXdebug(): bool
2307+
{
2308+
return (new Requirements)->requiresXdebug(static::class, $this->methodName);
2309+
}
2310+
23052311
/**
23062312
* @see https://github.com/sebastianbergmann/phpunit/issues/6095
23072313
*/

src/Framework/TestRunner/IsolatedTestRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
*/
1717
interface IsolatedTestRunner
1818
{
19-
public function run(TestCase $test, bool $runEntireClass, bool $preserveGlobalState): void;
19+
public function run(TestCase $test, bool $runEntireClass, bool $preserveGlobalState, bool $requiresXdebug): void;
2020
}

src/Framework/TestRunner/IsolatedTestRunnerRegistry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ final class IsolatedTestRunnerRegistry
1818
{
1919
private static ?IsolatedTestRunner $runner = null;
2020

21-
public static function run(TestCase $test, bool $runEntireClass, bool $preserveGlobalState): void
21+
public static function run(TestCase $test, bool $runEntireClass, bool $preserveGlobalState, bool $requiresXdebug): void
2222
{
2323
if (self::$runner === null) {
2424
self::$runner = new SeparateProcessTestRunner;
2525
}
2626

27-
self::$runner->run($test, $runEntireClass, $preserveGlobalState);
27+
self::$runner->run($test, $runEntireClass, $preserveGlobalState, $requiresXdebug);
2828
}
2929

3030
public static function set(IsolatedTestRunner $runner): void

src/Framework/TestRunner/SeparateProcessTestRunner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class SeparateProcessTestRunner implements IsolatedTestRunner
4444
* @throws NoPreviousThrowableException
4545
* @throws ProcessIsolationException
4646
*/
47-
public function run(TestCase $test, bool $runEntireClass, bool $preserveGlobalState): void
47+
public function run(TestCase $test, bool $runEntireClass, bool $preserveGlobalState, bool $requiresXdebug): void
4848
{
4949
$class = new ReflectionClass($test);
5050

@@ -139,7 +139,7 @@ public function run(TestCase $test, bool $runEntireClass, bool $preserveGlobalSt
139139

140140
assert($code !== '');
141141

142-
JobRunnerRegistry::runTestJob(new Job($code), $processResultFile, $test);
142+
JobRunnerRegistry::runTestJob(new Job($code, requiresXdebug: $requiresXdebug), $processResultFile, $test);
143143

144144
@unlink($serializedConfiguration);
145145
}

src/Metadata/Api/Requirements.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,17 @@ public function requirementsNotSatisfiedFor(string $className, string $methodNam
197197

198198
return $notSatisfied;
199199
}
200+
201+
public function requiresXdebug(string $className, string $methodName): bool
202+
{
203+
foreach (Registry::parser()->forClassAndMethod($className, $methodName) as $metadata) {
204+
if ($metadata->isRequiresPhpExtension()) {
205+
if ($metadata->extension() === 'xdebug') {
206+
return true;
207+
}
208+
}
209+
}
210+
211+
return false;
212+
}
200213
}

src/Util/PHP/DefaultJobRunner.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function run(Job $job): Result
6767
$job->arguments(),
6868
null,
6969
$job->redirectErrors(),
70+
$job->requiresXdebug(),
7071
);
7172
}
7273

@@ -193,8 +194,12 @@ private function buildCommand(Job $job, ?string $file): array
193194
),
194195
);
195196

196-
if (!CodeCoverage::instance()->isActive() &&
197-
xdebug_is_debugger_active() === false) {
197+
if (
198+
!CodeCoverage::instance()->isActive() &&
199+
xdebug_is_debugger_active() === false &&
200+
!$job->requiresXdebug()
201+
) {
202+
// disable xdebug to speedup test execution
198203
$phpSettings['xdebug.mode'] = 'xdebug.mode=off';
199204
}
200205
}

src/Util/PHP/Job.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
*/
4444
private ?string $input;
4545
private bool $redirectErrors;
46+
private bool $requiresXdebug;
4647

4748
/**
4849
* @param non-empty-string $code
@@ -51,14 +52,15 @@
5152
* @param list<non-empty-string> $arguments
5253
* @param ?non-empty-string $input
5354
*/
54-
public function __construct(string $code, array $phpSettings = [], array $environmentVariables = [], array $arguments = [], ?string $input = null, bool $redirectErrors = false)
55+
public function __construct(string $code, array $phpSettings = [], array $environmentVariables = [], array $arguments = [], ?string $input = null, bool $redirectErrors = false, bool $requiresXdebug = false)
5556
{
5657
$this->code = $code;
5758
$this->phpSettings = $phpSettings;
5859
$this->environmentVariables = $environmentVariables;
5960
$this->arguments = $arguments;
6061
$this->input = $input;
6162
$this->redirectErrors = $redirectErrors;
63+
$this->requiresXdebug = $requiresXdebug;
6264
}
6365

6466
/**
@@ -135,4 +137,9 @@ public function redirectErrors(): bool
135137
{
136138
return $this->redirectErrors;
137139
}
140+
141+
public function requiresXdebug(): bool
142+
{
143+
return $this->requiresXdebug;
144+
}
138145
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6105
3+
--SKIPIF--
4+
<?php declare(strict_types=1);
5+
if (!extension_loaded('xdebug')) {
6+
print 'skip: Xdebug is not loaded';
7+
}
8+
9+
if (!in_array('develop', xdebug_info('mode'), true) &&
10+
!in_array('debug', xdebug_info('mode'), true) &&
11+
!in_array('coverage', xdebug_info('mode'), true)) {
12+
print 'skip: Xdebug mode must include develop, debug, or coverage';
13+
}
14+
--FILE--
15+
<?php declare(strict_types=1);
16+
$_SERVER['argv'][] = '--do-not-cache-result';
17+
$_SERVER['argv'][] = __DIR__ . '/6105/IssueTest6105.php';
18+
19+
require_once __DIR__ . '/../../bootstrap.php';
20+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
21+
--EXPECTF--
22+
PHPUnit %s by Sebastian Bergmann and contributors.
23+
24+
Runtime: %s
25+
Configuration: %s
26+
27+
.. 2 / 2 (100%)
28+
29+
Time: %s, Memory: %s
30+
31+
OK (2 tests, 3 assertions)

0 commit comments

Comments
 (0)