Use ExpectDeprecationTrait
This commit is contained in:
parent
6dc7d8b211
commit
08febef500
@ -12,10 +12,13 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
|
||||
class AliasTest extends TestCase
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$alias = new Alias('foo');
|
||||
@ -59,10 +62,11 @@ class AliasTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Alias::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.
|
||||
*/
|
||||
public function testItHasADefaultDeprecationMessage()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Alias::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
|
||||
|
||||
$alias = new Alias('foo', false);
|
||||
$alias->setDeprecated();
|
||||
|
||||
@ -72,10 +76,11 @@ class AliasTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Alias::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.
|
||||
*/
|
||||
public function testSetDeprecatedWithoutPackageAndVersion()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Alias::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
|
||||
|
||||
$def = new Alias('stdClass');
|
||||
$def->setDeprecated(true, '%alias_id%');
|
||||
|
||||
@ -98,11 +103,12 @@ class AliasTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Alias::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: Passing a null message to un-deprecate a node is deprecated.
|
||||
*/
|
||||
public function testCanOverrideDeprecation()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Alias::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Passing a null message to un-deprecate a node is deprecated.');
|
||||
|
||||
$alias = new Alias('foo', false);
|
||||
$alias->setDeprecated('vendor/package', '1.1', 'The "%alias_id%" is deprecated.');
|
||||
$this->assertTrue($alias->isDeprecated());
|
||||
|
@ -12,12 +12,15 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
class ResolveChildDefinitionsPassTest extends TestCase
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
public function testProcess()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
@ -310,11 +313,12 @@ class ResolveChildDefinitionsPassTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Definition::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: Passing a null message to un-deprecate a node is deprecated.
|
||||
*/
|
||||
public function testDecoratedServiceCanOverwriteDeprecatedParentStatus()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Definition::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Passing a null message to un-deprecate a node is deprecated.');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('deprecated_parent')
|
||||
->setDeprecated(true)
|
||||
|
@ -17,6 +17,7 @@ require_once __DIR__.'/Fixtures/includes/ProjectExtension.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface as PsrContainerInterface;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\Config\Resource\ComposerResource;
|
||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
@ -50,6 +51,8 @@ use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
class ContainerBuilderTest extends TestCase
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
public function testDefaultRegisteredDefinitions()
|
||||
{
|
||||
$builder = new ContainerBuilder();
|
||||
@ -94,10 +97,11 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "deprecated_foo" service is deprecated. You should stop using it, as it will be removed in the future.
|
||||
*/
|
||||
public function testCreateDeprecatedService()
|
||||
{
|
||||
$this->expectDeprecation('The "deprecated_foo" service is deprecated. You should stop using it, as it will be removed in the future.');
|
||||
|
||||
$definition = new Definition('stdClass');
|
||||
$definition->setDeprecated(true);
|
||||
|
||||
@ -293,10 +297,11 @@ class ContainerBuilderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "foobar" service alias is deprecated. You should stop using it, as it will be removed in the future.
|
||||
*/
|
||||
public function testDeprecatedAlias()
|
||||
{
|
||||
$this->expectDeprecation('The "foobar" service alias is deprecated. You should stop using it, as it will be removed in the future.');
|
||||
|
||||
$builder = new ContainerBuilder();
|
||||
$builder->register('foo', 'stdClass');
|
||||
|
||||
|
@ -12,12 +12,15 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class DefinitionTest extends TestCase
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$def = new Definition('stdClass');
|
||||
@ -185,10 +188,11 @@ class DefinitionTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Definition::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.
|
||||
*/
|
||||
public function testSetDeprecatedWithoutPackageAndVersion()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Definition::setDeprecated()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
|
||||
|
||||
$def = new Definition('stdClass');
|
||||
$def->setDeprecated(true, '%service_id%');
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
|
||||
@ -20,6 +21,8 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
|
||||
class PhpFileLoaderTest extends TestCase
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new PhpFileLoader(new ContainerBuilder(), new FileLocator());
|
||||
@ -103,10 +106,11 @@ class PhpFileLoaderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Loader\Configurator\Traits\DeprecateTrait::deprecate()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.
|
||||
*/
|
||||
public function testDeprecatedWithoutPackageAndVersion()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: The signature of method "Symfony\Component\DependencyInjection\Loader\Configurator\Traits\DeprecateTrait::deprecate()" requires 3 arguments: "string $package, string $version, string $message", not defining them is deprecated.');
|
||||
|
||||
$fixtures = realpath(__DIR__.'/../Fixtures');
|
||||
$loader = new PhpFileLoader($container = new ContainerBuilder(), new FileLocator());
|
||||
$loader->load($fixtures.'/config/deprecated_without_package_version.php');
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
@ -39,6 +40,8 @@ use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
class XmlFileLoaderTest extends TestCase
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
@ -403,10 +406,11 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" is deprecated.
|
||||
*/
|
||||
public function testDeprecatedWithoutPackageAndVersion()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" is deprecated.');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
$loader->load('services_deprecated_without_package_and_version.xml');
|
||||
@ -435,10 +439,11 @@ class XmlFileLoaderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" is deprecated.
|
||||
*/
|
||||
public function testDeprecatedAliaseWithoutPackageAndVersion()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the node "deprecated" is deprecated.');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
$loader->load('deprecated_alias_definitions_without_package_and_version.xml');
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
@ -38,6 +39,8 @@ use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
class YamlFileLoaderTest extends TestCase
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
@ -232,11 +235,12 @@ class YamlFileLoaderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the "deprecated" option is deprecated.
|
||||
* @expectedDeprecation Since symfony/dependency-injection 5.1: Not setting the attribute "version" of the "deprecated" option is deprecated.
|
||||
*/
|
||||
public function testDeprecatedAliasesWithoutPackageAndVersion()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "package" of the "deprecated" option is deprecated.');
|
||||
$this->expectDeprecation('Since symfony/dependency-injection 5.1: Not setting the attribute "version" of the "deprecated" option is deprecated.');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('deprecated_alias_definitions_without_package_and_version.yml');
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
|
||||
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\Form\Tests\Fixtures\ChoiceList\DeprecatedChoiceListFactory
|
||||
|
||||
class ChoiceTypeTest extends BaseTypeTest
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\ChoiceType';
|
||||
|
||||
private $choices = [
|
||||
@ -2146,13 +2149,13 @@ class ChoiceTypeTest extends BaseTypeTest
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*
|
||||
* @expectedDeprecation The "Symfony\Component\Form\Tests\Fixtures\ChoiceList\DeprecatedChoiceListFactory::createListFromChoices()" method will require a new "callable|null $filter" argument in the next major version of its interface "Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface", not defining it is deprecated.
|
||||
* @expectedDeprecation The "Symfony\Component\Form\Tests\Fixtures\ChoiceList\DeprecatedChoiceListFactory::createListFromLoader()" method will require a new "callable|null $filter" argument in the next major version of its interface "Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface", not defining it is deprecated.
|
||||
* @expectedDeprecation Since symfony/form 5.1: Not defining a third parameter "callable|null $filter" in "Symfony\Component\Form\Tests\Fixtures\ChoiceList\DeprecatedChoiceListFactory::createListFromChoices()" is deprecated.
|
||||
*/
|
||||
public function testUsingDeprecatedChoiceListFactory()
|
||||
{
|
||||
$this->expectDeprecation('The "Symfony\Component\Form\Tests\Fixtures\ChoiceList\DeprecatedChoiceListFactory::createListFromChoices()" method will require a new "callable|null $filter" argument in the next major version of its interface "Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface", not defining it is deprecated.');
|
||||
$this->expectDeprecation('The "Symfony\Component\Form\Tests\Fixtures\ChoiceList\DeprecatedChoiceListFactory::createListFromLoader()" method will require a new "callable|null $filter" argument in the next major version of its interface "Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface", not defining it is deprecated.');
|
||||
$this->expectDeprecation('Since symfony/form 5.1: Not defining a third parameter "callable|null $filter" in "Symfony\Component\Form\Tests\Fixtures\ChoiceList\DeprecatedChoiceListFactory::createListFromChoices()" is deprecated.');
|
||||
|
||||
new ChoiceType(new DeprecatedChoiceListFactory());
|
||||
}
|
||||
}
|
||||
|
@ -13,18 +13,22 @@ namespace Symfony\Component\HttpKernel\Tests\Controller;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;
|
||||
|
||||
class ContainerControllerResolverTest extends ControllerResolverTest
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Since symfony/http-kernel 5.1: Referencing controllers with a single colon is deprecated. Use "foo::action" instead.
|
||||
*/
|
||||
public function testGetControllerServiceWithSingleColon()
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/http-kernel 5.1: Referencing controllers with a single colon is deprecated. Use "foo::action" instead.');
|
||||
|
||||
$service = new ControllerTestService('foo');
|
||||
|
||||
$container = $this->createMockContainer();
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Yaml\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Inline;
|
||||
use Symfony\Component\Yaml\Tag\TaggedValue;
|
||||
@ -19,6 +20,8 @@ use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class InlineTest extends TestCase
|
||||
{
|
||||
use ExpectDeprecationTrait;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
Inline::initialize(0, 0);
|
||||
@ -742,11 +745,11 @@ class InlineTest extends TestCase
|
||||
* @dataProvider phpObjectTagWithEmptyValueProvider
|
||||
*
|
||||
* @group legacy
|
||||
*
|
||||
* @expectedDeprecation Since symfony/yaml 5.1: Using the !php/object tag without a value is deprecated.
|
||||
*/
|
||||
public function testPhpObjectWithEmptyValue($expected, $value)
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/yaml 5.1: Using the !php/object tag without a value is deprecated.');
|
||||
|
||||
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT));
|
||||
}
|
||||
|
||||
@ -766,11 +769,11 @@ class InlineTest extends TestCase
|
||||
* @dataProvider phpConstTagWithEmptyValueProvider
|
||||
*
|
||||
* @group legacy
|
||||
*
|
||||
* @expectedDeprecation Since symfony/yaml 5.1: Using the !php/const tag without a value is deprecated.
|
||||
*/
|
||||
public function testPhpConstTagWithEmptyValue($expected, $value)
|
||||
{
|
||||
$this->expectDeprecation('Since symfony/yaml 5.1: Using the !php/const tag without a value is deprecated.');
|
||||
|
||||
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user