[DependencyInjection] Fixed deprecated default message template with XML
This commit is contained in:
parent
af47008bc9
commit
165529bb55
@ -187,7 +187,7 @@ class XmlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
if ($deprecated = $this->getChildren($service, 'deprecated')) {
|
||||
$definition->setDeprecated(true, $deprecated[0]->nodeValue);
|
||||
$definition->setDeprecated(true, $deprecated[0]->nodeValue ?: null);
|
||||
}
|
||||
|
||||
$definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<services>
|
||||
<service id="foo" class="Foo">
|
||||
<deprecated />
|
||||
</service>
|
||||
<service id="bar" class="Bar">
|
||||
<deprecated>The "%service_id%" service is deprecated.</deprecated>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
@ -324,6 +324,21 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$loader->load('tag_with_empty_name.xml');
|
||||
}
|
||||
|
||||
public function testDeprecated()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
$loader->load('services_deprecated.xml');
|
||||
|
||||
$this->assertTrue($container->getDefinition('foo')->isDeprecated());
|
||||
$message = 'The "foo" service is deprecated. You should stop using it, as it will soon be removed.';
|
||||
$this->assertSame($message, $container->getDefinition('foo')->getDeprecationMessage('foo'));
|
||||
|
||||
$this->assertTrue($container->getDefinition('bar')->isDeprecated());
|
||||
$message = 'The "bar" service is deprecated.';
|
||||
$this->assertSame($message, $container->getDefinition('bar')->getDeprecationMessage('bar'));
|
||||
}
|
||||
|
||||
public function testConvertDomElementToArray()
|
||||
{
|
||||
$doc = new \DOMDocument('1.0');
|
||||
|
Reference in New Issue
Block a user