Skip to content

Commit af18ce4

Browse files
committed
Make FormPerformanceTestCase compatible with PHPUnit 10
1 parent adcd3d0 commit af18ce4

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/Symfony/Component/Form/Test/FormPerformanceTestCase.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Test;
1313

14+
use Symfony\Component\Form\Test\Traits\RunTestTrait;
1415
use Symfony\Component\Form\Tests\VersionAwareTest;
1516

1617
/**
@@ -23,6 +24,7 @@
2324
*/
2425
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
2526
{
27+
use RunTestTrait;
2628
use VersionAwareTest;
2729

2830
/**
@@ -31,17 +33,19 @@ abstract class FormPerformanceTestCase extends FormIntegrationTestCase
3133
protected $maxRunningTime = 0;
3234

3335
/**
34-
* {@inheritdoc}
36+
* @return mixed
3537
*/
36-
protected function runTest()
38+
private function doRunTest()
3739
{
3840
$s = microtime(true);
39-
parent::runTest();
41+
$result = parent::runTest();
4042
$time = microtime(true) - $s;
4143

4244
if (0 != $this->maxRunningTime && $time > $this->maxRunningTime) {
4345
$this->fail(sprintf('expected running time: <= %s but was: %s', $this->maxRunningTime, $time));
4446
}
47+
48+
return $result;
4549
}
4650

4751
/**
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.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+
namespace Symfony\Component\Form\Test\Traits;
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
if ((new \ReflectionMethod(TestCase::class, 'runTest'))->hasReturnType()) {
17+
// PHPUnit 10
18+
/** @internal */
19+
trait RunTestTrait
20+
{
21+
protected function runTest(): mixed
22+
{
23+
return $this->doRunTest();
24+
}
25+
}
26+
} else {
27+
// PHPUnit 9
28+
/** @internal */
29+
trait RunTestTrait
30+
{
31+
protected function runTest()
32+
{
33+
return $this->doRunTest();
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy