From 242786cf9856bff63ab311df656ee673e91a37fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Thu, 8 Aug 2019 14:35:09 +0200 Subject: [PATCH] Remove ForwardCompatTestTrait --- .../Test/ForwardCompatTestTrait.php | 78 ------------------- .../FrameworkBundle/Test/KernelTestCase.php | 4 +- .../FrameworkBundle/Test/WebTestCase.php | 3 +- .../Form/Test/FormIntegrationTestCase.php | 4 +- .../Form/Test/ForwardCompatTestTrait.php | 78 ------------------- .../Component/Form/Test/TypeTestCase.php | 6 +- .../Test/ConstraintValidatorTestCase.php | 6 +- .../Validator/Test/ForwardCompatTestTrait.php | 78 ------------------- 8 files changed, 7 insertions(+), 250 deletions(-) delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Test/ForwardCompatTestTrait.php delete mode 100644 src/Symfony/Component/Form/Test/ForwardCompatTestTrait.php delete mode 100644 src/Symfony/Component/Validator/Test/ForwardCompatTestTrait.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/ForwardCompatTestTrait.php b/src/Symfony/Bundle/FrameworkBundle/Test/ForwardCompatTestTrait.php deleted file mode 100644 index 7dd9338580..0000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Test/ForwardCompatTestTrait.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\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()) { - /** - * @internal - */ - trait ForwardCompatTestTrait - { - private function doSetUp(): void - { - } - - private function doTearDown(): void - { - } - - protected function setUp(): void - { - $this->doSetUp(); - } - - protected function tearDown(): void - { - $this->doTearDown(); - } - } -} else { - /** - * @internal - */ - trait ForwardCompatTestTrait - { - /** - * @return void - */ - private function doSetUp() - { - } - - /** - * @return void - */ - private function doTearDown() - { - } - - /** - * @return void - */ - protected function setUp() - { - $this->doSetUp(); - } - - /** - * @return void - */ - protected function tearDown() - { - $this->doTearDown(); - } - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php index 02806ad6a9..01ff87e92e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php @@ -23,8 +23,6 @@ use Symfony\Contracts\Service\ResetInterface; */ abstract class KernelTestCase extends TestCase { - use ForwardCompatTestTrait; - protected static $class; /** @@ -39,7 +37,7 @@ abstract class KernelTestCase extends TestCase protected static $booted; - private function doTearDown() + protected function tearDown(): void { static::ensureKernelShutdown(); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index 63622a7cb7..b9da881e53 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -21,11 +21,10 @@ use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; */ abstract class WebTestCase extends KernelTestCase { - use ForwardCompatTestTrait; use WebTestAssertionsTrait; use MailerAssertionsTrait; - private function doTearDown() + protected function tearDown(): void { parent::tearDown(); self::getClient(null); diff --git a/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php b/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php index eabf82d161..4feb8df5a6 100644 --- a/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php +++ b/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php @@ -20,14 +20,12 @@ use Symfony\Component\Form\Forms; */ abstract class FormIntegrationTestCase extends TestCase { - use ForwardCompatTestTrait; - /** * @var FormFactoryInterface */ protected $factory; - private function doSetUp() + protected function setUp(): void { $this->factory = Forms::createFormFactoryBuilder() ->addExtensions($this->getExtensions()) diff --git a/src/Symfony/Component/Form/Test/ForwardCompatTestTrait.php b/src/Symfony/Component/Form/Test/ForwardCompatTestTrait.php deleted file mode 100644 index 82e531d030..0000000000 --- a/src/Symfony/Component/Form/Test/ForwardCompatTestTrait.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * 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 ((new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { - /** - * @internal - */ - trait ForwardCompatTestTrait - { - private function doSetUp(): void - { - } - - private function doTearDown(): void - { - } - - protected function setUp(): void - { - $this->doSetUp(); - } - - protected function tearDown(): void - { - $this->doTearDown(); - } - } -} else { - /** - * @internal - */ - trait ForwardCompatTestTrait - { - /** - * @return void - */ - private function doSetUp() - { - } - - /** - * @return void - */ - private function doTearDown() - { - } - - /** - * @return void - */ - protected function setUp() - { - $this->doSetUp(); - } - - /** - * @return void - */ - protected function tearDown() - { - $this->doTearDown(); - } - } -} diff --git a/src/Symfony/Component/Form/Test/TypeTestCase.php b/src/Symfony/Component/Form/Test/TypeTestCase.php index 51e6b85c6e..12d24eba73 100644 --- a/src/Symfony/Component/Form/Test/TypeTestCase.php +++ b/src/Symfony/Component/Form/Test/TypeTestCase.php @@ -17,8 +17,6 @@ use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; abstract class TypeTestCase extends FormIntegrationTestCase { - use ForwardCompatTestTrait; - /** * @var FormBuilder */ @@ -29,7 +27,7 @@ abstract class TypeTestCase extends FormIntegrationTestCase */ protected $dispatcher; - private function doSetUp() + protected function setUp(): void { parent::setUp(); @@ -37,7 +35,7 @@ abstract class TypeTestCase extends FormIntegrationTestCase $this->builder = new FormBuilder('', null, $this->dispatcher, $this->factory); } - private function doTearDown() + protected function tearDown(): void { if (\in_array(ValidatorExtensionTrait::class, class_uses($this))) { $this->validator = null; diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index ac9ace919d..313957ef5e 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -30,8 +30,6 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ abstract class ConstraintValidatorTestCase extends TestCase { - use ForwardCompatTestTrait; - /** * @var ExecutionContextInterface */ @@ -51,7 +49,7 @@ abstract class ConstraintValidatorTestCase extends TestCase protected $constraint; protected $defaultTimezone; - private function doSetUp() + protected function setUp(): void { $this->group = 'MyGroup'; $this->metadata = null; @@ -73,7 +71,7 @@ abstract class ConstraintValidatorTestCase extends TestCase $this->setDefaultTimezone('UTC'); } - private function doTearDown() + protected function tearDown(): void { $this->restoreDefaultTimezone(); } diff --git a/src/Symfony/Component/Validator/Test/ForwardCompatTestTrait.php b/src/Symfony/Component/Validator/Test/ForwardCompatTestTrait.php deleted file mode 100644 index e058391e04..0000000000 --- a/src/Symfony/Component/Validator/Test/ForwardCompatTestTrait.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * 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 ((new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { - /** - * @internal - */ - trait ForwardCompatTestTrait - { - private function doSetUp(): void - { - } - - private function doTearDown(): void - { - } - - protected function setUp(): void - { - $this->doSetUp(); - } - - protected function tearDown(): void - { - $this->doTearDown(); - } - } -} else { - /** - * @internal - */ - trait ForwardCompatTestTrait - { - /** - * @return void - */ - private function doSetUp() - { - } - - /** - * @return void - */ - private function doTearDown() - { - } - - /** - * @return void - */ - protected function setUp() - { - $this->doSetUp(); - } - - /** - * @return void - */ - protected function tearDown() - { - $this->doTearDown(); - } - } -}