Skip to content

Commit 6fd138b

Browse files
authored
test: Prevent the Symfony error handler to be registered while executing tests (#345)
See symfony/symfony#53812.
1 parent 5808932 commit 6fd138b

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
cacheDirectory="dist/phpunit-cache"
5-
bootstrap="vendor/autoload.php"
5+
bootstrap="tests/bootstrap.php"
66
beStrictAboutChangesToGlobalState="true"
77
beStrictAboutOutputDuringTests="true"
88
colors="true"
@@ -22,6 +22,7 @@
2222
<directory>tests/</directory>
2323
<exclude>tests/AutoReview</exclude>
2424
</testsuite>
25+
2526
<testsuite name="AutoReview">
2627
<directory>tests/AutoReview</directory>
2728
</testsuite>

tests/bootstrap.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Webmozarts Console Parallelization package.
5+
*
6+
* (c) Webmozarts GmbH <office@webmozarts.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
// Workaround for https://github.com/symfony/symfony/issues/53812
15+
// The problem is that FrameworkBundle registers an error handler but does not have a way to unregister it.
16+
// The issue was closed, so we probably need to use the workaround until newer Symfony/PHPUnit versions fix it,
17+
// or we use the regular Symfony WebTestCase instead of our custom WebRouteTestCase.
18+
// The current setup code in FrameworkBundle will check if `ErrorHandler` is already registered and won't register it again.
19+
use Symfony\Component\ErrorHandler\ErrorHandler;
20+
21+
require __DIR__.'/../vendor/autoload.php';
22+
23+
ErrorHandler::register();

0 commit comments

Comments
 (0)