From e3863bf1c1816bba391f01337b0d1b717fb542d2 Mon Sep 17 00:00:00 2001 From: Maximilian Berghoff Date: Tue, 13 Nov 2018 09:36:52 +0100 Subject: [PATCH] change template path to new pattern (#292) * adjust template paths to use the new pattern for symfony 4 * fix testing configuration --- CHANGELOG.md | 8 ++++++++ phpunit.xml.dist | 9 +++++++-- src/Block/ContainerBlockService.php | 2 +- src/Block/MenuBlockService.php | 2 +- src/Block/SimpleBlockService.php | 2 +- src/Block/StringBlockService.php | 2 +- src/DependencyInjection/CmfBlockExtension.php | 8 ++++---- src/Resources/config/services.xml | 2 +- tests/Fixtures/App/config/admin-test.xml | 2 +- tests/Functional/Block/ContainerBlockServiceTest.php | 4 ++-- tests/Functional/Block/MenuBlockServiceTest.php | 2 +- tests/Functional/Block/SimpleBlockServiceTest.php | 2 +- tests/Functional/Block/StringBlockServiceTest.php | 2 +- tests/Unit/DependencyInjection/XmlSchemaTest.php | 2 +- tests/WebTest/Render/ReferenceBlockRenderTest.php | 1 + 15 files changed, 32 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3ddd8c5..aeb490e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Changelog ========= +2.1.1 +----- + +* **2018-11-13**: [BUGFIX] Older template path `CmfBlockBundl:Block:some-template.html.twig` is replaced to `@CmfBlock/Block/some-template.html.twig` to be recognized by newer Symfony versions + +2.1.0 +----- + * **2017-11-16**: Removed php 5.6 and 7.0 support, removed Symfony 3.0.* and 3.1.* support 2.0.0 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5223ea29..9e2fa8ea 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,8 +5,13 @@ bootstrap="vendor/symfony-cmf/testing/bootstrap/bootstrap.php" > - - ./tests/ + + ./tests/Unit + + + + ./tests/WebTest + ./tests/Functional diff --git a/src/Block/ContainerBlockService.php b/src/Block/ContainerBlockService.php index 7a14f008..b6b07e5c 100644 --- a/src/Block/ContainerBlockService.php +++ b/src/Block/ContainerBlockService.php @@ -30,7 +30,7 @@ class ContainerBlockService extends AbstractBlockService implements BlockService /** * @var string */ - protected $template = 'CmfBlockBundle:Block:block_container.html.twig'; + protected $template = '@CmfBlock/Block/block_container.html.twig'; /** * @param string $name diff --git a/src/Block/MenuBlockService.php b/src/Block/MenuBlockService.php index b0275b7c..5cf2c0c3 100644 --- a/src/Block/MenuBlockService.php +++ b/src/Block/MenuBlockService.php @@ -25,7 +25,7 @@ */ class MenuBlockService extends AbstractBlockService implements BlockServiceInterface { - protected $template = 'CmfBlockBundle:Block:block_menu.html.twig'; + protected $template = '@CmfBlock/Block/block_menu.html.twig'; public function __construct($name, $templating, $template = null) { diff --git a/src/Block/SimpleBlockService.php b/src/Block/SimpleBlockService.php index c28d7da8..f8b36c0f 100644 --- a/src/Block/SimpleBlockService.php +++ b/src/Block/SimpleBlockService.php @@ -20,7 +20,7 @@ class SimpleBlockService extends AbstractBlockService implements BlockServiceInterface { - protected $template = 'CmfBlockBundle:Block:block_simple.html.twig'; + protected $template = '@CmfBlock/Block/block_simple.html.twig'; public function __construct($name, $templating, $template = null) { diff --git a/src/Block/StringBlockService.php b/src/Block/StringBlockService.php index 5aa8fb52..47cf5fe6 100644 --- a/src/Block/StringBlockService.php +++ b/src/Block/StringBlockService.php @@ -20,7 +20,7 @@ class StringBlockService extends AbstractBlockService implements BlockServiceInterface { - protected $template = 'CmfBlockBundle:Block:block_string.html.twig'; + protected $template = '@CmfBlock/Block/block_string.html.twig'; public function __construct($name, $templating, $template = null) { diff --git a/src/DependencyInjection/CmfBlockExtension.php b/src/DependencyInjection/CmfBlockExtension.php index 9c14fac9..a2b39d09 100644 --- a/src/DependencyInjection/CmfBlockExtension.php +++ b/src/DependencyInjection/CmfBlockExtension.php @@ -31,7 +31,7 @@ public function prepend(ContainerBuilder $container) if (isset($bundles['SonataBlockBundle'])) { $config = [ 'templates' => [ - 'block_base' => 'CmfBlockBundle:Block:block_base.html.twig', + 'block_base' => '@CmfBlock/Block/block_base.html.twig', ], 'blocks_by_class' => [ 0 => [ @@ -40,7 +40,7 @@ public function prepend(ContainerBuilder $container) 'title' => 'Insert the rss title', 'url' => false, 'maxItems' => 10, - 'template' => 'CmfBlockBundle:Block:block_rss.html.twig', + 'template' => '@CmfBlock/Block/block_rss.html.twig', 'itemClass' => 'Symfony\\Cmf\\Bundle\\BlockBundle\\Model\\FeedItem', ], ], @@ -93,9 +93,9 @@ private function loadPhpcr(array $config, XmlFileLoader $loader, ContainerBuilde $bundles = $container->getParameter('kernel.bundles'); if (isset($bundles['CmfCreateBundle'])) { $blockLoader = $container->getDefinition('cmf.block.simple'); - $blockLoader->addMethodCall('setTemplate', ['CmfBlockBundle:Block:block_simple_createphp.html.twig']); + $blockLoader->addMethodCall('setTemplate', ['@CmfBlock/Block/block_simple_createphp.html.twig']); $blockLoader = $container->getDefinition('cmf.block.string'); - $blockLoader->addMethodCall('setTemplate', ['CmfBlockBundle:Block:block_string_createphp.html.twig']); + $blockLoader->addMethodCall('setTemplate', ['@CmfBlock/Block/block_string_createphp.html.twig']); } if (isset($bundles['CmfMenuBundle'])) { diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 885c820d..95c1f4d3 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -47,7 +47,7 @@ cmf.block.slideshow - CmfBlockBundle:Block:block_slideshow.html.twig + @CmfBlock/Block/block_slideshow.html.twig diff --git a/tests/Fixtures/App/config/admin-test.xml b/tests/Fixtures/App/config/admin-test.xml index ab0e6869..a8aecf8e 100644 --- a/tests/Fixtures/App/config/admin-test.xml +++ b/tests/Fixtures/App/config/admin-test.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - + diff --git a/tests/Functional/Block/ContainerBlockServiceTest.php b/tests/Functional/Block/ContainerBlockServiceTest.php index 49771dc0..30d17d84 100644 --- a/tests/Functional/Block/ContainerBlockServiceTest.php +++ b/tests/Functional/Block/ContainerBlockServiceTest.php @@ -39,7 +39,7 @@ public function testExecutionOfDisabledBlock() public function testExecutionOfEnabledBlock() { - $template = 'CmfBlockBundle:Block:block_container.html.twig'; + $template = '@CmfBlock/Block/block_container.html.twig'; $simpleBlock1 = new SimpleBlock(); $simpleBlock1->setId(1); @@ -86,7 +86,7 @@ public function testExecutionOfEnabledBlock() public function testExecutionOfBlockWithNoChildren() { - $template = 'CmfBlockBundle:Block:block_container.html.twig'; + $template = '@CmfBlock/Block/block_container.html.twig'; $childrenCollectionMock = $this->createMock(ChildrenCollection::class); diff --git a/tests/Functional/Block/MenuBlockServiceTest.php b/tests/Functional/Block/MenuBlockServiceTest.php index 035389fc..e415bb8e 100644 --- a/tests/Functional/Block/MenuBlockServiceTest.php +++ b/tests/Functional/Block/MenuBlockServiceTest.php @@ -40,7 +40,7 @@ public function testExecutionOfDisabledBlock() public function testExecutionOfEnabledBlock() { - $template = 'CmfBlockBundle:Block:block_menu.html.twig'; + $template = '@CmfBlock/Block/block_menu.html.twig'; $menuNode = new MenuNode(); $menuBlock = new MenuBlock(); diff --git a/tests/Functional/Block/SimpleBlockServiceTest.php b/tests/Functional/Block/SimpleBlockServiceTest.php index 81416a62..dce7bdac 100644 --- a/tests/Functional/Block/SimpleBlockServiceTest.php +++ b/tests/Functional/Block/SimpleBlockServiceTest.php @@ -20,7 +20,7 @@ class SimpleBlockServiceTest extends \PHPUnit_Framework_TestCase { public function testExecutionOfEnabledBlock() { - $template = 'CmfBlockBundle:Block:block_simple.html.twig'; + $template = '@CmfBlock/Block/block_simple.html.twig'; $simpleBlock = new SimpleBlock(); $simpleBlock->setEnabled(true); $blockContext = new BlockContext($simpleBlock, ['template' => $template]); diff --git a/tests/Functional/Block/StringBlockServiceTest.php b/tests/Functional/Block/StringBlockServiceTest.php index cc8c404d..55646f12 100644 --- a/tests/Functional/Block/StringBlockServiceTest.php +++ b/tests/Functional/Block/StringBlockServiceTest.php @@ -20,7 +20,7 @@ class StringBlockServiceTest extends \PHPUnit_Framework_TestCase { public function testExecutionOfEnabledBlock() { - $template = 'CmfBlockBundle:Block:block_string.html.twig'; + $template = '@CmfBlock/Block/block_string.html.twig'; $stringBlock = new StringBlock(); $stringBlock->setEnabled(true); $blockContext = new BlockContext($stringBlock, ['template' => $template]); diff --git a/tests/Unit/DependencyInjection/XmlSchemaTest.php b/tests/Unit/DependencyInjection/XmlSchemaTest.php index 9fa1aa97..c28c7b19 100644 --- a/tests/Unit/DependencyInjection/XmlSchemaTest.php +++ b/tests/Unit/DependencyInjection/XmlSchemaTest.php @@ -18,7 +18,7 @@ class XmlSchemaTest extends XmlSchemaTestCase public function testSchema() { $xmlFiles = array_map(function ($file) { - return __DIR__.'/../..//Fixtures/App/config/'.$file; + return __DIR__.'/../..//Fixtures/fixtures/config/'.$file; }, [ 'config1.xml', 'config2.xml', diff --git a/tests/WebTest/Render/ReferenceBlockRenderTest.php b/tests/WebTest/Render/ReferenceBlockRenderTest.php index 7ea4d8a0..ad5eeefb 100644 --- a/tests/WebTest/Render/ReferenceBlockRenderTest.php +++ b/tests/WebTest/Render/ReferenceBlockRenderTest.php @@ -34,6 +34,7 @@ public function testRenderReferenceTwig() $crawler = $this->client->request('GET', '/render-reference-test'); $res = $this->client->getResponse(); + $this->assertEquals(200, $res->getStatusCode()); $this->assertCount(1, $crawler->filter('html:contains("Dummy action")'));