Merge branch '4.4'

* 4.4:
  [Cache] fix cs
  Make tests support phpunit 8
  Allow Travis CI to build on PHP 7.4
  [DI] Allow dumping the container in one file instead of many files
This commit is contained in:
Nicolas Grekas 2019-08-01 00:36:24 +02:00
commit 5f29340a8e
322 changed files with 3824 additions and 473 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

@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader;
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
use Symfony\Bridge\Doctrine\Form\ChoiceList\IdReader;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
@ -26,6 +27,8 @@ use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
*/
class DoctrineChoiceLoaderTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var ChoiceListFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
@ -71,7 +74,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

@ -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\Loader\FilesystemLoader;
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\Loader\FilesystemLoader;
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\Loader\FilesystemLoader;
*/
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\Loader\FilesystemLoader;
*/
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\Loader\FilesystemLoader;
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\Loader\FilesystemLoader;
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\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;
@ -20,6 +21,8 @@ use Symfony\Component\Filesystem\Filesystem;
class TranslationDebugCommandTest extends TestCase
{
use ForwardCompatTestTrait;
private $fs;
private $translationDir;
@ -111,7 +114,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);
@ -119,7 +122,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;
@ -88,7 +91,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);
@ -96,7 +99,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\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

@ -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;
@ -27,6 +28,8 @@ use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder;
*/
class UserPasswordEncoderCommandTest extends AbstractWebTestCase
{
use ForwardCompatTestTrait;
/** @var CommandTester */
private $passwordEncoderCommandTester;
@ -226,7 +229,7 @@ EOTXT
], ['interactive' => false]);
}
protected function setUp()
private function doSetUp()
{
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
$kernel = $this->createKernel(['test_case' => 'PasswordEncode']);
@ -239,7 +242,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;
@ -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

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

View File

@ -12,12 +12,15 @@
namespace Symfony\Component\Console\Tests\Input;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
class InputDefinitionTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixtures;
protected $foo;
@ -25,7 +28,7 @@ class InputDefinitionTest extends TestCase
protected $foo1;
protected $foo2;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixtures = __DIR__.'/../Fixtures/';
}

View File

