Skip to content

Commit b02edbc

Browse files
Merge branch '11.2'
2 parents 4eb6e5e + 55b5b35 commit b02edbc

File tree

5 files changed

+79
-8
lines changed

5 files changed

+79
-8
lines changed

src/Runner/ErrorHandler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use const E_WARNING;
2828
use function array_keys;
2929
use function array_values;
30-
use function assert;
3130
use function debug_backtrace;
3231
use function error_reporting;
3332
use function restore_error_handler;
@@ -254,19 +253,20 @@ private function trigger(TestMethod $test, bool $filterTrigger): IssueTrigger
254253

255254
$trace = $this->filteredStackTrace($filterTrigger);
256255

257-
assert(isset($trace[0]['file']));
258-
assert(isset($trace[1]['file']));
259-
260256
$triggeredInFirstPartyCode = false;
261257
$triggerCalledFromFirstPartyCode = false;
262258

263-
if ($trace[0]['file'] === $test->file() ||
264-
$this->sourceFilter->includes($this->source, $trace[0]['file'])) {
259+
if (isset($trace[0]['file']) && (
260+
$trace[0]['file'] === $test->file() ||
261+
$this->sourceFilter->includes($this->source, $trace[0]['file'])
262+
)) {
265263
$triggeredInFirstPartyCode = true;
266264
}
267265

268-
if ($trace[1]['file'] === $test->file() ||
269-
$this->sourceFilter->includes($this->source, $trace[1]['file'])) {
266+
if (isset($trace[1]['file']) && (
267+
$trace[1]['file'] === $test->file() ||
268+
$this->sourceFilter->includes($this->source, $trace[1]['file'])
269+
)) {
270270
$triggerCalledFromFirstPartyCode = true;
271271
}
272272

tests/end-to-end/regression/5822.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/pull/5592
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/5822/phpunit.xml';
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+
D 1 / 1 (100%)
18+
19+
Time: %s, Memory: %s
20+
21+
OK, but there were issues!
22+
Tests: 1, Assertions: 1, Deprecations: 1.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<testsuites>
5+
<testsuite name="default">
6+
<directory>tests</directory>
7+
</testsuite>
8+
</testsuites>
9+
10+
<source>
11+
<include>
12+
<directory>src</directory>
13+
</include>
14+
</source>
15+
</phpunit>

tests/end-to-end/regression/5822/src/.keep

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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\Issue5822;
11+
12+
use const E_USER_DEPRECATED;
13+
use function call_user_func;
14+
use function trigger_error;
15+
use PHPUnit\Framework\TestCase;
16+
17+
final class Issue5822Test extends TestCase
18+
{
19+
public function testDebugBacktrace(): void
20+
{
21+
$this->callUserFuncExample();
22+
$this->assertTrue(true);
23+
}
24+
25+
private function callUserFuncExample(): void
26+
{
27+
call_user_func([$this, 'exampleCallback']);
28+
}
29+
30+
private function exampleCallback(): void
31+
{
32+
trigger_error('My Deprecation Error', E_USER_DEPRECATED);
33+
}
34+
}

0 commit comments

Comments
 (0)