Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #30474 compatibility with phpunit8 (garak)
This PR was merged into the 3.4 branch. Discussion ---------- compatibility with phpunit8 This basically adds the same phpunit8 compatibility layer added in #30084 (but for other test classes) See also discussion in #30071 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30071 | License | MIT | Doc PR | none Commits ------- 5ef254f compatibility with phpunit8
- Loading branch information
Showing
5 changed files
with
175 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Form\Test; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
// Auto-adapt to PHPUnit 8 that added a `void` return-type to the setUp/tearDown methods | ||
|
||
if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { | ||
eval(' | ||
namespace Symfony\Component\Form\Test; | ||
/** | ||
* @internal | ||
*/ | ||
trait TestCaseSetUpTearDownTrait | ||
{ | ||
private function doSetUp(): void | ||
{ | ||
} | ||
private function doTearDown(): void | ||
{ | ||
} | ||
protected function setUp(): void | ||
{ | ||
$this->doSetUp(); | ||
} | ||
protected function tearDown(): void | ||
{ | ||
$this->doTearDown(); | ||
} | ||
} | ||
'); | ||
} else { | ||
/** | ||
* @internal | ||
*/ | ||
trait TestCaseSetUpTearDownTrait | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
private function doSetUp() | ||
{ | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function doTearDown() | ||
{ | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->doSetUp(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function tearDown() | ||
{ | ||
$this->doTearDown(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Validator\Test; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
// Auto-adapt to PHPUnit 8 that added a `void` return-type to the setUp/tearDown methods | ||
|
||
if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { | ||
eval(' | ||
namespace Symfony\Component\Validator\Test; | ||
/** | ||
* @internal | ||
*/ | ||
trait TestCaseSetUpTearDownTrait | ||
{ | ||
private function doSetUp(): void | ||
{ | ||
} | ||
private function doTearDown(): void | ||
{ | ||
} | ||
protected function setUp(): void | ||
{ | ||
$this->doSetUp(); | ||
} | ||
protected function tearDown(): void | ||
{ | ||
$this->doTearDown(); | ||
} | ||
} | ||
'); | ||
} else { | ||
/** | ||
* @internal | ||
*/ | ||
trait TestCaseSetUpTearDownTrait | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
private function doSetUp() | ||
{ | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function doTearDown() | ||
{ | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->doSetUp(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function tearDown() | ||
{ | ||
$this->doTearDown(); | ||
} | ||
} | ||
} |