Skip to content

Commit

Permalink
Remove deprecations in tests
Browse files Browse the repository at this point in the history
The one for symfony/config 5.1 is based on doctrine/DoctrineBundle#1160
  • Loading branch information
franmomu committed Sep 9, 2020
1 parent 5af6ad5 commit 716642a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -37,10 +37,10 @@
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4 || ^5.1",
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/framework-bundle": "^4.4 || ^5.1",
"symfony/http-foundation": "^4.4 || ^5.1",
"symfony/http-kernel": "^4.4 || ^5.1",
"symfony/phpunit-bridge": "^5.1",
"symfony/phpunit-bridge": "^5.1.1",
"symfony/twig-bundle": "^4.4 || ^5.1"
},
"config": {
Expand Down
19 changes: 18 additions & 1 deletion src/Bridge/Symfony/DependencyInjection/Configuration.php
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\Twig\Bridge\Symfony\DependencyInjection;

use Symfony\Component\Config\Definition\BaseNode;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand Down Expand Up @@ -63,7 +64,7 @@ private function addFlashMessageSection(ArrayNodeDefinition $node): void
->children()
->scalarNode('domain')
->defaultValue('SonataTwigBundle')
->setDeprecated('The child node "%node%" at path "%path%" is deprecated since sonata-project/twig-extensions 1.4 and will be removed in 2.0 version. Translate you message before add it to session flash.')
->setDeprecated(...$this->getDomainParamDeprecationMsg())
->end()
->end()
->end()
Expand All @@ -74,4 +75,20 @@ private function addFlashMessageSection(ArrayNodeDefinition $node): void
->end()
;
}

// BC layer for deprecation messages for symfony/config < 5.1
private function getDomainParamDeprecationMsg(): array
{
$message = 'The child node "%node%" at path "%path%" is deprecated since sonata-project/twig-extensions 1.4 and will be removed in 2.0 version. Translate you message before add it to session flash.';

if (method_exists(BaseNode::class, 'getDeprecation')) {
return [
'sonata-project/twig-extensions',
'1.4',
$message,
];
}

return [$message];
}
}
2 changes: 2 additions & 0 deletions tests/App/config.yml
Expand Up @@ -7,5 +7,7 @@ framework:
name: 'MOCKSESSID'

twig:
exception_controller: null
paths:
- '%kernel.project_dir%/templates'
strict_variables: '%kernel.debug%'
1 change: 0 additions & 1 deletion tests/Node/TemplateBoxNodeTest.php
Expand Up @@ -32,7 +32,6 @@ public function testConstructor(): void
}

/**
* @covers \Twig_Node_Block::compile
* @dataProvider getTests
*/
public function testCompile($node, $source, $environment = null, $isPattern = false): void
Expand Down

0 comments on commit 716642a

Please sign in to comment.