Merge branch '4.3' into 4.4

* 4.3:
  [Cache] fix cs
  Make tests support phpunit 8
  Allow Travis CI to build on PHP 7.4
This commit is contained in:
Nicolas Grekas 2019-08-01 00:33:28 +02:00
commit 13f7616afb
360 changed files with 3264 additions and 506 deletions

View File

@ -29,7 +29,6 @@ matrix:
env: deps=high
- php: 7.3
env: deps=low
fast_finish: true
cache:
@ -163,7 +162,7 @@ before_install:
tfold ext.libsodium tpecl libsodium sodium.so $INI
fi
tfold ext.apcu tpecl apcu-5.1.16 apcu.so $INI
tfold ext.apcu tpecl apcu-5.1.17 apcu.so $INI
tfold ext.mongodb tpecl mongodb-1.6.0alpha1 mongodb.so $INI
tfold ext.igbinary tpecl igbinary-2.0.8 igbinary.so $INI
tfold ext.zookeeper tpecl zookeeper-0.7.1 zookeeper.so $INI

View File

@ -7,8 +7,12 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
exit(1);
}
if (\PHP_VERSION_ID >= 70000 && !getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
if (\PHP_VERSION_ID >= 70400) {
putenv('SYMFONY_PHPUNIT_VERSION=8.2');
} elseif (\PHP_VERSION_ID >= 70000) {
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
}
}
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

View File

