minor #33048 Remove ForwardCompatTestTrait (jderusse)

This PR was merged into the 5.0-dev branch.

Discussion
----------

Remove ForwardCompatTestTrait

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | NA
| License       | MIT
| Doc PR        | NA

Removes ForwardCompatTestTrait not needed anymore, and use the PHPUnit 8 signature on methods `setUp` and `tearDown`

Commits
-------

242786cf98 Remove ForwardCompatTestTrait
This commit is contained in:
Nicolas Grekas 2019-08-08 20:44:24 +02:00
commit 3483e62afe
8 changed files with 7 additions and 250 deletions

View File

@ -1,78 +0,0 @@
<?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\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();
}
}
}

View File

@ -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();
}

View File

@ -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);

View File

@ -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())

View File

@ -1,78 +0,0 @@
<?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 ((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();
}
}
}

View File

@ -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;

View File

@ -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();
}

View File

@ -1,78 +0,0 @@
<?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 ((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();
}
}
}