From 4201d419a2b355d9c3f6db06bdc38370adbc95bb Mon Sep 17 00:00:00 2001 From: Matthew Davis Date: Fri, 6 Dec 2013 17:04:55 -0500 Subject: [PATCH 1/2] fix issue #8171 on configuration tree for twig extension -- pairing up with @cordoval --- .../Bundle/TwigBundle/DependencyInjection/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 4089aee5a1..5d46be0b32 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -136,6 +136,7 @@ class Configuration implements ConfigurationInterface ->scalarNode('optimizations')->end() ->arrayNode('paths') ->normalizeKeys(false) + ->useAttributeAsKey('paths') ->beforeNormalization() ->always() ->then(function ($paths) { From 9aa88e44943c4a366de338877d6a5274f6ff3c13 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sun, 22 Dec 2013 02:17:37 -0500 Subject: [PATCH 2/2] added regression test --- .../Tests/DependencyInjection/Fixtures/php/extra.php | 7 +++++++ .../Tests/DependencyInjection/Fixtures/php/full.php | 4 ++-- .../Tests/DependencyInjection/Fixtures/xml/extra.xml | 12 ++++++++++++ .../Tests/DependencyInjection/Fixtures/xml/full.xml | 4 ++-- .../Tests/DependencyInjection/Fixtures/yml/extra.yml | 3 +++ .../Tests/DependencyInjection/Fixtures/yml/full.yml | 4 ++-- .../Tests/DependencyInjection/TwigExtensionTest.php | 6 ++++-- src/Symfony/Component/Finder/Tests/FinderTest.php | 3 +-- 8 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php new file mode 100644 index 0000000000..47d00ef445 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php @@ -0,0 +1,7 @@ +loadFromExtension('twig', array( + 'paths' => array( + 'namespaced_path3' => 'namespace3', + ), +)); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php index 24ba3f60d3..3d2a14d00d 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -22,7 +22,7 @@ $container->loadFromExtension('twig', array( 'paths' => array( 'path1', 'path2', - 'namespaced_path1' => 'namespace', - 'namespaced_path2' => 'namespace', + 'namespaced_path1' => 'namespace1', + 'namespaced_path2' => 'namespace2', ), )); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml new file mode 100644 index 0000000000..174b3e1b6c --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml @@ -0,0 +1,12 @@ + + + + + + namespaced_path3 + + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 85e2d8fd9a..3e1acaeb6e 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -15,7 +15,7 @@ 3.14 path1 path2 - namespaced_path1 - namespaced_path2 + namespaced_path1 + namespaced_path2 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml new file mode 100644 index 0000000000..3c5e6a3b59 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml @@ -0,0 +1,3 @@ +twig: + paths: + namespaced_path3: namespace3 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index ecbc92aff3..1d453c553f 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -17,5 +17,5 @@ twig: paths: path1: '' path2: '' - namespaced_path1: namespace - namespaced_path2: namespace + namespaced_path1: namespace1 + namespaced_path2: namespace2 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 558187486d..6d0fc467e5 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -145,6 +145,7 @@ class TwigExtensionTest extends TestCase $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $this->loadFromFile($container, 'full', $format); + $this->loadFromFile($container, 'extra', $format); $this->compileContainer($container); $def = $container->getDefinition('twig.loader.filesystem'); @@ -160,8 +161,9 @@ class TwigExtensionTest extends TestCase $this->assertEquals(array( array('path1'), array('path2'), - array('namespaced_path1', 'namespace'), - array('namespaced_path2', 'namespace'), + array('namespaced_path1', 'namespace1'), + array('namespaced_path2', 'namespace2'), + array('namespaced_path3', 'namespace3'), array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'), array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'), array(__DIR__.'/Fixtures/Resources/views'), diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index a42b0d7c65..9f9e47b646 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -16,7 +16,6 @@ use Symfony\Component\Finder\Adapter; class FinderTest extends Iterator\RealIteratorTestCase { - public function testCreate() { $this->assertInstanceOf('Symfony\Component\Finder\Finder', Finder::create()); @@ -796,7 +795,7 @@ class FinderTest extends Iterator\RealIteratorTestCase ); } - /** + /** * Searching in multiple locations with sub directories involves * AppendIterator which does an unnecessary rewind which leaves * FilterIterator with inner FilesystemIterator in an invalid state.