@ -13,14 +13,17 @@ namespace Symfony\Bridge\Doctrine\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\ContainerAwareEventManager;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Container;
class ContainerAwareEventManagerTest extends TestCase
{
use ForwardCompatTestTrait;
private $container;
private $evm;
protected function setUp()
private function doSetUp()
{
$this->container = new Container();
$this->evm = new ContainerAwareEventManager($this->container);

View File

@ -12,6 +12,7 @@
namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@ -21,12 +22,14 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
*/
class DoctrineExtensionTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var \Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension
*/
private $extension;
protected function setUp()
private function doSetUp()
{
parent::setUp();

View File

@ -19,6 +19,7 @@ use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader;
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
@ -27,6 +28,8 @@ use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
*/
class DoctrineChoiceLoaderTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var ChoiceListFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
@ -72,7 +75,7 @@ class DoctrineChoiceLoaderTest extends TestCase
*/
private $obj3;
protected function setUp()
private function doSetUp()
{
$this->factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$this->om = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();

View File

@ -14,18 +14,21 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\DataTransformer;
use Doctrine\Common\Collections\ArrayCollection;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
class CollectionToArrayTransformerTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var CollectionToArrayTransformer
*/
private $transformer;
protected function setUp()
private function doSetUp()
{
$this->transformer = new CollectionToArrayTransformer();
}

View File

@ -14,6 +14,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\EventListener;
use Doctrine\Common\Collections\ArrayCollection;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Form\EventListener\MergeDoctrineCollectionListener;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormEvent;
@ -21,6 +22,8 @@ use Symfony\Component\Form\FormEvents;
class MergeDoctrineCollectionListenerTest extends TestCase
{
use ForwardCompatTestTrait;
/** @var \Doctrine\Common\Collections\ArrayCollection */
private $collection;
/** @var \Symfony\Component\EventDispatcher\EventDispatcher */
@ -28,7 +31,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
private $factory;
private $form;
protected function setUp()
private function doSetUp()
{
$this->collection = new ArrayCollection(['test']);
$this->dispatcher = new EventDispatcher();
@ -37,7 +40,7 @@ class MergeDoctrineCollectionListenerTest extends TestCase
->getForm();
}
protected function tearDown()
private function doTearDown()
{
$this->collection = null;
$this->dispatcher = null;

View File

@ -15,6 +15,7 @@ use Doctrine\ORM\Tools\SchemaTool;
use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension;
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Symfony\Component\Form\Test\FormPerformanceTestCase;
@ -23,6 +24,8 @@ use Symfony\Component\Form\Test\FormPerformanceTestCase;
*/
class EntityTypePerformanceTest extends FormPerformanceTestCase
{
use ForwardCompatTestTrait;
const ENTITY_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity';
/**
@ -50,7 +53,7 @@ class EntityTypePerformanceTest extends FormPerformanceTestCase
];
}
protected function setUp()
private function doSetUp()
{
$this->em = DoctrineTestHelper::createTestEntityManager();

View File

@ -28,6 +28,7 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringCastableIdEntity;
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\Forms;
@ -36,6 +37,8 @@ use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest;
class EntityTypeTest extends BaseTypeTest
{
use ForwardCompatTestTrait;
const TESTED_TYPE = 'Symfony\Bridge\Doctrine\Form\Type\EntityType';
const ITEM_GROUP_CLASS = 'Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity';
@ -59,7 +62,7 @@ class EntityTypeTest extends BaseTypeTest
protected static $supportedFeatureSetVersion = 304;
protected function setUp()
private function doSetUp()
{
$this->em = DoctrineTestHelper::createTestEntityManager();
$this->emRegistry = $this->createRegistryMock('default', $this->em);
@ -89,7 +92,7 @@ class EntityTypeTest extends BaseTypeTest
}
}
protected function tearDown()
private function doTearDown()
{
parent::tearDown();

View File

@ -13,11 +13,14 @@ namespace Symfony\Bridge\Doctrine\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\ManagerRegistry;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper\PhpDumperTest;
class ManagerRegistryTest extends TestCase
{
public static function setUpBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
if (!class_exists('PHPUnit_Framework_TestCase')) {
self::markTestSkipped('proxy-manager-bridge is not yet compatible with namespaced phpunit versions.');

View File

@ -32,6 +32,7 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity;
use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapper;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
@ -39,6 +40,8 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
*/
class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
{
use ForwardCompatTestTrait;
const EM_NAME = 'foo';
/**
@ -58,7 +61,7 @@ class UniqueEntityValidatorTest extends ConstraintValidatorTestCase
protected $repositoryFactory;
protected function setUp()
private function doSetUp()
{
$this->repositoryFactory = new TestRepositoryFactory();

View File

@ -0,0 +1,28 @@
<?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\Bridge\PhpUnit;
use PHPUnit\Framework\TestCase;
// A trait to provide forward compatibility with newest PHPUnit versions
if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) {
trait ForwardCompatTestTrait
{
use Legacy\ForwardCompatTestTraitForV8;
}
} else {
trait ForwardCompatTestTrait
{
use Legacy\ForwardCompatTestTraitForV5;
}
}

View File

@ -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\Bridge\PhpUnit\Legacy;
/**
* @internal
*/
trait ForwardCompatTestTraitForV5
{
/**
* @return void
*/
public static function setUpBeforeClass()
{
self::doSetUpBeforeClass();
}
/**
* @return void
*/
public static function tearDownAfterClass()
{
self::doTearDownAfterClass();
}
/**
* @return void
*/
protected function setUp()
{
self::doSetUp();
}
/**
* @return void
*/
protected function tearDown()
{
self::doTearDown();
}
/**
* @return void
*/
private static function doSetUpBeforeClass()
{
parent::setUpBeforeClass();
}
/**
* @return void
*/
private static function doTearDownAfterClass()
{
parent::tearDownAfterClass();
}
/**
* @return void
*/
private function doSetUp()
{
parent::setUp();
}
/**
* @return void
*/
private function doTearDown()
{
parent::tearDown();
}
}

View File

@ -0,0 +1,58 @@
<?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\Bridge\PhpUnit\Legacy;
/**
* @internal
*/
trait ForwardCompatTestTraitForV8
{
public static function setUpBeforeClass(): void
{
self::doSetUpBeforeClass();
}
public static function tearDownAfterClass(): void
{
self::doTearDownAfterClass();
}
protected function setUp(): void
{
self::doSetUp();
}
protected function tearDown(): void
{
self::doTearDown();
}
private static function doSetUpBeforeClass(): void
{
parent::setUpBeforeClass();
}
private static function doTearDownAfterClass(): void
{
parent::tearDownAfterClass();
}
private function doSetUp(): void
{
parent::setUp();
}
private function doTearDown(): void
{
parent::tearDown();
}
}

View File

@ -13,6 +13,7 @@ namespace Symfony\Bridge\PhpUnit\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
/**
* @author Dominic Tubach <dominic.tubach@to.com>
@ -21,12 +22,14 @@ use Symfony\Bridge\PhpUnit\ClockMock;
*/
class ClockMockTest extends TestCase
{
public static function setUpBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
ClockMock::register(__CLASS__);
}
protected function setUp()
private function doSetUp()
{
ClockMock::withClockMock(1234567890.125);
}

View File

@ -13,10 +13,13 @@ namespace Symfony\Bridge\PhpUnit\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\DnsMock;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
class DnsMockTest extends TestCase
{
protected function tearDown()
use ForwardCompatTestTrait;
private function doTearDown()
{
DnsMock::withMockedHosts(array());
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\Instantiator;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
use Symfony\Component\DependencyInjection\Definition;
@ -22,6 +23,8 @@ use Symfony\Component\DependencyInjection\Definition;
*/
class RuntimeInstantiatorTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var RuntimeInstantiator
*/
@ -30,7 +33,7 @@ class RuntimeInstantiatorTest extends TestCase
/**
* {@inheritdoc}
*/
protected function setUp()
private function doSetUp()
{
$this->instantiator = new RuntimeInstantiator();
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
@ -23,6 +24,8 @@ use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
*/
class ProxyDumperTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var ProxyDumper
*/
@ -31,7 +34,7 @@ class ProxyDumperTest extends TestCase
/**
* {@inheritdoc}
*/
protected function setUp()
private function doSetUp()
{
$this->dumper = new ProxyDumper();
}

View File

@ -3,6 +3,7 @@
namespace Symfony\Bridge\Twig\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\AppVariable;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag;
@ -10,12 +11,14 @@ use Symfony\Component\HttpFoundation\Session\Session;
class AppVariableTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var AppVariable
*/
protected $appVariable;
protected function setUp()
private function doSetUp()
{
$this->appVariable = new AppVariable();
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bridge\Twig\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Command\LintCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Output\OutputInterface;
@ -21,6 +22,8 @@ use Twig\Loader\FilesystemLoader;
class LintCommandTest extends TestCase
{
use ForwardCompatTestTrait;
private $files;
public function testLintCorrectFile()
@ -95,12 +98,12 @@ class LintCommandTest extends TestCase
return $filename;
}
protected function setUp()
private function doSetUp()
{
$this->files = [];
}
protected function tearDown()
private function doTearDown()
{
foreach ($this->files as $file) {
if (file_exists($file)) {

View File

@ -11,6 +11,7 @@
namespace Symfony\Bridge\Twig\Tests\Extension;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
@ -22,6 +23,8 @@ use Twig\Environment;
class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest
{
use ForwardCompatTestTrait;
use RuntimeLoaderProvider;
protected $testableFeatures = [
@ -33,7 +36,7 @@ class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3Hori
*/
private $renderer;
protected function setUp()
private function doSetUp()
{
parent::setUp();

View File

@ -11,6 +11,7 @@
namespace Symfony\Bridge\Twig\Tests\Extension;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
@ -22,6 +23,7 @@ use Twig\Environment;
class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
{
use ForwardCompatTestTrait;
use RuntimeLoaderProvider;
/**
@ -29,7 +31,7 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
*/
private $renderer;
protected function setUp()
private function doSetUp()
{
parent::setUp();

View File

@ -11,6 +11,7 @@
namespace Symfony\Bridge\Twig\Tests\Extension;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
@ -27,6 +28,7 @@ use Twig\Environment;
*/
class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4HorizontalLayoutTest
{
use ForwardCompatTestTrait;
use RuntimeLoaderProvider;
protected $testableFeatures = [
@ -35,7 +37,7 @@ class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4Hori
private $renderer;
protected function setUp()
private function doSetUp()
{
parent::setUp();

View File

@ -11,6 +11,7 @@
namespace Symfony\Bridge\Twig\Tests\Extension;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
@ -27,13 +28,14 @@ use Twig\Environment;
*/
class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest
{
use ForwardCompatTestTrait;
use RuntimeLoaderProvider;
/**
* @var FormRenderer
*/
private $renderer;
protected function setUp()
private function doSetUp()
{
parent::setUp();

View File

@ -11,6 +11,7 @@
namespace Symfony\Bridge\Twig\Tests\Extension;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
@ -24,6 +25,7 @@ use Twig\Environment;
class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
{
use ForwardCompatTestTrait;
use RuntimeLoaderProvider;
/**
@ -33,7 +35,7 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
protected static $supportedFeatureSetVersion = 404;
protected function setUp()
private function doSetUp()
{
parent::setUp();

View File

@ -11,6 +11,7 @@
namespace Symfony\Bridge\Twig\Tests\Extension;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
@ -23,6 +24,7 @@ use Twig\Environment;
class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
{
use ForwardCompatTestTrait;
use RuntimeLoaderProvider;
/**
@ -32,7 +34,7 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
protected static $supportedFeatureSetVersion = 404;
protected function setUp()
private function doSetUp()
{
parent::setUp();

View File

@ -13,6 +13,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension;
use Fig\Link\Link;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Extension\WebLinkExtension;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
@ -22,6 +23,8 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
class WebLinkExtensionTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var Request
*/
@ -32,7 +35,7 @@ class WebLinkExtensionTest extends TestCase
*/
private $extension;
protected function setUp()
private function doSetUp()
{
$this->request = new Request();

View File

@ -12,6 +12,7 @@
namespace Symfony\Bridge\Twig\Tests\Extension;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\Twig\Extension\WorkflowExtension;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore;
@ -25,10 +26,12 @@ use Symfony\Component\Workflow\Workflow;
class WorkflowExtensionTest extends TestCase
{
use ForwardCompatTestTrait;
private $extension;
private $t1;
protected function setUp()
private function doSetUp()
{
if (!class_exists(Workflow::class)) {
$this->markTestSkipped('The Workflow component is needed to run tests for this extension.');

View File

@ -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\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()) {
eval('
namespace Symfony\Bundle\FrameworkBundle\Test;
/**
* @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,7 +23,7 @@ use Symfony\Contracts\Service\ResetInterface;
*/
abstract class KernelTestCase extends TestCase
{
use TestCaseSetUpTearDownTrait;
use ForwardCompatTestTrait;
protected static $class;
@ -39,7 +39,7 @@ abstract class KernelTestCase extends TestCase
protected static $booted;
protected function doTearDown(): void
private function doTearDown()
{
static::ensureKernelShutdown();
}

View File

@ -21,11 +21,12 @@ use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
*/
abstract class WebTestCase extends KernelTestCase
{
use ForwardCompatTestTrait;
use WebTestAssertionsTrait;
protected function doTearDown(): void
private function doTearDown()
{
parent::doTearDown();
parent::tearDown();
self::getClient(null);
}

View File

@ -5,6 +5,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\Reader;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\Cache\Adapter\NullAdapter;
@ -14,9 +15,11 @@ use Symfony\Component\Filesystem\Filesystem;
class AnnotationsCacheWarmerTest extends TestCase
{
use ForwardCompatTestTrait;
private $cacheDir;
protected function setUp()
private function doSetUp()
{
$this->cacheDir = sys_get_temp_dir().'/'.uniqid();
$fs = new Filesystem();
@ -24,7 +27,7 @@ class AnnotationsCacheWarmerTest extends TestCase
parent::setUp();
}
protected function tearDown()
private function doTearDown()
{
$fs = new Filesystem();
$fs->remove($this->cacheDir);

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer;
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
@ -24,6 +25,8 @@ use Symfony\Component\Filesystem\Filesystem;
*/
class TemplatePathsCacheWarmerTest extends TestCase
{
use ForwardCompatTestTrait;
/** @var Filesystem */
private $filesystem;
@ -38,7 +41,7 @@ class TemplatePathsCacheWarmerTest extends TestCase
private $tmpDir;
protected function setUp()
private function doSetUp()
{
$this->templateFinder = $this
->getMockBuilder(TemplateFinderInterface::class)
@ -59,7 +62,7 @@ class TemplatePathsCacheWarmerTest extends TestCase
$this->filesystem->mkdir($this->tmpDir);
}
protected function tearDown()
private function doTearDown()
{
$this->filesystem->remove($this->tmpDir);
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Tests\Command\CacheClearCommand\Fixture\TestAppKernel;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
@ -23,19 +24,21 @@ use Symfony\Component\Finder\Finder;
class CacheClearCommandTest extends TestCase
{
use ForwardCompatTestTrait;
/** @var TestAppKernel */
private $kernel;
/** @var Filesystem */
private $fs;
protected function setUp()
private function doSetUp()
{
$this->fs = new Filesystem();
$this->kernel = new TestAppKernel('test', true);
$this->fs->mkdir($this->kernel->getProjectDir());
}
protected function tearDown()
private function doTearDown()
{
$this->fs->remove($this->kernel->getProjectDir());
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
@ -21,6 +22,8 @@ use Symfony\Component\HttpKernel;
class TranslationDebugCommandTest extends TestCase
{
use ForwardCompatTestTrait;
private $fs;
private $translationDir;
@ -129,7 +132,7 @@ class TranslationDebugCommandTest extends TestCase
$tester->execute(['locale' => 'en', 'bundle' => 'dir']);
}
protected function setUp()
private function doSetUp()
{
$this->fs = new Filesystem();
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
@ -137,7 +140,7 @@ class TranslationDebugCommandTest extends TestCase
$this->fs->mkdir($this->translationDir.'/templates');
}
protected function tearDown()
private function doTearDown()
{
$this->fs->remove($this->translationDir);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
@ -21,6 +22,8 @@ use Symfony\Component\HttpKernel;
class TranslationUpdateCommandTest extends TestCase
{
use ForwardCompatTestTrait;
private $fs;
private $translationDir;
@ -105,7 +108,7 @@ class TranslationUpdateCommandTest extends TestCase
$this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay());
}
protected function setUp()
private function doSetUp()
{
$this->fs = new Filesystem();
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true);
@ -113,7 +116,7 @@ class TranslationUpdateCommandTest extends TestCase
$this->fs->mkdir($this->translationDir.'/templates');
}
protected function tearDown()
private function doTearDown()
{
$this->fs->remove($this->translationDir);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Command\YamlLintCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Application as BaseApplication;
@ -28,6 +29,8 @@ use Symfony\Component\HttpKernel\KernelInterface;
*/
class YamlLintCommandTest extends TestCase
{
use ForwardCompatTestTrait;
private $files;
public function testLintCorrectFile()
@ -183,13 +186,13 @@ EOF;
return $application;
}
protected function setUp()
private function doSetUp()
{
@mkdir(sys_get_temp_dir().'/yml-lint-test');
$this->files = [];
}
protected function tearDown()
private function doTearDown()
{
foreach ($this->files as $file) {
if (file_exists($file)) {

View File

@ -11,16 +11,19 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Console\Descriptor\TextDescriptor;
class TextDescriptorTest extends AbstractDescriptorTest
{
protected function setUp()
use ForwardCompatTestTrait;
private function doSetUp()
{
putenv('COLUMNS=121');
}
protected function tearDown()
private function doTearDown()
{
putenv('COLUMNS');
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
use Composer\Autoload\ClassLoader;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\HttpKernel\Kernel;
@ -21,9 +22,11 @@ use Symfony\Component\HttpKernel\Kernel;
*/
class ControllerNameParserTest extends TestCase
{
use ForwardCompatTestTrait;
protected $loader;
protected function setUp()
private function doSetUp()
{
$this->loader = new ClassLoader();
$this->loader->add('TestBundle', __DIR__.'/../Fixtures');
@ -31,7 +34,7 @@ class ControllerNameParserTest extends TestCase
$this->loader->register();
}
protected function tearDown()
private function doTearDown()
{
$this->loader->unregister();
$this->loader = null;

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\DependencyInjection\ChildDefinition;
@ -24,9 +25,11 @@ use Symfony\Component\DependencyInjection\Reference;
*/
class CachePoolPassTest extends TestCase
{
use ForwardCompatTestTrait;
private $cachePoolPass;
protected function setUp()
private function doSetUp()
{
$this->cachePoolPass = new CachePoolPass();
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
@ -19,10 +20,12 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class DataCollectorTranslatorPassTest extends TestCase
{
use ForwardCompatTestTrait;
private $container;
private $dataCollectorTranslatorPass;
protected function setUp()
private function doSetUp()
{
$this->container = new ContainerBuilder();
$this->dataCollectorTranslatorPass = new DataCollectorTranslatorPass();

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\WorkflowGuardListenerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
@ -22,10 +23,12 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
class WorkflowGuardListenerPassTest extends TestCase
{
use ForwardCompatTestTrait;
private $container;
private $compilerPass;
protected function setUp()
private function doSetUp()
{
$this->container = new ContainerBuilder();
$this->compilerPass = new WorkflowGuardListenerPass();

View File

@ -11,23 +11,26 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
use Symfony\Component\Filesystem\Filesystem;
abstract class AbstractWebTestCase extends BaseWebTestCase
{
use ForwardCompatTestTrait;
public static function assertRedirect($response, $location)
{
self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.$response->getStatusCode());
self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
}
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
static::deleteTmpDir();
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
static::deleteTmpDir();
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
@ -20,7 +21,9 @@ use Symfony\Component\Console\Tester\CommandTester;
*/
class CachePoolClearCommandTest extends AbstractWebTestCase
{
protected function setUp()
use ForwardCompatTestTrait;
private function doSetUp()
{
static::bootKernel(['test_case' => 'CachePoolClear', 'root_config' => 'config.yml']);
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
@ -21,9 +22,11 @@ use Symfony\Component\Console\Tester\CommandTester;
*/
class ConfigDebugCommandTest extends AbstractWebTestCase
{
use ForwardCompatTestTrait;
private $application;
protected function setUp()
private function doSetUp()
{
$kernel = static::createKernel(['test_case' => 'ConfigDump', 'root_config' => 'config.yml']);
$this->application = new Application($kernel);

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
@ -21,9 +22,11 @@ use Symfony\Component\Console\Tester\CommandTester;
*/
class ConfigDumpReferenceCommandTest extends AbstractWebTestCase
{
use ForwardCompatTestTrait;
private $application;
protected function setUp()
private function doSetUp()
{
$kernel = static::createKernel(['test_case' => 'ConfigDump', 'root_config' => 'config.yml']);
$this->application = new Application($kernel);

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\DependencyInjection\Container;
@ -20,10 +21,12 @@ use Symfony\Component\DependencyInjection\Container;
*/
class GlobalVariablesTest extends TestCase
{
use ForwardCompatTestTrait;
private $container;
private $globals;
protected function setUp()
private function doSetUp()
{
$this->container = new Container();
$this->globals = new GlobalVariables($this->container);

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\Packages;
@ -22,9 +23,11 @@ use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
*/
class AssetsHelperTest extends TestCase
{
use ForwardCompatTestTrait;
private $helper;
protected function setUp()
private function doSetUp()
{
$fooPackage = new Package(new StaticVersionStrategy('42', '%s?v=%s'));
$barPackage = new Package(new StaticVersionStrategy('22', '%s?%s'));

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
@ -25,6 +26,8 @@ use Symfony\Component\Templating\PhpEngine;
*/
class FormHelperDivLayoutTest extends AbstractDivLayoutTest
{
use ForwardCompatTestTrait;
/**
* @var PhpEngine
*/
@ -55,7 +58,7 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
]);
}
protected function tearDown()
private function doTearDown()
{
$this->engine = null;

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper;
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser;
use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator;
@ -25,6 +26,8 @@ use Symfony\Component\Templating\PhpEngine;
*/
class FormHelperTableLayoutTest extends AbstractTableLayoutTest
{
use ForwardCompatTestTrait;
/**
* @var PhpEngine
*/
@ -100,7 +103,7 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
]);
}
protected function tearDown()
private function doTearDown()
{
$this->engine = null;

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
@ -21,9 +22,11 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
class RequestHelperTest extends TestCase
{
use ForwardCompatTestTrait;
protected $requestStack;
protected function setUp()
private function doSetUp()
{
$this->requestStack = new RequestStack();
$request = new Request();

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
@ -23,9 +24,11 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
*/
class SessionHelperTest extends TestCase
{
use ForwardCompatTestTrait;
protected $requestStack;
protected function setUp()
private function doSetUp()
{
$request = new Request();
@ -39,7 +42,7 @@ class SessionHelperTest extends TestCase
$this->requestStack->push($request);
}
protected function tearDown()
private function doTearDown()
{
$this->requestStack = null;
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
@ -20,14 +21,16 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
*/
class TemplateFilenameParserTest extends TestCase
{
use ForwardCompatTestTrait;
protected $parser;
protected function setUp()
private function doSetUp()
{
$this->parser = new TemplateFilenameParser();
}
protected function tearDown()
private function doTearDown()
{
$this->parser = null;
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
@ -21,9 +22,11 @@ use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
*/
class TemplateNameParserTest extends TestCase
{
use ForwardCompatTestTrait;
protected $parser;
protected function setUp()
private function doSetUp()
{
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
@ -40,7 +43,7 @@ class TemplateNameParserTest extends TestCase
$this->parser = new TemplateNameParser($kernel);
}
protected function tearDown()
private function doTearDown()
{
$this->parser = null;
}

View File

@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Translation;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Translation\Translator;
use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\Config\Resource\FileExistenceResource;
@ -22,15 +23,17 @@ use Symfony\Component\Translation\MessageCatalogue;
class TranslatorTest extends TestCase
{
use ForwardCompatTestTrait;
protected $tmpDir;
protected function setUp()
private function doSetUp()
{
$this->tmpDir = sys_get_temp_dir().'/sf_translation';
$this->deleteTmpDir();
}
protected function tearDown()
private function doTearDown()
{
$this->deleteTmpDir();
}

View File

@ -11,23 +11,26 @@
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
use Symfony\Component\Filesystem\Filesystem;
abstract class AbstractWebTestCase extends BaseWebTestCase
{
use ForwardCompatTestTrait;
public static function assertRedirect($response, $location)
{
self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.substr($response, 0, 2000));
self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
}
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
static::deleteTmpDir();
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
static::deleteTmpDir();
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand;
use Symfony\Component\Console\Application as ConsoleApplication;
@ -29,6 +30,8 @@ use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder;
*/
class UserPasswordEncoderCommandTest extends AbstractWebTestCase
{
use ForwardCompatTestTrait;
/** @var CommandTester */
private $passwordEncoderCommandTester;
@ -292,7 +295,7 @@ EOTXT
], ['interactive' => false]);
}
protected function setUp()
private function doSetUp()
{
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
$kernel = $this->createKernel(['test_case' => 'PasswordEncode']);
@ -305,7 +308,7 @@ EOTXT
$this->passwordEncoderCommandTester = new CommandTester($passwordEncoderCommand);
}
protected function tearDown()
private function doTearDown()
{
$this->passwordEncoderCommandTester = null;
}

View File

@ -12,12 +12,15 @@
namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
class TwigLoaderPassTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var ContainerBuilder
*/
@ -31,7 +34,7 @@ class TwigLoaderPassTest extends TestCase
*/
private $pass;
protected function setUp()
private function doSetUp()
{
$this->builder = new ContainerBuilder();
$this->builder->register('twig');

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\TwigBundle\Tests\Functional;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Bundle\TwigBundle\TwigBundle;
@ -23,6 +24,8 @@ use Symfony\Component\HttpKernel\Kernel;
*/
class CacheWarmingTest extends TestCase
{
use ForwardCompatTestTrait;
public function testCacheIsProperlyWarmedWhenTemplatingIsAvailable()
{
$kernel = new CacheWarmingKernel(true);
@ -47,12 +50,12 @@ class CacheWarmingTest extends TestCase
$this->assertFileExists($kernel->getCacheDir().'/twig');
}
protected function setUp()
private function doSetUp()
{
$this->deleteTempDir();
}
protected function tearDown()
private function doTearDown()
{
$this->deleteTempDir();
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\TwigBundle\Tests\Functional;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\TwigBundle\Tests\TestCase;
use Symfony\Bundle\TwigBundle\TwigBundle;
@ -20,6 +21,8 @@ use Symfony\Component\HttpKernel\Kernel;
class NoTemplatingEntryTest extends TestCase
{
use ForwardCompatTestTrait;
public function test()
{
$kernel = new NoTemplatingEntryKernel('dev', true);
@ -30,12 +33,12 @@ class NoTemplatingEntryTest extends TestCase
$this->assertContains('{ a: b }', $content);
}
protected function setUp()
private function doSetUp()
{
$this->deleteTempDir();
}
protected function tearDown()
private function doTearDown()
{
$this->deleteTempDir();
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\WebProfilerBundle\Tests\DependencyInjection;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\WebProfilerBundle\DependencyInjection\WebProfilerExtension;
use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
use Symfony\Component\DependencyInjection\Container;
@ -23,6 +24,8 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
class WebProfilerExtensionTest extends TestCase
{
use ForwardCompatTestTrait;
private $kernel;
/**
* @var \Symfony\Component\DependencyInjection\Container
@ -47,7 +50,7 @@ class WebProfilerExtensionTest extends TestCase
self::assertEquals([], $errors, $message);
}
protected function setUp()
private function doSetUp()
{
parent::setUp();
@ -75,7 +78,7 @@ class WebProfilerExtensionTest extends TestCase
$this->container->addCompilerPass(new RegisterListenersPass());
}
protected function tearDown()
private function doTearDown()
{
parent::tearDown();

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\WebProfilerBundle\Tests\Profiler;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
use Symfony\Component\HttpKernel\Profiler\Profile;
@ -23,6 +24,8 @@ use Twig\Environment;
*/
class TemplateManagerTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var Environment
*/
@ -38,7 +41,7 @@ class TemplateManagerTest extends TestCase
*/
protected $templateManager;
protected function setUp()
private function doSetUp()
{
parent::setUp();

View File

@ -11,10 +11,13 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\RedisAdapter;
abstract class AbstractRedisAdapterTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testExpiration' => 'Testing expiration slows down the test suite',
'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
@ -28,7 +31,7 @@ abstract class AbstractRedisAdapterTest extends AdapterTestCase
return new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
}
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
if (!\extension_loaded('redis')) {
self::markTestSkipped('Extension redis required.');
@ -39,7 +42,7 @@ abstract class AbstractRedisAdapterTest extends AdapterTestCase
}
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
self::$redis = null;
}

View File

@ -15,13 +15,16 @@ use Cache\IntegrationTests\CachePoolTest;
use PHPUnit\Framework\Assert;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\CacheItem;
use Symfony\Component\Cache\PruneableInterface;
use Symfony\Contracts\Cache\CallbackInterface;
abstract class AdapterTestCase extends CachePoolTest
{
protected function setUp()
use ForwardCompatTestTrait;
private function doSetUp()
{
parent::setUp();

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
/**
@ -19,12 +20,14 @@ use Symfony\Component\Cache\Adapter\FilesystemAdapter;
*/
class FilesystemAdapterTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
public function createCachePool($defaultLifetime = 0)
{
return new FilesystemAdapter('', $defaultLifetime);
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
self::rmdir(sys_get_temp_dir().'/symfony-cache');
}

View File

@ -11,11 +11,14 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\AbstractAdapter;
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
class MemcachedAdapterTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testHasItemReturnsFalseWhenDeferredItemIsExpired' => 'Testing expiration slows down the test suite',
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
@ -24,7 +27,7 @@ class MemcachedAdapterTest extends AdapterTestCase
protected static $client;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
if (!MemcachedAdapter::isSupported()) {
self::markTestSkipped('Extension memcached >=2.2.0 required.');

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\PdoAdapter;
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
@ -19,11 +20,12 @@ use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
*/
class PdoAdapterTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
use PdoPruneableTrait;
protected static $dbFile;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
if (!\extension_loaded('pdo_sqlite')) {
self::markTestSkipped('Extension pdo_sqlite required.');
@ -35,7 +37,7 @@ class PdoAdapterTest extends AdapterTestCase
$pool->createTable();
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
@unlink(self::$dbFile);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Doctrine\DBAL\DriverManager;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\PdoAdapter;
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
@ -20,11 +21,12 @@ use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
*/
class PdoDbalAdapterTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
use PdoPruneableTrait;
protected static $dbFile;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
if (!\extension_loaded('pdo_sqlite')) {
self::markTestSkipped('Extension pdo_sqlite required.');
@ -35,7 +37,7 @@ class PdoDbalAdapterTest extends AdapterTestCase
$pool = new PdoAdapter(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
@unlink(self::$dbFile);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Psr\Cache\CacheItemInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\NullAdapter;
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
@ -21,6 +22,8 @@ use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
*/
class PhpArrayAdapterTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testGet' => 'PhpArrayAdapter is read-only.',
'testRecursiveGet' => 'PhpArrayAdapter is read-only.',
@ -58,12 +61,12 @@ class PhpArrayAdapterTest extends AdapterTestCase
protected static $file;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
}
protected function tearDown()
private function doTearDown()
{
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
@ -19,6 +20,8 @@ use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
*/
class PhpArrayAdapterWithFallbackTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testGetItemInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
'testGetItemsInvalidKeys' => 'PhpArrayAdapter does not throw exceptions on invalid key.',
@ -30,12 +33,12 @@ class PhpArrayAdapterWithFallbackTest extends AdapterTestCase
protected static $file;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
}
protected function tearDown()
private function doTearDown()
{
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
/**
@ -19,6 +20,8 @@ use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
*/
class PhpFilesAdapterTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testDefaultLifeTime' => 'PhpFilesAdapter does not allow configuring a default lifetime.',
];
@ -28,7 +31,7 @@ class PhpFilesAdapterTest extends AdapterTestCase
return new PhpFilesAdapter('sf-cache');
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
}

View File

@ -12,11 +12,14 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Predis\Connection\StreamConnection;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\RedisAdapter;
class PredisAdapterTest extends AbstractRedisAdapterTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
parent::setupBeforeClass();
self::$redis = new \Predis\Client(['host' => getenv('REDIS_HOST')]);

View File

@ -11,15 +11,19 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
class PredisClusterAdapterTest extends AbstractRedisAdapterTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
parent::setupBeforeClass();
self::$redis = new \Predis\Client([['host' => getenv('REDIS_HOST')]]);
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
self::$redis = null;
}

View File

@ -11,11 +11,14 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\RedisAdapter;
class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
@ -24,7 +27,7 @@ class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest
self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['class' => \Predis\Client::class, 'redis_cluster' => true]);
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
self::$redis = null;
}

View File

@ -11,13 +11,16 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\AbstractAdapter;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Traits\RedisProxy;
class RedisAdapterTest extends AbstractRedisAdapterTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
parent::setupBeforeClass();
self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), ['lazy' => true]);

View File

@ -11,9 +11,13 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
class RedisArrayAdapterTest extends AbstractRedisAdapterTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
parent::setupBeforeClass();
if (!class_exists('RedisArray')) {

View File

@ -11,13 +11,16 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\AbstractAdapter;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Traits\RedisClusterProxy;
class RedisClusterAdapterTest extends AbstractRedisAdapterTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
if (!class_exists('RedisCluster')) {
self::markTestSkipped('The RedisCluster class is required.');

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Adapter;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
@ -21,6 +22,7 @@ use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait;
*/
class TagAwareAdapterTest extends AdapterTestCase
{
use ForwardCompatTestTrait;
use TagAwareTestTrait;
public function createCachePool($defaultLifetime = 0)
@ -28,7 +30,7 @@ class TagAwareAdapterTest extends AdapterTestCase
return new TagAwareAdapter(new FilesystemAdapter('', $defaultLifetime));
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Simple\RedisCache;
/**
@ -18,6 +19,8 @@ use Symfony\Component\Cache\Simple\RedisCache;
*/
abstract class AbstractRedisCacheTest extends CacheTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testSetTtl' => 'Testing expiration slows down the test suite',
'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
@ -31,7 +34,7 @@ abstract class AbstractRedisCacheTest extends CacheTestCase
return new RedisCache(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
}
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
if (!\extension_loaded('redis')) {
self::markTestSkipped('Extension redis required.');
@ -42,7 +45,7 @@ abstract class AbstractRedisCacheTest extends CacheTestCase
}
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
self::$redis = null;
}

View File

@ -13,11 +13,14 @@ namespace Symfony\Component\Cache\Tests\Simple;
use Cache\IntegrationTests\SimpleCacheTest;
use Psr\SimpleCache\CacheInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\PruneableInterface;
abstract class CacheTestCase extends SimpleCacheTest
{
protected function setUp()
use ForwardCompatTestTrait;
private function doSetUp()
{
parent::setUp();

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Adapter\AbstractAdapter;
use Symfony\Component\Cache\Simple\MemcachedCache;
@ -19,6 +20,8 @@ use Symfony\Component\Cache\Simple\MemcachedCache;
*/
class MemcachedCacheTest extends CacheTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testSetTtl' => 'Testing expiration slows down the test suite',
'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
@ -27,7 +30,7 @@ class MemcachedCacheTest extends CacheTestCase
protected static $client;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
if (!MemcachedCache::isSupported()) {
self::markTestSkipped('Extension memcached >=2.2.0 required.');

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Simple\PdoCache;
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
@ -20,11 +21,12 @@ use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
*/
class PdoCacheTest extends CacheTestCase
{
use ForwardCompatTestTrait;
use PdoPruneableTrait;
protected static $dbFile;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
if (!\extension_loaded('pdo_sqlite')) {
self::markTestSkipped('Extension pdo_sqlite required.');
@ -36,7 +38,7 @@ class PdoCacheTest extends CacheTestCase
$pool->createTable();
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
@unlink(self::$dbFile);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Doctrine\DBAL\DriverManager;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Simple\PdoCache;
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
@ -21,11 +22,12 @@ use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
*/
class PdoDbalCacheTest extends CacheTestCase
{
use ForwardCompatTestTrait;
use PdoPruneableTrait;
protected static $dbFile;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
if (!\extension_loaded('pdo_sqlite')) {
self::markTestSkipped('Extension pdo_sqlite required.');
@ -37,7 +39,7 @@ class PdoDbalCacheTest extends CacheTestCase
$pool->createTable();
}
public static function tearDownAfterClass()
private static function doTearDownAfterClass()
{
@unlink(self::$dbFile);
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Simple\NullCache;
use Symfony\Component\Cache\Simple\PhpArrayCache;
use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
@ -21,6 +22,8 @@ use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
*/
class PhpArrayCacheTest extends CacheTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testBasicUsageWithLongKey' => 'PhpArrayCache does no writes',
@ -50,12 +53,12 @@ class PhpArrayCacheTest extends CacheTestCase
protected static $file;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
}
protected function tearDown()
private function doTearDown()
{
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Simple\FilesystemCache;
use Symfony\Component\Cache\Simple\PhpArrayCache;
use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
@ -21,6 +22,8 @@ use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
*/
class PhpArrayCacheWithFallbackTest extends CacheTestCase
{
use ForwardCompatTestTrait;
protected $skippedTests = [
'testGetInvalidKeys' => 'PhpArrayCache does no validation',
'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
@ -37,12 +40,12 @@ class PhpArrayCacheWithFallbackTest extends CacheTestCase
protected static $file;
public static function setupBeforeClass()
private static function doSetUpBeforeClass()
{
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
}
protected function tearDown()
private function doTearDown()
{
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');

View File

@ -11,12 +11,16 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
/**
* @group legacy
*/
class RedisArrayCacheTest extends AbstractRedisCacheTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
parent::setupBeforeClass();
if (!class_exists('RedisArray')) {

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Cache\Simple\RedisCache;
/**
@ -18,7 +19,9 @@ use Symfony\Component\Cache\Simple\RedisCache;
*/
class RedisCacheTest extends AbstractRedisCacheTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
parent::setupBeforeClass();
self::$redis = RedisCache::createConnection('redis://'.getenv('REDIS_HOST'));

View File

@ -11,12 +11,16 @@
namespace Symfony\Component\Cache\Tests\Simple;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
/**
* @group legacy
*/
class RedisClusterCacheTest extends AbstractRedisCacheTest
{
public static function setupBeforeClass()
use ForwardCompatTestTrait;
private static function doSetUpBeforeClass()
{
if (!class_exists('RedisCluster')) {
self::markTestSkipped('The RedisCluster class is required.');

View File

@ -0,0 +1,203 @@
<?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\ClassLoader\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\ClassLoader\ClassLoader;
/**
* @group legacy
*/
class ApcClassLoaderTest extends TestCase
{
use ForwardCompatTestTrait;
private function doSetUp()
{
if (!(filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
$this->markTestSkipped('The apc extension is not enabled.');
} else {
apcu_clear_cache();
}
}
private function doTearDown()
{
if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
apcu_clear_cache();
}
}
public function testConstructor()
{
$loader = new ClassLoader();
$loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader = new ApcClassLoader('test.prefix.', $loader);
$this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apcu_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument');
}
/**
* @dataProvider getLoadClassTests
*/
public function testLoadClass($className, $testClassName, $message)
{
$loader = new ClassLoader();
$loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Apc_Pearlike_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader = new ApcClassLoader('test.prefix.', $loader);
$loader->loadClass($testClassName);
$this->assertTrue(class_exists($className), $message);
}
public function getLoadClassTests()
{
return [
['\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'],
['Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'],
];
}
/**
* @dataProvider getLoadClassFromFallbackTests
*/
public function testLoadClassFromFallback($className, $testClassName, $message)
{
$loader = new ClassLoader();
$loader->addPrefix('Apc\Namespaced', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Apc_Pearlike_', __DIR__.\DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('', [__DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/fallback']);
$loader = new ApcClassLoader('test.prefix.fallback', $loader);
$loader->loadClass($testClassName);
$this->assertTrue(class_exists($className), $message);
}
public function getLoadClassFromFallbackTests()
{
return [
['\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'],
['Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'],
['\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'],
['Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'],
];
}
/**
* @dataProvider getLoadClassNamespaceCollisionTests
*/
public function testLoadClassNamespaceCollision($namespaces, $className, $message)
{
$loader = new ClassLoader();
$loader->addPrefixes($namespaces);
$loader = new ApcClassLoader('test.prefix.collision.', $loader);
$loader->loadClass($className);
$this->assertTrue(class_exists($className), $message);
}
public function getLoadClassNamespaceCollisionTests()
{
return [
[
[
'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
],
'Apc\NamespaceCollision\A\Foo',
'->loadClass() loads NamespaceCollision\A\Foo from alpha.',
],
[
[
'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
],
'Apc\NamespaceCollision\A\Bar',
'->loadClass() loads NamespaceCollision\A\Bar from alpha.',
],
[
[
'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
],
'Apc\NamespaceCollision\A\B\Foo',
'->loadClass() loads NamespaceCollision\A\B\Foo from beta.',
],
[
[
'Apc\\NamespaceCollision\\A\\B' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta',
'Apc\\NamespaceCollision\\A' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha',
],
'Apc\NamespaceCollision\A\B\Bar',
'->loadClass() loads NamespaceCollision\A\B\Bar from beta.',
],
];
}
/**
* @dataProvider getLoadClassPrefixCollisionTests
*/
public function testLoadClassPrefixCollision($prefixes, $className, $message)
{
$loader = new ClassLoader();
$loader->addPrefixes($prefixes);
$loader = new ApcClassLoader('test.prefix.collision.', $loader);
$loader->loadClass($className);
$this->assertTrue(class_exists($className), $message);
}
public function getLoadClassPrefixCollisionTests()
{
return [
[
[
'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
],
'ApcPrefixCollision_A_Foo',
'->loadClass() loads ApcPrefixCollision_A_Foo from alpha.',
],
[
[
'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
],
'ApcPrefixCollision_A_Bar',
'->loadClass() loads ApcPrefixCollision_A_Bar from alpha.',
],
[
[
'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
],
'ApcPrefixCollision_A_B_Foo',
'->loadClass() loads ApcPrefixCollision_A_B_Foo from beta.',
],
[
[
'ApcPrefixCollision_A_B_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/beta/Apc',
'ApcPrefixCollision_A_' => __DIR__.\DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc',
],
'ApcPrefixCollision_A_B_Bar',
'->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.',
],
];
}
}

View File

@ -12,19 +12,22 @@
namespace Symfony\Component\Config\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Tests\Resource\ResourceStub;
class ConfigCacheTest extends TestCase
{
use ForwardCompatTestTrait;
private $cacheFile = null;
protected function setUp()
private function doSetUp()
{
$this->cacheFile = tempnam(sys_get_temp_dir(), 'config_');
}
protected function tearDown()
private function doTearDown()
{
$files = [$this->cacheFile, $this->cacheFile.'.meta'];

View File

@ -12,13 +12,16 @@
namespace Symfony\Component\Config\Tests\Resource;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\DirectoryResource;
class DirectoryResourceTest extends TestCase
{
use ForwardCompatTestTrait;
protected $directory;
protected function setUp()
private function doSetUp()
{
$this->directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfonyDirectoryIterator';
if (!file_exists($this->directory)) {
@ -27,7 +30,7 @@ class DirectoryResourceTest extends TestCase
touch($this->directory.'/tmp.xml');
}
protected function tearDown()
private function doTearDown()
{
if (!is_dir($this->directory)) {
return;

View File

@ -12,22 +12,25 @@
namespace Symfony\Component\Config\Tests\Resource;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileExistenceResource;
class FileExistenceResourceTest extends TestCase
{
use ForwardCompatTestTrait;
protected $resource;
protected $file;
protected $time;
protected function setUp()
private function doSetUp()
{
$this->file = realpath(sys_get_temp_dir()).'/tmp.xml';
$this->time = time();
$this->resource = new FileExistenceResource($this->file);
}
protected function tearDown()
private function doTearDown()
{
if (file_exists($this->file)) {
unlink($this->file);

View File

@ -12,15 +12,18 @@
namespace Symfony\Component\Config\Tests\Resource;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
class FileResourceTest extends TestCase
{
use ForwardCompatTestTrait;
protected $resource;
protected $file;
protected $time;
protected function setUp()
private function doSetUp()
{
$this->file = sys_get_temp_dir().'/tmp.xml';
$this->time = time();
@ -28,7 +31,7 @@ class FileResourceTest extends TestCase
$this->resource = new FileResource($this->file);
}
protected function tearDown()
private function doTearDown()
{
if (!file_exists($this->file)) {
return;

View File

@ -12,11 +12,14 @@
namespace Symfony\Component\Config\Tests\Resource;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\GlobResource;
class GlobResourceTest extends TestCase
{
protected function tearDown()
use ForwardCompatTestTrait;
private function doTearDown()
{
$dir = \dirname(__DIR__).'/Fixtures';
@rmdir($dir.'/TmpGlob');

View File

@ -12,20 +12,23 @@
namespace Symfony\Component\Config\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\ResourceCheckerConfigCache;
use Symfony\Component\Config\Tests\Resource\ResourceStub;
class ResourceCheckerConfigCacheTest extends TestCase
{
use ForwardCompatTestTrait;
private $cacheFile = null;
protected function setUp()
private function doSetUp()
{
$this->cacheFile = tempnam(sys_get_temp_dir(), 'config_');
}
protected function tearDown()
private function doTearDown()
{
$files = [$this->cacheFile, "{$this->cacheFile}.meta"];

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
@ -39,16 +40,18 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
class ApplicationTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
private $colSize;
protected function setUp()
private function doSetUp()
{
$this->colSize = getenv('COLUMNS');
}
protected function tearDown()
private function doTearDown()
{
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
putenv('SHELL_VERBOSITY');
@ -56,7 +59,7 @@ class ApplicationTest extends TestCase
unset($_SERVER['SHELL_VERBOSITY']);
}
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/Fixtures/');
require_once self::$fixturesPath.'/FooCommand.php';

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\FormatterHelper;
@ -26,9 +27,11 @@ use Symfony\Component\Console\Tester\CommandTester;
class CommandTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = __DIR__.'/../Fixtures/';
require_once self::$fixturesPath.'/TestCommand.php';

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\Store\FlockStore;
@ -19,9 +20,11 @@ use Symfony\Component\Lock\Store\SemaphoreStore;
class LockableTraitTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = __DIR__.'/../Fixtures/';
require_once self::$fixturesPath.'/FooLockCommand.php';

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Helper\ProgressBar;
@ -23,15 +24,17 @@ use Symfony\Component\Console\Output\StreamOutput;
*/
class ProgressBarTest extends TestCase
{
use ForwardCompatTestTrait;
private $colSize;
protected function setUp()
private function doSetUp()
{
$this->colSize = getenv('COLUMNS');
putenv('COLUMNS=120');
}
protected function tearDown()
private function doTearDown()
{
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableCell;
@ -22,14 +23,16 @@ use Symfony\Component\Console\Output\StreamOutput;
class TableTest extends TestCase
{
use ForwardCompatTestTrait;
protected $stream;
protected function setUp()
private function doSetUp()
{
$this->stream = fopen('php://memory', 'r+');
}
protected function tearDown()
private function doTearDown()
{
fclose($this->stream);
$this->stream = null;

Some files were not shown because too many files have changed in this diff Show More