@ -12,19 +12,22 @@
namespace Symfony\Component\Console\Tests\Output;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Console\Output\StreamOutput;
class StreamOutputTest extends TestCase
{
use ForwardCompatTestTrait;
protected $stream;
protected function setUp()
private function doSetUp()
{
$this->stream = fopen('php://memory', 'a', false);
}
protected function tearDown()
private function doTearDown()
{
$this->stream = null;
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Style;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Input\InputInterface;
@ -22,13 +23,15 @@ use Symfony\Component\Console\Tester\CommandTester;
class SymfonyStyleTest extends TestCase
{
use ForwardCompatTestTrait;
/** @var Command */
protected $command;
/** @var CommandTester */
protected $tester;
private $colSize;
protected function setUp()
private function doSetUp()
{
$this->colSize = getenv('COLUMNS');
putenv('COLUMNS=121');
@ -36,7 +39,7 @@ class SymfonyStyleTest extends TestCase
$this->tester = new CommandTester($this->command);
}
protected function tearDown()
private function doTearDown()
{
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
$this->command = null;

View File

@ -12,20 +12,23 @@
namespace Symfony\Component\Console\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Terminal;
class TerminalTest extends TestCase
{
use ForwardCompatTestTrait;
private $colSize;
private $lineSize;
protected function setUp()
private function doSetUp()
{
$this->colSize = getenv('COLUMNS');
$this->lineSize = getenv('LINES');
}
protected function tearDown()
private function doTearDown()
{
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
putenv($this->lineSize ? 'LINES' : 'LINES='.$this->lineSize);

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Tester;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Output\Output;
@ -20,10 +21,12 @@ use Symfony\Component\Console\Tester\ApplicationTester;
class ApplicationTesterTest extends TestCase
{
use ForwardCompatTestTrait;
protected $application;
protected $tester;
protected function setUp()
private function doSetUp()
{
$this->application = new Application();
$this->application->setAutoExit(false);
@ -38,7 +41,7 @@ class ApplicationTesterTest extends TestCase
$this->tester->run(['command' => 'foo', 'foo' => 'bar'], ['interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]);
}
protected function tearDown()
private function doTearDown()
{
$this->application = null;
$this->tester = null;

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Console\Tests\Tester;
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\HelperSet;
@ -24,10 +25,12 @@ use Symfony\Component\Console\Tester\CommandTester;
class CommandTesterTest extends TestCase
{
use ForwardCompatTestTrait;
protected $command;
protected $tester;
protected function setUp()
private function doSetUp()
{
$this->command = new Command('foo');
$this->command->addArgument('command');
@ -38,7 +41,7 @@ class CommandTesterTest extends TestCase
$this->tester->execute(['foo' => 'bar'], ['interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]);
}
protected function tearDown()
private function doTearDown()
{
$this->command = null;
$this->tester = null;

View File

@ -16,6 +16,7 @@ CHANGELOG
4.4.0
-----
* added support for dumping the container in one file instead of many files
* deprecated support for short factories and short configurators in Yaml
* deprecated `tagged` in favor of `tagged_iterator`
* deprecated passing an instance of `Symfony\Component\DependencyInjection\Parameter` as class name to `Symfony\Component\DependencyInjection\Definition`

View File

@ -73,6 +73,7 @@ class PhpDumper extends Dumper
private $namespace;
private $asFiles;
private $hotPathTag;
private $inlineFactories;
private $inlineRequires;
private $inlinedRequires = [];
private $circularReferences = [];
@ -135,6 +136,7 @@ class PhpDumper extends Dumper
'as_files' => false,
'debug' => true,
'hot_path_tag' => 'container.hot_path',
'inline_factories_parameter' => 'container.dumper.inline_factories',
'inline_class_loader_parameter' => 'container.dumper.inline_class_loader',
'service_locator_tag' => 'container.service_locator',
'build_time' => time(),
@ -144,6 +146,7 @@ class PhpDumper extends Dumper
$this->namespace = $options['namespace'];
$this->asFiles = $options['as_files'];
$this->hotPathTag = $options['hot_path_tag'];
$this->inlineFactories = $this->asFiles && $options['inline_factories_parameter'] && $this->container->hasParameter($options['inline_factories_parameter']) && $this->container->getParameter($options['inline_factories_parameter']);
$this->inlineRequires = $options['inline_class_loader_parameter'] && $this->container->hasParameter($options['inline_class_loader_parameter']) && $this->container->getParameter($options['inline_class_loader_parameter']);
$this->serviceLocatorTag = $options['service_locator_tag'];
@ -217,6 +220,8 @@ class PhpDumper extends Dumper
}
}
$proxyClasses = $this->inlineFactories ? $this->generateProxyClasses() : null;
$code =
$this->startClass($options['class'], $baseClass, $baseClassWithNamespace).
$this->addServices($services).
@ -224,6 +229,8 @@ class PhpDumper extends Dumper
$this->addDefaultParametersMethod()
;
$proxyClasses = $proxyClasses ?? $this->generateProxyClasses();
if ($this->addGetService) {
$code = preg_replace(
"/(\r?\n\r?\n public function __construct.+?\\{\r?\n)/s",
@ -260,13 +267,24 @@ EOF;
$files['removed-ids.php'] = $c .= "];\n";
}
foreach ($this->generateServiceFiles($services) as $file => $c) {
$files[$file] = $fileStart.$c;
if (!$this->inlineFactories) {
foreach ($this->generateServiceFiles($services) as $file => $c) {
$files[$file] = $fileStart.$c;
}
foreach ($proxyClasses as $file => $c) {
$files[$file] = "<?php\n".$c;
}
}
foreach ($this->generateProxyClasses() as $file => $c) {
$files[$file] = "<?php\n".$c;
$code .= $this->endClass();
if ($this->inlineFactories) {
foreach ($proxyClasses as $c) {
$code .= $c;
}
}
$files[$options['class'].'.php'] = $code.$this->endClass();
$files[$options['class'].'.php'] = $code;
$hash = ucfirst(strtr(ContainerBuilder::hash($files), '._', 'xx'));
$code = [];
@ -305,7 +323,7 @@ return new \\Container{$hash}\\{$options['class']}([
EOF;
} else {
$code .= $this->endClass();
foreach ($this->generateProxyClasses() as $c) {
foreach ($proxyClasses as $c) {
$code .= $c;
}
}
@ -435,8 +453,9 @@ EOF;
$lineage[$class] = substr($exportedFile, 1, -1);
}
private function generateProxyClasses()
private function generateProxyClasses(): array
{
$proxyClasses = [];
$alreadyGenerated = [];
$definitions = $this->container->getDefinitions();
$strip = '' === $this->docStar && method_exists('Symfony\Component\HttpKernel\Kernel', 'stripComments');
@ -455,19 +474,39 @@ EOF;
if ("\n" === $proxyCode = "\n".$proxyDumper->getProxyCode($definition)) {
continue;
}
if ($this->inlineRequires) {
$lineage = [];
$this->collectLineage($class, $lineage);
$code = '';
foreach (array_diff_key(array_flip($lineage), $this->inlinedRequires) as $file => $class) {
if ($this->inlineFactories) {
$this->inlinedRequires[$file] = true;
}
$file = preg_replace('#^\\$this->targetDirs\[(\d++)\]#', sprintf('\dirname(__DIR__, %d + $1)', $this->asFiles), $file);
$code .= sprintf("include_once %s;\n", $file);
}
$proxyCode = $code.$proxyCode;
}
if ($strip) {
$proxyCode = "<?php\n".$proxyCode;
$proxyCode = substr(Kernel::stripComments($proxyCode), 5);
}
yield sprintf('%s.php', explode(' ', $proxyCode, 3)[1]) => $proxyCode;
$proxyClasses[sprintf('%s.php', explode(' ', $proxyCode, 3)[1])] = $proxyCode;
}
return $proxyClasses;
}
private function addServiceInclude(string $cId, Definition $definition): string
{
$code = '';
if ($this->inlineRequires && !$this->isHotPath($definition)) {
if ($this->inlineRequires && (!$this->isHotPath($definition) || $this->getProxyDumper()->isProxyCandidate($definition))) {
$lineage = [];
foreach ($this->inlinedDefinitions as $def) {
if (!$def->isDeprecated() && \is_string($class = \is_array($factory = $def->getFactory()) && \is_string($factory[0]) ? $factory[0] : $def->getClass())) {
@ -697,7 +736,7 @@ EOF;
$lazyInitialization = '';
}
$asFile = $this->asFiles && !$this->isHotPath($definition);
$asFile = $this->asFiles && !$this->inlineFactories && !$this->isHotPath($definition);
$methodName = $this->generateMethodName($id);
if ($asFile) {
$file = $methodName.'.php';
@ -723,17 +762,16 @@ EOF;
$this->serviceCalls = [];
$this->inlinedDefinitions = $this->getDefinitionsFromArguments([$definition], null, $this->serviceCalls);
$code .= $this->addServiceInclude($id, $definition);
if ($definition->isDeprecated()) {
$code .= sprintf(" @trigger_error(%s, E_USER_DEPRECATED);\n\n", $this->export($definition->getDeprecationMessage($id)));
}
if ($this->getProxyDumper()->isProxyCandidate($definition)) {
$factoryCode = $asFile ? ($definition->isShared() ? "\$this->load('%s.php', false)" : '$this->factories[%2$s](false)') : '$this->%s(false)';
$code .= $this->getProxyDumper()->getProxyFactoryCode($definition, $id, sprintf($factoryCode, $methodName, $this->doExport($id)));
}
if ($definition->isDeprecated()) {
$code .= sprintf(" @trigger_error(%s, E_USER_DEPRECATED);\n\n", $this->export($definition->getDeprecationMessage($id)));
}
$code .= $this->addServiceInclude($id, $definition);
$code .= $this->addInlineService($id, $definition);
if ($asFile) {
@ -1048,7 +1086,7 @@ EOF;
$code .= $this->addSyntheticIds();
$code .= $this->addMethodMap();
$code .= $this->asFiles ? $this->addFileMap() : '';
$code .= $this->asFiles && !$this->inlineFactories ? $this->addFileMap() : '';
$code .= $this->addAliases();
$code .= $this->addInlineRequires();
$code .= <<<EOF
@ -1067,7 +1105,7 @@ EOF;
EOF;
$code .= $this->addRemovedIds();
if ($this->asFiles) {
if ($this->asFiles && !$this->inlineFactories) {
$code .= <<<EOF
protected function load(\$file, \$lazyLoad = true)
@ -1083,10 +1121,10 @@ EOF;
if (!$proxyDumper->isProxyCandidate($definition)) {
continue;
}
if ($this->asFiles) {
if ($this->asFiles && !$this->inlineFactories) {
$proxyLoader = '$this->load("{$class}.php")';
} elseif ($this->namespace) {
$proxyLoader = 'class_alias("'.$this->namespace.'\\\\{$class}", $class, false)';
} elseif ($this->namespace || $this->inlineFactories) {
$proxyLoader = 'class_alias(__NAMESPACE__."\\\\$class", $class, false)';
} else {
$proxyLoader = '';
}
@ -1164,7 +1202,7 @@ EOF;
$definitions = $this->container->getDefinitions();
ksort($definitions);
foreach ($definitions as $id => $definition) {
if (!$definition->isSynthetic() && $definition->isPublic() && (!$this->asFiles || $this->isHotPath($definition))) {
if (!$definition->isSynthetic() && $definition->isPublic() && (!$this->asFiles || $this->inlineFactories || $this->isHotPath($definition))) {
$code .= ' '.$this->doExport($id).' => '.$this->doExport($this->generateMethodName($id)).",\n";
}
}
@ -1261,6 +1299,11 @@ EOF;
foreach ($this->container->findTaggedServiceIds($this->hotPathTag) as $id => $tags) {
$definition = $this->container->getDefinition($id);
if ($this->getProxyDumper()->isProxyCandidate($definition)) {
continue;
}
$inlinedDefinitions = $this->getDefinitionsFromArguments([$definition]);
foreach ($inlinedDefinitions as $def) {
@ -1606,7 +1649,7 @@ EOF;
continue;
}
$definition = $this->container->findDefinition($id = (string) $v);
$load = !($definition->hasErrors() && $e = $definition->getErrors()) ? $this->asFiles && !$this->isHotPath($definition) : reset($e);
$load = !($definition->hasErrors() && $e = $definition->getErrors()) ? $this->asFiles && !$this->inlineFactories && !$this->isHotPath($definition) : reset($e);
$serviceMap .= sprintf("\n %s => [%s, %s, %s, %s],",
$this->export($k),
$this->export($definition->isShared() ? ($definition->isPublic() ? 'services' : 'privates') : false),
@ -1749,7 +1792,7 @@ EOF;
$code = sprintf('$this->%s[%s] = %s', $definition->isPublic() ? 'services' : 'privates', $this->doExport($id), $code);
}
$code = "($code)";
} elseif ($this->asFiles && !$this->isHotPath($definition)) {
} elseif ($this->asFiles && !$this->inlineFactories && !$this->isHotPath($definition)) {
$code = sprintf("\$this->load('%s.php')", $this->generateMethodName($id));
if (!$definition->isShared()) {
$factory = sprintf('$this->factories%s[%s]', $definition->isPublic() ? '' : "['service_container']", $this->doExport($id));

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\ExtensionCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -22,10 +23,12 @@ use Symfony\Component\DependencyInjection\Extension\Extension;
*/
class ExtensionCompilerPassTest extends TestCase
{
use ForwardCompatTestTrait;
private $container;
private $pass;
protected function setUp()
private function doSetUp()
{
$this->container = new ContainerBuilder();
$this->pass = new ExtensionCompilerPass();

View File

@ -12,16 +12,19 @@
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class ResolveParameterPlaceHoldersPassTest extends TestCase
{
use ForwardCompatTestTrait;
private $compilerPass;
private $container;
private $fooDefinition;
protected function setUp()
private function doSetUp()
{
$this->compilerPass = new ResolveParameterPlaceHoldersPass();
$this->container = $this->createContainerBuilder();

View File

@ -0,0 +1,127 @@
<?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\DependencyInjection\Tests\Config;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
use Symfony\Component\DependencyInjection\Config\AutowireServiceResource;
/**
* @group legacy
*/
class AutowireServiceResourceTest extends TestCase
{
use ForwardCompatTestTrait;
/**
* @var AutowireServiceResource
*/
private $resource;
private $file;
private $class;
private $time;
private function doSetUp()
{
$this->file = realpath(sys_get_temp_dir()).'/tmp.php';
$this->time = time();
touch($this->file, $this->time);
$this->class = __NAMESPACE__.'\Foo';
$this->resource = new AutowireServiceResource(
$this->class,
$this->file,
[]
);
}
public function testToString()
{
$this->assertSame('service.autowire.'.$this->class, (string) $this->resource);
}
public function testSerializeUnserialize()
{
$unserialized = unserialize(serialize($this->resource));
$this->assertEquals($this->resource, $unserialized);
}
public function testIsFresh()
{
$this->assertTrue($this->resource->isFresh($this->time), '->isFresh() returns true if the resource has not changed in same second');
$this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed');
$this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated');
}
public function testIsFreshForDeletedResources()
{
unlink($this->file);
$this->assertFalse($this->resource->isFresh($this->getStaleFileTime()), '->isFresh() returns false if the resource does not exist');
}
public function testIsNotFreshChangedResource()
{
$oldResource = new AutowireServiceResource(
$this->class,
$this->file,
['will_be_different']
);
// test with a stale file *and* a resource that *will* be different than the actual
$this->assertFalse($oldResource->isFresh($this->getStaleFileTime()), '->isFresh() returns false if the constructor arguments have changed');
}
public function testIsFreshSameConstructorArgs()
{
$oldResource = AutowirePass::createResourceForClass(
new \ReflectionClass(__NAMESPACE__.'\Foo')
);
// test with a stale file *but* the resource will not be changed
$this->assertTrue($oldResource->isFresh($this->getStaleFileTime()), '->isFresh() returns false if the constructor arguments have changed');
}
public function testNotFreshIfClassNotFound()
{
$resource = new AutowireServiceResource(
'Some\Non\Existent\Class',
$this->file,
[]
);
$this->assertFalse($resource->isFresh($this->getStaleFileTime()), '->isFresh() returns false if the class no longer exists');
}
private function doTearDown()
{
if (!file_exists($this->file)) {
return;
}
unlink($this->file);
}
private function getStaleFileTime()
{
return $this->time - 10;
}
}
class Foo
{
public function __construct($foo)
{
}
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Config;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\ResourceCheckerInterface;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResourceChecker;
@ -19,6 +20,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class ContainerParametersResourceCheckerTest extends TestCase
{
use ForwardCompatTestTrait;
/** @var ContainerParametersResource */
private $resource;
@ -28,7 +31,7 @@ class ContainerParametersResourceCheckerTest extends TestCase
/** @var ContainerInterface */
private $container;
protected function setUp()
private function doSetUp()
{
$this->resource = new ContainerParametersResource(['locales' => ['fr', 'en'], 'default_locale' => 'fr']);
$this->container = $this->getMockBuilder(ContainerInterface::class)->getMock();

View File

@ -12,14 +12,17 @@
namespace Symfony\Component\DependencyInjection\Tests\Config;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
class ContainerParametersResourceTest extends TestCase
{
use ForwardCompatTestTrait;
/** @var ContainerParametersResource */
private $resource;
protected function setUp()
private function doSetUp()
{
$this->resource = new ContainerParametersResource(['locales' => ['fr', 'en'], 'default_locale' => 'fr']);
}

View File

@ -12,14 +12,17 @@
namespace Symfony\Component\DependencyInjection\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class CrossCheckTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = __DIR__.'/Fixtures/';

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Dumper\GraphvizDumper;
@ -19,9 +20,11 @@ use Symfony\Component\DependencyInjection\Reference;
class GraphvizDumperTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = __DIR__.'/../Fixtures/';
}

View File

@ -13,6 +13,8 @@ namespace Symfony\Component\DependencyInjection\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
@ -42,12 +44,16 @@ use Symfony\Component\ExpressionLanguage\Expression;
require_once __DIR__.'/../Fixtures/includes/autowiring_classes.php';
require_once __DIR__.'/../Fixtures/includes/classes.php';
require_once __DIR__.'/../Fixtures/includes/foo.php';
require_once __DIR__.'/../Fixtures/includes/foo_lazy.php';
class PhpDumperTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
}
@ -234,6 +240,59 @@ class PhpDumperTest extends TestCase
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_as_files.txt', $dump);
}
public function testDumpAsFilesWithFactoriesInlined()
{
$container = include self::$fixturesPath.'/containers/container9.php';
$container->setParameter('container.dumper.inline_factories', true);
$container->setParameter('container.dumper.inline_class_loader', true);
$container->getDefinition('bar')->addTag('hot');
$container->register('non_shared_foo', \Bar\FooClass::class)
->setFile(realpath(self::$fixturesPath.'/includes/foo.php'))
->setShared(false)
->setPublic(true);
$container->register('throwing_one', \Bar\FooClass::class)
->addArgument(new Reference('errored_one', ContainerBuilder::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE))
->setPublic(true);
$container->register('errored_one', 'stdClass')
->addError('No-no-no-no');
$container->compile();
$dumper = new PhpDumper($container);
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'build_time' => 1563381341]), true);
if ('\\' === \DIRECTORY_SEPARATOR) {
$dump = str_replace('\\\\Fixtures\\\\includes\\\\', '/Fixtures/includes/', $dump);
}
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_inlined_factories.txt', $dump);
}
/**
* @requires function \Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper::getProxyCode
*/
public function testDumpAsFilesWithLazyFactoriesInlined()
{
$container = new ContainerBuilder();
$container->setParameter('container.dumper.inline_factories', true);
$container->setParameter('container.dumper.inline_class_loader', true);
$container->register('lazy_foo', \Bar\FooClass::class)
->addArgument(new Definition(\Bar\FooLazyClass::class))
->setPublic(true)
->setLazy(true);
$container->compile();
$dumper = new PhpDumper($container);
$dumper->setProxyDumper(new ProxyDumper());
$dump = print_r($dumper->dump(['as_files' => true, 'file' => __DIR__, 'hot_path_tag' => 'hot', 'build_time' => 1563381341]), true);
if ('\\' === \DIRECTORY_SEPARATOR) {
$dump = str_replace('\\\\Fixtures\\\\includes\\\\', '/Fixtures/includes/', $dump);
}
$this->assertStringMatchesFormatFile(self::$fixturesPath.'/php/services9_lazy_inlined_factories.txt', $dump);
}
public function testNonSharedLazyDumpAsFiles()
{
$container = include self::$fixturesPath.'/containers/container_non_shared_lazy.php';

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
@ -23,9 +24,11 @@ use Symfony\Component\DependencyInjection\Reference;
class XmlDumperTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
@ -26,9 +27,11 @@ use Symfony\Component\Yaml\Yaml;
class YamlDumperTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
}

View File

@ -0,0 +1,572 @@
Array
(
[Container%s/removed-ids.php] => <?php
return [
'Psr\\Container\\ContainerInterface' => true,
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
'configurator_service' => true,
'configurator_service_simple' => true,
'decorated.pif-pouf' => true,
'decorator_service.inner' => true,
'errored_definition' => true,
'errored_one' => true,
'factory_simple' => true,
'inlined' => true,
'new_factory' => true,
'tagged_iterator_foo' => true,
];
[Container%s/ProjectServiceContainer.php] => <?php
namespace Container%s;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
*/
class ProjectServiceContainer extends Container
{
private $buildParameters;
private $containerDir;
private $parameters;
private $targetDirs = [];
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
{
$dir = $this->targetDirs[0] = \dirname($containerDir);
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->buildParameters = $buildParameters;
$this->containerDir = $containerDir;
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];
$this->syntheticIds = [
'request' => true,
];
$this->methodMap = [
'BAR' => 'getBARService',
'BAR2' => 'getBAR2Service',
'bar' => 'getBar3Service',
'bar2' => 'getBar22Service',
'baz' => 'getBazService',
'configured_service' => 'getConfiguredServiceService',
'configured_service_simple' => 'getConfiguredServiceSimpleService',
'decorator_service' => 'getDecoratorServiceService',
'decorator_service_with_name' => 'getDecoratorServiceWithNameService',
'deprecated_service' => 'getDeprecatedServiceService',
'factory_service' => 'getFactoryServiceService',
'factory_service_simple' => 'getFactoryServiceSimpleService',
'foo' => 'getFooService',
'foo.baz' => 'getFoo_BazService',
'foo_bar' => 'getFooBarService',
'foo_with_inline' => 'getFooWithInlineService',
'lazy_context' => 'getLazyContextService',
'lazy_context_ignore_invalid_ref' => 'getLazyContextIgnoreInvalidRefService',
'method_call1' => 'getMethodCall1Service',
'new_factory_service' => 'getNewFactoryServiceService',
'non_shared_foo' => 'getNonSharedFooService',
'runtime_error' => 'getRuntimeErrorService',
'service_from_static_method' => 'getServiceFromStaticMethodService',
'tagged_iterator' => 'getTaggedIteratorService',
'throwing_one' => 'getThrowingOneService',
];
$this->aliases = [
'alias_for_alias' => 'foo',
'alias_for_foo' => 'foo',
'decorated' => 'decorator_service_with_name',
];
$this->privates['service_container'] = function () {
include_once $this->targetDirs[0].'/Fixtures/includes/foo.php';
};
}
public function compile()
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}
public function isCompiled()
{
return true;
}
public function getRemovedIds()
{
return require $this->containerDir.\DIRECTORY_SEPARATOR.'removed-ids.php';
}
/**
* Gets the public 'BAR' shared service.
*
* @return \stdClass
*/
protected function getBARService()
{
$this->services['BAR'] = $instance = new \stdClass();
$instance->bar = ($this->services['bar'] ?? $this->getBar3Service());
return $instance;
}
/**
* Gets the public 'BAR2' shared service.
*
* @return \stdClass
*/
protected function getBAR2Service()
{
return $this->services['BAR2'] = new \stdClass();
}
/**
* Gets the public 'bar' shared service.
*
* @return \Bar\FooClass
*/
protected function getBar3Service()
{
$a = ($this->services['foo.baz'] ?? $this->getFoo_BazService());
$this->services['bar'] = $instance = new \Bar\FooClass('foo', $a, $this->getParameter('foo_bar'));
$a->configure($instance);
return $instance;
}
/**
* Gets the public 'bar2' shared service.
*
* @return \stdClass
*/
protected function getBar22Service()
{
return $this->services['bar2'] = new \stdClass();
}
/**
* Gets the public 'baz' shared service.
*
* @return \Baz
*/
protected function getBazService()
{
$this->services['baz'] = $instance = new \Baz();
$instance->setFoo(($this->services['foo_with_inline'] ?? $this->getFooWithInlineService()));
return $instance;
}
/**
* Gets the public 'configured_service' shared service.
*
* @return \stdClass
*/
protected function getConfiguredServiceService()
{
$this->services['configured_service'] = $instance = new \stdClass();
$a = new \ConfClass();
$a->setFoo(($this->services['baz'] ?? $this->getBazService()));
$a->configureStdClass($instance);
return $instance;
}
/**
* Gets the public 'configured_service_simple' shared service.
*
* @return \stdClass
*/
protected function getConfiguredServiceSimpleService()
{
$this->services['configured_service_simple'] = $instance = new \stdClass();
(new \ConfClass('bar'))->configureStdClass($instance);
return $instance;
}
/**
* Gets the public 'decorator_service' shared service.
*
* @return \stdClass
*/
protected function getDecoratorServiceService()
{
return $this->services['decorator_service'] = new \stdClass();
}
/**
* Gets the public 'decorator_service_with_name' shared service.
*
* @return \stdClass
*/
protected function getDecoratorServiceWithNameService()
{
return $this->services['decorator_service_with_name'] = new \stdClass();
}
/**
* Gets the public 'deprecated_service' shared service.
*
* @return \stdClass
*
* @deprecated The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.
*/
protected function getDeprecatedServiceService()
{
@trigger_error('The "deprecated_service" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
return $this->services['deprecated_service'] = new \stdClass();
}
/**
* Gets the public 'factory_service' shared service.
*
* @return \Bar
*/
protected function getFactoryServiceService()
{
return $this->services['factory_service'] = ($this->services['foo.baz'] ?? $this->getFoo_BazService())->getInstance();
}
/**
* Gets the public 'factory_service_simple' shared service.
*
* @return \Bar
*/
protected function getFactoryServiceSimpleService()
{
return $this->services['factory_service_simple'] = $this->getFactorySimpleService()->getInstance();
}
/**
* Gets the public 'foo' shared service.
*
* @return \Bar\FooClass
*/
protected function getFooService()
{
$a = ($this->services['foo.baz'] ?? $this->getFoo_BazService());
$this->services['foo'] = $instance = \Bar\FooClass::getInstance('foo', $a, ['bar' => 'foo is bar', 'foobar' => 'bar'], true, $this);
$instance->foo = 'bar';
$instance->moo = $a;
$instance->qux = ['bar' => 'foo is bar', 'foobar' => 'bar'];
$instance->setBar(($this->services['bar'] ?? $this->getBar3Service()));
$instance->initialize();
sc_configure($instance);
return $instance;
}
/**
* Gets the public 'foo.baz' shared service.
*
* @return \BazClass
*/
protected function getFoo_BazService()
{
include_once $this->targetDirs[0].'/Fixtures/includes/classes.php';
$this->services['foo.baz'] = $instance = \BazClass::getInstance();
\BazClass::configureStatic1($instance);
return $instance;
}
/**
* Gets the public 'foo_bar' service.
*
* @return \Bar\FooClass
*/
protected function getFooBarService()
{
return new \Bar\FooClass(($this->services['deprecated_service'] ?? $this->getDeprecatedServiceService()));
}
/**
* Gets the public 'foo_with_inline' shared service.
*
* @return \Foo
*/
protected function getFooWithInlineService()
{
$this->services['foo_with_inline'] = $instance = new \Foo();
$a = new \Bar();
$a->pub = 'pub';
$a->setBaz(($this->services['baz'] ?? $this->getBazService()));
$instance->setBar($a);
return $instance;
}
/**
* Gets the public 'lazy_context' shared service.
*
* @return \LazyContext
*/
protected function getLazyContextService()
{
include_once $this->targetDirs[0].'/Fixtures/includes/classes.php';
return $this->services['lazy_context'] = new \LazyContext(new RewindableGenerator(function () {
yield 'k1' => ($this->services['foo.baz'] ?? $this->getFoo_BazService());
yield 'k2' => $this;
}, 2), new RewindableGenerator(function () {
return new \EmptyIterator();
}, 0));
}
/**
* Gets the public 'lazy_context_ignore_invalid_ref' shared service.
*
* @return \LazyContext
*/
protected function getLazyContextIgnoreInvalidRefService()
{
include_once $this->targetDirs[0].'/Fixtures/includes/classes.php';
return $this->services['lazy_context_ignore_invalid_ref'] = new \LazyContext(new RewindableGenerator(function () {
yield 0 => ($this->services['foo.baz'] ?? $this->getFoo_BazService());
}, 1), new RewindableGenerator(function () {
return new \EmptyIterator();
}, 0));
}
/**
* Gets the public 'method_call1' shared service.
*
* @return \Bar\FooClass
*/
protected function getMethodCall1Service()
{
include_once ($this->targetDirs[0].'/Fixtures/includes/foo.php');
$this->services['method_call1'] = $instance = new \Bar\FooClass();
$instance->setBar(($this->services['foo'] ?? $this->getFooService()));
$instance->setBar(NULL);
$instance->setBar((($this->services['foo'] ?? $this->getFooService())->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
return $instance;
}
/**
* Gets the public 'new_factory_service' shared service.
*
* @return \FooBarBaz
*/
protected function getNewFactoryServiceService()
{
$a = new \FactoryClass();
$a->foo = 'bar';
$this->services['new_factory_service'] = $instance = $a->getInstance();
$instance->foo = 'bar';
return $instance;
}
/**
* Gets the public 'non_shared_foo' service.
*
* @return \Bar\FooClass
*/
protected function getNonSharedFooService()
{
include_once ($this->targetDirs[0].'/Fixtures/includes/foo.php');
return new \Bar\FooClass();
}
/**
* Gets the public 'runtime_error' shared service.
*
* @return \stdClass
*/
protected function getRuntimeErrorService()
{
return $this->services['runtime_error'] = new \stdClass($this->throw('Service "errored_definition" is broken.'));
}
/**
* Gets the public 'service_from_static_method' shared service.
*
* @return \Bar\FooClass
*/
protected function getServiceFromStaticMethodService()
{
return $this->services['service_from_static_method'] = \Bar\FooClass::getInstance();
}
/**
* Gets the public 'tagged_iterator' shared service.
*
* @return \Bar
*/
protected function getTaggedIteratorService()
{
return $this->services['tagged_iterator'] = new \Bar(new RewindableGenerator(function () {
yield 0 => ($this->services['foo'] ?? $this->getFooService());
yield 1 => ($this->privates['tagged_iterator_foo'] ?? ($this->privates['tagged_iterator_foo'] = new \Bar()));
}, 2));
}
/**
* Gets the public 'throwing_one' shared service.
*
* @return \Bar\FooClass
*/
protected function getThrowingOneService()
{
return $this->services['throwing_one'] = new \Bar\FooClass($this->throw('No-no-no-no'));
}
/**
* Gets the private 'factory_simple' shared service.
*
* @return \SimpleFactoryClass
*
* @deprecated The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.
*/
protected function getFactorySimpleService()
{
@trigger_error('The "factory_simple" service is deprecated. You should stop using it, as it will be removed in the future.', E_USER_DEPRECATED);
return new \SimpleFactoryClass('foo');
}
public function getParameter($name)
{
$name = (string) $name;
if (isset($this->buildParameters[$name])) {
return $this->buildParameters[$name];
}
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
}
if (isset($this->loadedDynamicParameters[$name])) {
return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
}
return $this->parameters[$name];
}
public function hasParameter($name)
{
$name = (string) $name;
if (isset($this->buildParameters[$name])) {
return true;
}
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
}
public function setParameter($name, $value)
{
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
}
public function getParameterBag()
{
if (null === $this->parameterBag) {
$parameters = $this->parameters;
foreach ($this->loadedDynamicParameters as $name => $loaded) {
$parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
}
foreach ($this->buildParameters as $name => $value) {
$parameters[$name] = $value;
}
$this->parameterBag = new FrozenParameterBag($parameters);
}
return $this->parameterBag;
}
private $loadedDynamicParameters = [];
private $dynamicParameters = [];
/**
* Computes a dynamic parameter.
*
* @param string $name The name of the dynamic parameter to load
*
* @return mixed The value of the dynamic parameter
*
* @throws InvalidArgumentException When the dynamic parameter does not exist
*/
private function getDynamicParameter($name)
{
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
}
/**
* Gets the default parameters.
*
* @return array An array of the default parameters
*/
protected function getDefaultParameters()
{
return [
'baz_class' => 'BazClass',
'foo_class' => 'Bar\\FooClass',
'foo' => 'bar',
'container.dumper.inline_factories' => true,
'container.dumper.inline_class_loader' => true,
];
}
protected function throw($message)
{
throw new RuntimeException($message);
}
}
[ProjectServiceContainer.php] => <?php
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
if (\class_exists(\Container%s\ProjectServiceContainer::class, false)) {
// no-op
} elseif (!include __DIR__.'/Container%s/ProjectServiceContainer.php') {
touch(__DIR__.'/Container%s.legacy');
return;
}
if (!\class_exists(ProjectServiceContainer::class, false)) {
\class_alias(\Container%s\ProjectServiceContainer::class, ProjectServiceContainer::class, false);
}
return new \Container%s\ProjectServiceContainer([
'container.build_hash' => '%s',
'container.build_id' => '%s',
'container.build_time' => 1563381341,
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
)

View File

@ -0,0 +1,206 @@
Array
(
[Container%s/removed-ids.php] => <?php
return [
'Psr\\Container\\ContainerInterface' => true,
'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true,
];
[Container%s/ProjectServiceContainer.php] => <?php
namespace Container%s;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
*/
class ProjectServiceContainer extends Container
{
private $buildParameters;
private $containerDir;
private $parameters;
private $targetDirs = [];
public function __construct(array $buildParameters = [], $containerDir = __DIR__)
{
$dir = $this->targetDirs[0] = \dirname($containerDir);
for ($i = 1; $i <= 5; ++$i) {
$this->targetDirs[$i] = $dir = \dirname($dir);
}
$this->buildParameters = $buildParameters;
$this->containerDir = $containerDir;
$this->parameters = $this->getDefaultParameters();
$this->services = $this->privates = [];
$this->methodMap = [
'lazy_foo' => 'getLazyFooService',
];
$this->aliases = [];
}
public function compile()
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}
public function isCompiled()
{
return true;
}
public function getRemovedIds()
{
return require $this->containerDir.\DIRECTORY_SEPARATOR.'removed-ids.php';
}
protected function createProxy($class, \Closure $factory)
{
class_exists($class, false) || class_alias(__NAMESPACE__."\\$class", $class, false);
return $factory();
}
/**
* Gets the public 'lazy_foo' shared service.
*
* @return \Bar\FooClass
*/
protected function getLazyFooService($lazyLoad = true)
{
if ($lazyLoad) {
return $this->services['lazy_foo'] = $this->createProxy('FooClass_%s', function () {
return \FooClass_%s::staticProxyConstructor(function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) {
$wrappedInstance = $this->getLazyFooService(false);
$proxy->setProxyInitializer(null);
return true;
});
});
}
include_once $this->targetDirs[0].'/Fixtures/includes/foo_lazy.php';
return new \Bar\FooClass(new \Bar\FooLazyClass());
}
public function getParameter($name)
{
$name = (string) $name;
if (isset($this->buildParameters[$name])) {
return $this->buildParameters[$name];
}
if (!(isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters))) {
throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name));
}
if (isset($this->loadedDynamicParameters[$name])) {
return $this->loadedDynamicParameters[$name] ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
}
return $this->parameters[$name];
}
public function hasParameter($name)
{
$name = (string) $name;
if (isset($this->buildParameters[$name])) {
return true;
}
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
}
public function setParameter($name, $value)
{
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
}
public function getParameterBag()
{
if (null === $this->parameterBag) {
$parameters = $this->parameters;
foreach ($this->loadedDynamicParameters as $name => $loaded) {
$parameters[$name] = $loaded ? $this->dynamicParameters[$name] : $this->getDynamicParameter($name);
}
foreach ($this->buildParameters as $name => $value) {
$parameters[$name] = $value;
}
$this->parameterBag = new FrozenParameterBag($parameters);
}
return $this->parameterBag;
}
private $loadedDynamicParameters = [];
private $dynamicParameters = [];
/**
* Computes a dynamic parameter.
*
* @param string $name The name of the dynamic parameter to load
*
* @return mixed The value of the dynamic parameter
*
* @throws InvalidArgumentException When the dynamic parameter does not exist
*/
private function getDynamicParameter($name)
{
throw new InvalidArgumentException(sprintf('The dynamic parameter "%s" must be defined.', $name));
}
/**
* Gets the default parameters.
*
* @return array An array of the default parameters
*/
protected function getDefaultParameters()
{
return [
'container.dumper.inline_factories' => true,
'container.dumper.inline_class_loader' => true,
];
}
}
include_once \dirname(__DIR__, 1 + 0).'/Fixtures/includes/foo.php';
class FooClass_%s extends \Bar\FooClass implements \ProxyManager\Proxy\VirtualProxyInterface
{
%A
}
[ProjectServiceContainer.php] => <?php
// This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
if (\class_exists(\Container%s\ProjectServiceContainer::class, false)) {
// no-op
} elseif (!include __DIR__.'/Container%s/ProjectServiceContainer.php') {
touch(__DIR__.'/Container%s.legacy');
return;
}
if (!\class_exists(ProjectServiceContainer::class, false)) {
\class_alias(\Container%s\ProjectServiceContainer::class, ProjectServiceContainer::class, false);
}
return new \Container%s\ProjectServiceContainer([
'container.build_hash' => '%s',
'container.build_id' => '%s',
'container.build_time' => 1563381341,
], __DIR__.\DIRECTORY_SEPARATOR.'Container%s');
)

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -22,17 +23,19 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
class DirectoryLoaderTest extends TestCase
{
use ForwardCompatTestTrait;
private static $fixturesPath;
private $container;
private $loader;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
}
protected function setUp()
private function doSetUp()
{
$locator = new FileLocator(self::$fixturesPath);
$this->container = new ContainerBuilder();

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface as PsrContainerInterface;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -34,9 +35,11 @@ use Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\BarInterf
class FileLoaderTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/../');
}

View File

@ -12,16 +12,19 @@
namespace Symfony\Component\DependencyInjection\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
class IniFileLoaderTest extends TestCase
{
use ForwardCompatTestTrait;
protected $container;
protected $loader;
protected function setUp()
private function doSetUp()
{
$this->container = new ContainerBuilder();
$this->loader = new IniFileLoader($this->container, new FileLocator(realpath(__DIR__.'/../Fixtures/').'/ini'));

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@ -23,12 +24,14 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
class LoaderResolverTest extends TestCase
{
use ForwardCompatTestTrait;
private static $fixturesPath;
/** @var LoaderResolver */
private $resolver;
protected function setUp()
private function doSetUp()
{
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\DependencyInjection\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Config\Resource\FileResource;
@ -36,9 +37,11 @@ use Symfony\Component\ExpressionLanguage\Expression;
class XmlFileLoaderTest extends TestCase
{
use ForwardCompatTestTrait;
protected static $fixturesPath;
public static function setUpBeforeClass()
private static function doSetUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
require_once self::$fixturesPath.'/includes/foo.php';

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