8000 [PhpUnitBridge] Restore SetUpTearDownTraitForV5 · symfony/symfony@e2198a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit e2198a8

Browse files
jderussenicolas-grekas
authored andcommitted
[PhpUnitBridge] Restore SetUpTearDownTraitForV5
1 parent e2053d0 commit e2198a8

File tree

7 files changed

+88
-12
lines changed

7 files changed

+88
-12
lines changed

UPGRADE-5.3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ HttpKernel
1818

1919
* Marked the class `Symfony\Component\HttpKernel\EventListener\DebugHandlersListener` as internal
2020

21+
PhpunitBridge
22+
-------------
23+
24+
* Deprecated the `SetUpTearDownTrait` trait, use original methods with "void" return typehint.
25+
2126
Security
2227
--------
2328

UPGRADE-6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ PhpUnitBridge
129129
-------------
130130

131131
* Removed support for `@expectedDeprecation` annotations, use the `ExpectDeprecationTrait::expectDeprecation()` method instead.
132+
* Removed the `SetUpTearDownTrait` trait, use original methods with "void" return typehint.
132133

133134
PropertyAccess
134135
--------------

src/Symfony/Bridge/PhpUnit/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
* bumped the minimum PHP version to 7.1.3
88
* bumped the minimum PHPUnit version to 7.5
9+
* deprecated the `SetUpTearDownTrait` trait, use original methods with "void" return typehint.
910

1011
5.1.0
1112
-----
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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\Bridge\PhpUnit 8000 \Legacy;
13+
14+
/**
15+
* @internal
16+
*/
17+
trait SetUpTearDownTraitForV7
18+
{
19+
/**
20+
* @return void
21+
*/
22+
public static function setUpBeforeClass()
23+
{
24+
self::doSetUpBeforeClass();
25+
}
26+
27+
/**
28+
* @return void
29+
*/
30+
public static function tearDownAfterClass()
31+
{
32+
self::doTearDownAfterClass();
33+
}
34+
35+
/**
36+
* @return void
37+
*/
38+
protected function setUp()
39+
{
40+
self::doSetUp();
41+
}
42+
43+
/**
44+
* @return void
45+
*/
46+
protected function tearDown()
47+
{
48+
self::doTearDown();
49+
}
50+
51+
private static function doSetUpBeforeClass()
52+
{
53+
parent::setUpBeforeClass();
54+
}
55+
56+
private static function doTearDownAfterClass()
57+
{
58+
parent::tearDownAfterClass();
59+
}
60+
61+
private function doSetUp()
62+
{
63+
parent::setUp();
64+
}
65+
66+
private function doTearDown()
67+
{
68+
parent::tearDown();
69+
}
70+
}

src/Symfony/Bridge/PhpUnit/SetUpTearDownTrait.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515

16+
trigger_deprecation('symfony/phpunit-bridge', '5.3', 'The "%s" trait is deprecated, use original methods with "void" return typehint.', SetUpTearDownTrait::class);
17+
1618
// A trait to provide forward compatibility with newest PHPUnit versions
1719
$r = new \ReflectionClass(TestCase::class);
18-
if (\PHP_VERSION_ID < 70000 || !$r->getMethod('setUp')->hasReturnType()) {
20+
if (!$r->getMethod('setUp')->hasReturnType()) {
1921
trait SetUpTearDownTrait
2022
{
21-
use Legacy\SetUpTearDownTraitForV5;
23+
use Legacy\SetUpTearDownTraitForV7;
2224
}
2325
} else {
2426
trait SetUpTearDownTrait

src/Symfony/Bridge/PhpUnit/Tests/CoverageListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function test()
1414

1515
exec('type phpdbg 2> /dev/null', $output, $returnCode);
1616

17-
if (\PHP_VERSION_ID >= 70000 && 0 === $returnCode) {
17+
if (0 === $returnCode) {
1818
$php = 'phpdbg -qrr';
1919
} else {
2020
exec('php --ri xdebug -d zend_extension=xdebug.so 2> /dev/null', $output, $returnCode);

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1616
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
17-
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5;
18-
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
17+
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7;
1918

2019
class DeprecationTest extends TestCase
2120
{
22-
use SetUpTearDownTrait;
23-
2421
private static $vendorDir;
2522
private static $prefixDirsPsr4;
2623

@@ -164,7 +161,7 @@ public function providerGetTypeDetectsSelf()
164161
'triggering_file' => 'dummy_vendor_path',
165162
'files_stack' => [],
166163
]),
167-
SymfonyTestsListenerForV5::class,
164+
SymfonyTestsListenerForV7::class,
168165
'',
169166
],
170167
];
@@ -208,7 +205,7 @@ public function providerGetTypeUsesRightTrace()
208205
$vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile2.php',
209206
],
210207
]),
211-
[['function' => 'myfunc1'], ['class' => SymfonyTestsListenerForV5::class, 'method' => 'mymethod']],
208+
[['function' => 'myfunc1'], ['class' => SymfonyTestsListenerForV7::class, 'method' => 'mymethod']],
212209
],
213210
'serialized_stack_files_from_various_packages' => [
214211
Deprecation::TYPE_INDIRECT,
@@ -221,7 +218,7 @@ public function providerGetTypeUsesRightTrace()
221218
$vendorDir.'/myfakevendor/myfakepackage2/MyFakeFile.php',
222219
],
223220
]),
224-
[['function' => 'myfunc1'], ['class' => SymfonyTestsListenerForV5::class, 'method' => 'mymethod']],
221+
[['function' => 'myfunc1'], ['class' => SymfonyTestsListenerForV7::class, 'method' => 'mymethod']],
225222
],
226223
];
227224
}
@@ -261,7 +258,7 @@ private static function removeDir($dir)
261258
rmdir($dir);
262259
}
263260

264-
private static function doSetupBeforeClass()
261+
public static function setupBeforeClass(): void
265262
{
266263
foreach (get_declared_classes() as $class) {
267264
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
@@ -281,7 +278,7 @@ private static function doSetupBeforeClass()
281278
}
282279
}
283280

284-
private static function doTearDownAfterClass()
281+
public static function tearDownAfterClass(): void
285282
{
286283
foreach (self::$prefixDirsPsr4 as [$prop, $loader, $prefixDirsPsr4]) {
287284
$prop->setValue($loader, $prefixDirsPsr4);

0 commit comments

Comments
 (0)
0