Skip to content

Commit fd1d6d1

Browse files
minor symfony#26139 [Bridge\PhpUnit] Cleanup BC layer (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [Bridge\PhpUnit] Cleanup BC layer | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Follow up of symfony#26024 Commits ------- c41681c [Bridge\PhpUnit] Cleanup BC layer
2 parents a23ce69 + c41681c commit fd1d6d1

File tree

4 files changed

+77
-67
lines changed

4 files changed

+77
-67
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListener.php renamed to src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @internal
2020
*/
21-
class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
21+
class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener
2222
{
2323
private $trait;
2424

@@ -34,26 +34,26 @@ public function globalListenerDisabled()
3434

3535
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
3636
{
37-
return $this->trait->startTestSuite($suite);
37+
$this->trait->startTestSuite($suite);
3838
}
3939

4040
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
4141
{
42-
return $this->trait->addSkippedTest($test, $e, $time);
42+
$this->trait->addSkippedTest($test, $e, $time);
4343
}
4444

4545
public function startTest(\PHPUnit_Framework_Test $test)
4646
{
47-
return $this->trait->startTest($test);
47+
$this->trait->startTest($test);
4848
}
4949

5050
public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time)
5151
{
52-
return $this->trait->addWarning($test, $e, $time);
52+
$this->trait->addWarning($test, $e, $time);
5353
}
5454

5555
public function endTest(\PHPUnit_Framework_Test $test, $time)
5656
{
57-
return $this->trait->endTest($test, $time);
57+
$this->trait->endTest($test, $time);
5858
}
5959
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Legacy;
13+
14+
use PHPUnit\Framework\BaseTestListener;
15+
use PHPUnit\Framework\Test;
16+
use PHPUnit\Framework\TestSuite;
17+
use PHPUnit\Framework\Warning;
18+
19+
/**
20+
* Collects and replays skipped tests.
21+
*
22+
* @author Nicolas Grekas <[email protected]>
23+
*
24+
* @internal
25+
*/
26+
class SymfonyTestsListenerForV6 extends BaseTestListener
27+
{
28+
private $trait;
29+
30+
public function __construct(array $mockedNamespaces = array())
31+
{
32+
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
33+
}
34+
35+
public function globalListenerDisabled()
36+
{
37+
$this->trait->globalListenerDisabled();
38+
}
39+
40+
public function startTestSuite(TestSuite $suite)
41+
{
42+
$this->trait->startTestSuite($suite);
43+
}
44+
45+
public function addSkippedTest(Test $test, \Exception $e, $time)
46+
{
47+
$this->trait->addSkippedTest($test, $e, $time);
48+
}
49+
50+
public function startTest(Test $test)
51+
{
52+
$this->trait->startTest($test);
53+
}
54+
55+
public function addWarning(Test $test, Warning $e, $time)
56+
{
57+
$this->trait->addWarning($test, $e, $time);
58+
}
59+
60+
public function endTest(Test $test, $time)
61+
{
62+
$this->trait->endTest($test, $time);
63+
}
64+
}

src/Symfony/Bridge/PhpUnit/SymfonyTestsListenerWithReturnTypes.php renamed to src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,19 @@
2020
/**
2121
* Collects and replays skipped tests.
2222
*
23-
* (Version of SymfonyTestsListener for PHPUnit 7+, and PHP 7.1+.)
24-
*
2523
* @author Nicolas Grekas <[email protected]>
2624
*
27-
* @final
25+
* @internal
2826
*/
29-
class SymfonyTestsListenerWithReturnTypes implements TestListener
27+
class SymfonyTestsListenerForV7 implements TestListener
3028
{
3129
use TestListenerDefaultImplementation;
3230

3331
private $trait;
3432

3533
public function __construct(array $mockedNamespaces = array())
3634
{
37-
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
35+
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
3836
}
3937

4038
public function globalListenerDisabled()

src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,10 @@
1111

1212
namespace Symfony\Bridge\PhpUnit;
1313

14-
use PHPUnit\Framework\BaseTestListener;
15-
use PHPUnit\Framework\Test;
16-
use PHPUnit\Framework\TestSuite;
17-
use PHPUnit\Framework\Warning;
18-
19-
// Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class
20-
// gets defined without executing the code before it and so the definition is not properly conditional)
2114
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
22-
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
23-
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '>=')) {
24-
class_alias('Symfony\Bridge\PhpUnit\SymfonyTestsListenerWithReturnTypes', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
15+
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
16+
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
17+
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
2518
} else {
26-
/**
27-
* Collects and replays skipped tests.
28-
*
29-
* @author Nicolas Grekas <[email protected]>
30-
*
31-
* @final
32-
*/
33-
class SymfonyTestsListener extends BaseTestListener
34-
{
35-
private $trait;
36-
37-
public function __construct(array $mockedNamespaces = array())
38-
{
39-
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
40-
}
41-
42-
public function globalListenerDisabled()
43-
{
44-
$this->trait->globalListenerDisabled();
45-
}
46-
47-
public function startTestSuite(TestSuite $suite)
48-
{
49-
return $this->trait->startTestSuite($suite);
50-
}
51-
52-
public function addSkippedTest(Test $test, \Exception $e, $time)
53-
{
54-
return $this->trait->addSkippedTest($test, $e, $time);
55-
}
56-
57-
public function startTest(Test $test)
58-
{
59-
return $this->trait->startTest($test);
60-
}
61-
62-
public function addWarning(Test $test, Warning $e, $time)
63-
{
64-
return $this->trait->addWarning($test, $e, $time);
65-
}
66-
67-
public function endTest(Test $test, $time)
68-
{
69-
return $this->trait->endTest($test, $time);
70-
}
71-
}
19+
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
7220
}

0 commit comments

Comments
 (0)