From 10c7831fde95bee740794a4bf738fcd22da4c419 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Tue, 29 Jan 2019 06:29:34 +0100 Subject: [PATCH 01/20] DevKit updates --- .travis.yml | 17 ++++++----------- README.md | 40 ++++++++++++++++++++-------------------- composer.json | 14 +++++++------- 3 files changed, 33 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index a42a6568..2105f143 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,22 +28,17 @@ cache: env: matrix: SYMFONY_VERSION=4.0.* global: - - SYMFONY_DEPRECATIONS_HELPER="/.*each.*/" + - SYMFONY_DEPRECATIONS_HELPER="weak" - SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" - KERNEL_CLASS=Symfony\Cmf\Bundle\BlockBundle\Tests\Fixtures\App\Kernel - - SYMFONY_PHPUNIT_VERSION=5.7 - - TEST_INSTALLATION=false + - SYMFONY_PHPUNIT_VERSION=5.7.26 matrix: include: - - php: 7.2 - env: SYMFONY_VERSION=4.0.* - - php: 7.1 - env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak - - php: 7.2 - env: SYMFONY_VERSION=3.3.* - - php: 7.2 - env: SYMFONY_VERSION=3.4.* + - php: "7.3" + env: SYMFONY_VERSION="4.0.*" + - php: "7.2" + env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION="3.4.*" SYMFONY_DEPRECATIONS_HELPER="weak" fast_finish: true allow_failures: diff --git a/README.md b/README.md index a290b4ef..3a0fc3c1 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ Branch | Travis | Coveralls | Scrutinizer | ------ | ------ | --------- | ----------- | -2.x | [![Build Status][travis_stable_badge]][travis_stable_link] | [![Coverage Status][coveralls_stable_badge]][coveralls_stable_link] | [![Scrutinizer Status][scrutinizer_stable_badge]][scrutinizer_stable_link] | -master | [![Build Status][travis_unstable_badge]][travis_unstable_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] | [![Scrutinizer Status][scrutinizer_unstable_badge]][scrutinizer_unstable_link] | +3.0-dev | [![Build Status][travis_stable_badge]][travis_stable_link] | [![Coverage Status][coveralls_stable_badge]][coveralls_stable_link] | [![Scrutinizer Status][scrutinizer_stable_badge]][scrutinizer_stable_link] | +3.0-dev | [![Build Status][travis_unstable_badge]][travis_unstable_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] | [![Scrutinizer Status][scrutinizer_unstable_badge]][scrutinizer_unstable_link] | -This package is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/) and licensed +This package is part of the [Symfony Content Management Framework (CMF)](https://cmf.symfony.com/) and licensed under the [MIT License](LICENSE). The BlockBundle provides integration with @@ -26,24 +26,24 @@ provides a few commonly used standard blocks, including the ability to edit them ## Requirements -* PHP 7.1 / 7.2 -* Symfony 2.8 / 3.3 / 3.4 / 4.0 +* PHP 7.2 / 7.3 +* Symfony 3.4 / 4.0 * See also the `require` section of [composer.json](composer.json) ## Documentation For the install guide and reference, see: -* [symfony-cmf/block-bundle Documentation](http://symfony.com/doc/master/cmf/bundles/block/index.html) +* [symfony-cmf/block-bundle Documentation](https://symfony.com/doc/master/cmf/bundles/block/index.html) See also: -* [All Symfony CMF documentation](http://symfony.com/doc/master/cmf/index.html) - complete Symfony CMF reference -* [Symfony CMF Website](http://cmf.symfony.com/) - introduction, live demo, support and community links +* [All Symfony CMF documentation](https://symfony.com/doc/master/cmf/index.html) - complete Symfony CMF reference +* [Symfony CMF Website](https://cmf.symfony.com/) - introduction, live demo, support and community links ## Support -For general support and questions, please use [StackOverflow](http://stackoverflow.com/questions/tagged/symfony-cmf). +For general support and questions, please use [StackOverflow](https://stackoverflow.com/questions/tagged/symfony-cmf). ## Contributing @@ -52,7 +52,7 @@ Pull requests are welcome. Please see our guide. Unit and/or functional tests exist for this package. See the -[Testing documentation](http://symfony.com/doc/master/cmf/components/testing.html) +[Testing documentation](https://symfony.com/doc/master/cmf/components/testing.html) for a guide to running the tests. Thanks to @@ -62,17 +62,17 @@ Thanks to This package is available under the [MIT license](src/Resources/meta/LICENSE). -[travis_stable_badge]: https://travis-ci.org/symfony-cmf/block-bundle.svg?branch=2.x +[travis_stable_badge]: https://travis-ci.org/symfony-cmf/block-bundle.svg?branch=3.0-dev [travis_stable_link]: https://travis-ci.org/symfony-cmf/block-bundle -[travis_unstable_badge]: https://travis-ci.org/symfony-cmf/block-bundle.svg?branch=master +[travis_unstable_badge]: https://travis-ci.org/symfony-cmf/block-bundle.svg?branch=3.0-dev [travis_unstable_link]: https://travis-ci.org/symfony-cmf/block-bundle -[coveralls_stable_badge]: https://coveralls.io/repos/github/symfony-cmf/block-bundle/badge.svg?branch=2.x -[coveralls_stable_link]: https://coveralls.io/github/symfony-cmf/block-bundle?branch=2.x -[coveralls_unstable_badge]: https://coveralls.io/repos/github/symfony-cmf/block-bundle/badge.svg?branch=master -[coveralls_unstable_link]: https://coveralls.io/github/symfony-cmf/block-bundle?branch=master +[coveralls_stable_badge]: https://coveralls.io/repos/github/symfony-cmf/block-bundle/badge.svg?branch=3.0-dev +[coveralls_stable_link]: https://coveralls.io/github/symfony-cmf/block-bundle?branch=3.0-dev +[coveralls_unstable_badge]: https://coveralls.io/repos/github/symfony-cmf/block-bundle/badge.svg?branch=3.0-dev +[coveralls_unstable_link]: https://coveralls.io/github/symfony-cmf/block-bundle?branch=3.0-dev -[scrutinizer_stable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/badges/quality-score.png?b=2.x -[scrutinizer_stable_link]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/?branch=2.x -[scrutinizer_unstable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/badges/quality-score.png?b=master -[scrutinizer_unstable_link]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/?branch=master +[scrutinizer_stable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/badges/quality-score.png?b=3.0-dev +[scrutinizer_stable_link]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/?branch=3.0-dev +[scrutinizer_unstable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/badges/quality-score.png?b=3.0-dev +[scrutinizer_unstable_link]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/?branch=3.0-dev diff --git a/composer.json b/composer.json index 9bfb501e..55329b8e 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ } ], "require": { - "php": "^7.1", - "symfony/framework-bundle": "^2.8 || ^3.3 || ^4.0", + "php": "^7.2", + "symfony/framework-bundle": "^3.4 || ^4.0", "doctrine/phpcr-bundle": "^1.3 || ^2.0", "doctrine/phpcr-odm": "^1.4.2 || ^2.0", "sonata-project/block-bundle": "^3.11", @@ -26,14 +26,14 @@ "require-dev": { "symfony-cmf/testing": "^2.1.8", "symfony-cmf/menu-bundle": "^2.1", - "symfony/phpunit-bridge": "^3.3 || ^4.0", + "symfony/phpunit-bridge": "^3.4 || ^4.0", "sonata-project/cache-bundle": "^2.4", "sonata-project/core-bundle": "^3.0", "twig/twig": "^1.14.2 || ^2.0", - "symfony/security-bundle": "^2.8 || ^3.3 || ^4.0", - "symfony/twig-bundle": "^2.8 || ^3.3 || ^4.0", - "symfony/asset": "^2.8 || ^3.3 || ^4.0", - "symfony/templating": "^2.8 || ^3.3 || ^4.0" + "symfony/security-bundle": "^3.4 || ^4.0", + "symfony/twig-bundle": "^3.4 || ^4.0", + "symfony/asset": "^3.4 || ^4.0", + "symfony/templating": "^3.4 || ^4.0" }, "suggest": { "sonata-project/cache-bundle": "To add caching support for block loading", From c05ce45bb270747b4518f322f5aea9bfff66e1c9 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Tue, 29 Jan 2019 06:52:43 +0100 Subject: [PATCH 02/20] DevKit updates --- .travis.yml | 8 ++++++-- README.md | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2105f143..32455187 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ cache: - $HOME/.composer/cache/files env: - matrix: SYMFONY_VERSION=4.0.* + matrix: SYMFONY_VERSION=4.2.* global: - SYMFONY_DEPRECATIONS_HELPER="weak" - SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" @@ -36,9 +36,13 @@ env: matrix: include: - php: "7.3" - env: SYMFONY_VERSION="4.0.*" + env: SYMFONY_VERSION="4.2.*" - php: "7.2" env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION="3.4.*" SYMFONY_DEPRECATIONS_HELPER="weak" + - php: "7.3" + env: SYMFONY_VERSION="4.0.*" + - php: "7.3" + env: SYMFONY_VERSION="4.1.*" fast_finish: true allow_failures: diff --git a/README.md b/README.md index 3a0fc3c1..d1edd2b7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ provides a few commonly used standard blocks, including the ability to edit them ## Requirements * PHP 7.2 / 7.3 -* Symfony 3.4 / 4.0 +* Symfony 3.4 / 4.0 / 4.1 / 4.2 * See also the `require` section of [composer.json](composer.json) ## Documentation From 57117f8b317a36e9dcd9c2ea4790ca1f4c005620 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Wed, 30 Jan 2019 22:53:59 +0100 Subject: [PATCH 03/20] DevKit updates --- .travis.yml | 31 +++++++++++++++++++------------ Makefile | 5 +++-- README.md | 26 +++++++++++++------------- composer.json | 4 ++-- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index 32455187..9e859c6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,8 @@ language: php php: - 7.1 - + - 7.2 + - 7.3 sudo: false cache: @@ -28,23 +29,29 @@ cache: env: matrix: SYMFONY_VERSION=4.2.* global: - - SYMFONY_DEPRECATIONS_HELPER="weak" + - SYMFONY_DEPRECATIONS_HELPER=weak - SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" - - KERNEL_CLASS=Symfony\Cmf\Bundle\BlockBundle\Tests\Fixtures\App\Kernel - - SYMFONY_PHPUNIT_VERSION=5.7.26 + - SYMFONY_PHPUNIT_VERSION=7 + - TEST_INSTALLATION=false matrix: include: - - php: "7.3" - env: SYMFONY_VERSION="4.2.*" - - php: "7.2" - env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION="3.4.*" SYMFONY_DEPRECATIONS_HELPER="weak" - - php: "7.3" - env: SYMFONY_VERSION="4.0.*" - - php: "7.3" - env: SYMFONY_VERSION="4.1.*" + - php: 7.3 + env: STABILITY="dev" SYMFONY_VERSION=4.3.* + - php: 7.3 + env: SYMFONY_VERSION=4.2.* + - php: 7.1 + env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=3.4.* SYMFONY_DEPRECATIONS_HELPER=weak + - php: 7.2 + env: SYMFONY_VERSION=4.0.* + - php: 7.2 + env: SYMFONY_VERSION=4.1.* + - env: TEST_INSTALLATION=true fast_finish: true allow_failures: + - php: 7.3 + env: STABILITY="dev" SYMFONY_VERSION=4.3.* + - env: TEST_INSTALLATION=true before_install: - phpenv config-rm xdebug.ini || true diff --git a/Makefile b/Makefile index f81e5035..cd75049e 100644 --- a/Makefile +++ b/Makefile @@ -20,15 +20,16 @@ ifdef BRANCH VERSION=dev-${BRANCH} endif PACKAGE=symfony-cmf/block-bundle -export KERNEL_CLASS=Symfony\Cmf\Bundle\BlockBundle\Tests\Fixtures\App\Kernel + list: @echo 'test: will run all tests' @echo 'unit_tests: will run unit tests only' @echo 'functional_tests_phpcr: will run functional tests with PHPCR' - + @echo 'test_installation: will run installation test' include ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk include ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk +include ${TESTING_SCRIPTS_DIR}/make/test_installation.mk .PHONY: test test: unit_tests functional_tests_phpcr diff --git a/README.md b/README.md index d1edd2b7..fd23ee4f 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ Branch | Travis | Coveralls | Scrutinizer | ------ | ------ | --------- | ----------- | -3.0-dev | [![Build Status][travis_stable_badge]][travis_stable_link] | [![Coverage Status][coveralls_stable_badge]][coveralls_stable_link] | [![Scrutinizer Status][scrutinizer_stable_badge]][scrutinizer_stable_link] | -3.0-dev | [![Build Status][travis_unstable_badge]][travis_unstable_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] | [![Scrutinizer Status][scrutinizer_unstable_badge]][scrutinizer_unstable_link] | +2.1 | [![Build Status][travis_stable_badge]][travis_stable_link] | [![Coverage Status][coveralls_stable_badge]][coveralls_stable_link] | [![Scrutinizer Status][scrutinizer_stable_badge]][scrutinizer_stable_link] | +dev-master | [![Build Status][travis_unstable_badge]][travis_unstable_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] | [![Scrutinizer Status][scrutinizer_unstable_badge]][scrutinizer_unstable_link] | This package is part of the [Symfony Content Management Framework (CMF)](https://cmf.symfony.com/) and licensed @@ -26,7 +26,7 @@ provides a few commonly used standard blocks, including the ability to edit them ## Requirements -* PHP 7.2 / 7.3 +* PHP 7.1 / 7.2 / 7.3 * Symfony 3.4 / 4.0 / 4.1 / 4.2 * See also the `require` section of [composer.json](composer.json) @@ -62,17 +62,17 @@ Thanks to This package is available under the [MIT license](src/Resources/meta/LICENSE). -[travis_stable_badge]: https://travis-ci.org/symfony-cmf/block-bundle.svg?branch=3.0-dev +[travis_stable_badge]: https://travis-ci.org/symfony-cmf/block-bundle.svg?branch=2.1 [travis_stable_link]: https://travis-ci.org/symfony-cmf/block-bundle -[travis_unstable_badge]: https://travis-ci.org/symfony-cmf/block-bundle.svg?branch=3.0-dev +[travis_unstable_badge]: https://travis-ci.org/symfony-cmf/block-bundle.svg?branch=dev-master [travis_unstable_link]: https://travis-ci.org/symfony-cmf/block-bundle -[coveralls_stable_badge]: https://coveralls.io/repos/github/symfony-cmf/block-bundle/badge.svg?branch=3.0-dev -[coveralls_stable_link]: https://coveralls.io/github/symfony-cmf/block-bundle?branch=3.0-dev -[coveralls_unstable_badge]: https://coveralls.io/repos/github/symfony-cmf/block-bundle/badge.svg?branch=3.0-dev -[coveralls_unstable_link]: https://coveralls.io/github/symfony-cmf/block-bundle?branch=3.0-dev +[coveralls_stable_badge]: https://coveralls.io/repos/github/symfony-cmf/block-bundle/badge.svg?branch=2.1 +[coveralls_stable_link]: https://coveralls.io/github/symfony-cmf/block-bundle?branch=2.1 +[coveralls_unstable_badge]: https://coveralls.io/repos/github/symfony-cmf/block-bundle/badge.svg?branch=dev-master +[coveralls_unstable_link]: https://coveralls.io/github/symfony-cmf/block-bundle?branch=dev-master -[scrutinizer_stable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/badges/quality-score.png?b=3.0-dev -[scrutinizer_stable_link]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/?branch=3.0-dev -[scrutinizer_unstable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/badges/quality-score.png?b=3.0-dev -[scrutinizer_unstable_link]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/?branch=3.0-dev +[scrutinizer_stable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/badges/quality-score.png?b=2.1 +[scrutinizer_stable_link]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/?branch=2.1 +[scrutinizer_unstable_badge]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/badges/quality-score.png?b=dev-master +[scrutinizer_unstable_link]: https://scrutinizer-ci.com/g/symfony-cmf/block-bundle/?branch=dev-master diff --git a/composer.json b/composer.json index 55329b8e..99d49114 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.1", "symfony/framework-bundle": "^3.4 || ^4.0", "doctrine/phpcr-bundle": "^1.3 || ^2.0", "doctrine/phpcr-odm": "^1.4.2 || ^2.0", @@ -26,7 +26,7 @@ "require-dev": { "symfony-cmf/testing": "^2.1.8", "symfony-cmf/menu-bundle": "^2.1", - "symfony/phpunit-bridge": "^3.4 || ^4.0", + "symfony/phpunit-bridge": "^4.2.2", "sonata-project/cache-bundle": "^2.4", "sonata-project/core-bundle": "^3.0", "twig/twig": "^1.14.2 || ^2.0", From ba70104d55f69dff90c54b616eb44ccb095a0ff7 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Wed, 30 Jan 2019 23:05:26 +0100 Subject: [PATCH 04/20] DevKit updates --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index cd75049e..91b86985 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,12 @@ ############################################################################ TESTING_SCRIPTS_DIR=vendor/symfony-cmf/testing/bin + +SYMFONY_PHPUNIT_VERSION=7 +SYMFONY_DEPRECATIONS_HELPER==weak CONSOLE=${TESTING_SCRIPTS_DIR}/console +SYMFONY_PHPUNIT_DIR=.phpunit +SYMFONY_PHPUNIT_REMOVE="symfony/yaml" VERSION=dev-master ifdef BRANCH VERSION=dev-${BRANCH} From e9fb60a3012a6049988301238cb1426efcf0740b Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Wed, 30 Jan 2019 23:42:11 +0100 Subject: [PATCH 05/20] DevKit updates --- .travis.yml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e859c6d..ea57ec24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ env: global: - SYMFONY_DEPRECATIONS_HELPER=weak - SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" - - SYMFONY_PHPUNIT_VERSION=7 + - SYMFONY_PHPUNIT_VERSION=6 - TEST_INSTALLATION=false matrix: diff --git a/Makefile b/Makefile index 91b86985..e6376249 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ TESTING_SCRIPTS_DIR=vendor/symfony-cmf/testing/bin -SYMFONY_PHPUNIT_VERSION=7 +SYMFONY_PHPUNIT_VERSION=6 SYMFONY_DEPRECATIONS_HELPER==weak CONSOLE=${TESTING_SCRIPTS_DIR}/console SYMFONY_PHPUNIT_DIR=.phpunit From ec9694374dea4602635f177393de1622bc790c42 Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Thu, 31 Jan 2019 05:34:10 +0100 Subject: [PATCH 06/20] change root node defintion to avoid deprecation --- src/DependencyInjection/Configuration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 6627a84e..a369276c 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -31,8 +31,8 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('cmf_block'); + $treeBuilder = new TreeBuilder('cmf_block'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() From 0098e65060e969fd7c8c63fd1755912472e3de1e Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Thu, 31 Jan 2019 05:37:00 +0100 Subject: [PATCH 07/20] replace by AbstractController --- src/Controller/RssController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/RssController.php b/src/Controller/RssController.php index 5ed26d54..31206ce3 100644 --- a/src/Controller/RssController.php +++ b/src/Controller/RssController.php @@ -13,12 +13,12 @@ use Sonata\BlockBundle\Block\BlockContextInterface; use Sonata\BlockBundle\Model\BlockInterface; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Cmf\Bundle\BlockBundle\Model\FeedItem; use Symfony\Component\HttpFoundation\Response; use Zend\Feed\Reader\Exception\RuntimeException; -class RssController extends Controller +class RssController extends AbstractController { /** * Action that is referenced in an ActionBlock. From 7d87fe28f34392df768e648e6a90750152ecb180 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Mon, 4 Feb 2019 09:18:23 +0100 Subject: [PATCH 08/20] DevKit updates --- .travis.yml | 4 ++-- Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea57ec24..1f3a4639 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ cache: env: matrix: SYMFONY_VERSION=4.2.* global: - - SYMFONY_DEPRECATIONS_HELPER=weak + - SYMFONY_DEPRECATIONS_HELPER=/.*each.*/ - SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" - SYMFONY_PHPUNIT_VERSION=6 - TEST_INSTALLATION=false @@ -41,7 +41,7 @@ matrix: - php: 7.3 env: SYMFONY_VERSION=4.2.* - php: 7.1 - env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=3.4.* SYMFONY_DEPRECATIONS_HELPER=weak + env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=3.4.* SYMFONY_DEPRECATIONS_HELPER=/.*each.*/ - php: 7.2 env: SYMFONY_VERSION=4.0.* - php: 7.2 diff --git a/Makefile b/Makefile index e6376249..ebfcd797 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ TESTING_SCRIPTS_DIR=vendor/symfony-cmf/testing/bin SYMFONY_PHPUNIT_VERSION=6 -SYMFONY_DEPRECATIONS_HELPER==weak +SYMFONY_DEPRECATIONS_HELPER==/.*each.*/ CONSOLE=${TESTING_SCRIPTS_DIR}/console SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" From f7719c084c2363b2d69cc9f0908c456e2c47c060 Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Mon, 4 Feb 2019 09:33:59 +0100 Subject: [PATCH 09/20] root node defintion for SF < 4.2 also --- src/DependencyInjection/Configuration.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index a369276c..98c1b95d 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -32,7 +32,12 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('cmf_block'); - $rootNode = $treeBuilder->getRootNode(); + // Keep compatibility with symfony/config < 4.2 + if (!method_exists($treeBuilder, 'getRootNode')) { + $rootNode = $treeBuilder->root('cmf_block'); + } else { + $rootNode = $treeBuilder->getRootNode(); + } $rootNode ->children() From 294bb03266853a07c5e5443ccdacc3e84963d2e3 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Mon, 4 Feb 2019 09:56:18 +0100 Subject: [PATCH 10/20] DevKit updates --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f3a4639..bbeb2907 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ cache: env: matrix: SYMFONY_VERSION=4.2.* global: - - SYMFONY_DEPRECATIONS_HELPER=/.*each.*/ + - SYMFONY_DEPRECATIONS_HELPER="/.*each.*/" - SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" - SYMFONY_PHPUNIT_VERSION=6 - TEST_INSTALLATION=false @@ -41,7 +41,8 @@ matrix: - php: 7.3 env: SYMFONY_VERSION=4.2.* - php: 7.1 - env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=3.4.* SYMFONY_DEPRECATIONS_HELPER=/.*each.*/ + env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=3.4.* SYMFONY_DEPRECATIONS_HELPER="/.*each.*/" + - php: 7.2 env: SYMFONY_VERSION=4.0.* - php: 7.2 From 21d79d34a48ad5a17b154523508f23e226e938bd Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Wed, 27 Feb 2019 09:12:12 +0100 Subject: [PATCH 11/20] some changes due to phpunit 6 --- tests/Unit/Cache/BlockJsCacheTest.php | 3 ++- tests/Unit/Cache/BlockSsiCacheTest.php | 3 ++- tests/Unit/Cache/BlockVarnishCacheTest.php | 3 ++- tests/Unit/Templating/Helper/CmfBlockHelperTest.php | 3 ++- tests/Unit/Templating/Helper/EmbedBlocksParserTest.php | 3 ++- tests/Unit/Twig/Extension/CmfBlockExtensionTest.php | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/Unit/Cache/BlockJsCacheTest.php b/tests/Unit/Cache/BlockJsCacheTest.php index 6ca67ee1..3615af06 100644 --- a/tests/Unit/Cache/BlockJsCacheTest.php +++ b/tests/Unit/Cache/BlockJsCacheTest.php @@ -11,6 +11,7 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Unit\Cache; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContextManagerInterface; use Sonata\BlockBundle\Block\BlockLoaderInterface; use Sonata\BlockBundle\Block\BlockRendererInterface; @@ -20,7 +21,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\RouterInterface; -class BlockJsCacheTest extends \PHPUnit_Framework_TestCase +class BlockJsCacheTest extends TestCase { /** * @expectedException \RuntimeException diff --git a/tests/Unit/Cache/BlockSsiCacheTest.php b/tests/Unit/Cache/BlockSsiCacheTest.php index ca3d60e2..39e433cd 100644 --- a/tests/Unit/Cache/BlockSsiCacheTest.php +++ b/tests/Unit/Cache/BlockSsiCacheTest.php @@ -11,6 +11,7 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Unit\Cache; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContextManagerInterface; use Sonata\BlockBundle\Block\BlockLoaderInterface; use Sonata\BlockBundle\Block\BlockRendererInterface; @@ -18,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RouterInterface; -class BlockSsiCacheTest extends \PHPUnit_Framework_TestCase +class BlockSsiCacheTest extends TestCase { /** * @expectedException \RuntimeException diff --git a/tests/Unit/Cache/BlockVarnishCacheTest.php b/tests/Unit/Cache/BlockVarnishCacheTest.php index 09cc16bb..677cd30a 100644 --- a/tests/Unit/Cache/BlockVarnishCacheTest.php +++ b/tests/Unit/Cache/BlockVarnishCacheTest.php @@ -11,6 +11,7 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Unit\Cache; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContextManagerInterface; use Sonata\BlockBundle\Block\BlockLoaderInterface; use Sonata\BlockBundle\Block\BlockRendererInterface; @@ -19,7 +20,7 @@ use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\Routing\RouterInterface; -class BlockVarnishCacheTest extends \PHPUnit_Framework_TestCase +class BlockVarnishCacheTest extends TestCase { /** * @var FragmentHandler|\PHPUnit_Framework_MockObject_MockObject diff --git a/tests/Unit/Templating/Helper/CmfBlockHelperTest.php b/tests/Unit/Templating/Helper/CmfBlockHelperTest.php index 6d9c2a38..22b15e59 100644 --- a/tests/Unit/Templating/Helper/CmfBlockHelperTest.php +++ b/tests/Unit/Templating/Helper/CmfBlockHelperTest.php @@ -11,13 +11,14 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Unit\Templating\Helper; +use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Sonata\BlockBundle\Exception\BlockNotFoundException; use Sonata\BlockBundle\Templating\Helper\BlockHelper; use Symfony\Cmf\Bundle\BlockBundle\Templating\Helper\CmfBlockHelper; use Symfony\Cmf\Bundle\BlockBundle\Templating\Helper\EmbedBlocksParser; -class CmfBlockHelperTest extends \PHPUnit_Framework_TestCase +class CmfBlockHelperTest extends TestCase { private $sonataBlock; diff --git a/tests/Unit/Templating/Helper/EmbedBlocksParserTest.php b/tests/Unit/Templating/Helper/EmbedBlocksParserTest.php index b51e88c6..0434faeb 100644 --- a/tests/Unit/Templating/Helper/EmbedBlocksParserTest.php +++ b/tests/Unit/Templating/Helper/EmbedBlocksParserTest.php @@ -11,9 +11,10 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Unit\Templating\Helper; +use PHPUnit\Framework\TestCase; use Symfony\Cmf\Bundle\BlockBundle\Templating\Helper\EmbedBlocksParser; -class EmbedBlocksParserTest extends \PHPUnit_Framework_TestCase +class EmbedBlocksParserTest extends TestCase { /** @var EmbedBlocksParser */ protected $parser; diff --git a/tests/Unit/Twig/Extension/CmfBlockExtensionTest.php b/tests/Unit/Twig/Extension/CmfBlockExtensionTest.php index 25f47912..0b5d22c7 100644 --- a/tests/Unit/Twig/Extension/CmfBlockExtensionTest.php +++ b/tests/Unit/Twig/Extension/CmfBlockExtensionTest.php @@ -11,10 +11,11 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Unit\Twig\Extension; +use PHPUnit\Framework\TestCase; use Symfony\Cmf\Bundle\BlockBundle\Templating\Helper\CmfBlockHelper; use Symfony\Cmf\Bundle\BlockBundle\Twig\Extension\CmfBlockExtension; -class CmfBlockExtensionTest extends \PHPUnit_Framework_TestCase +class CmfBlockExtensionTest extends TestCase { private $blockHelper; From 770573f0060b5bfd09c24ea250d39fb2658f38f9 Mon Sep 17 00:00:00 2001 From: ElectricMaxxx Date: Thu, 28 Feb 2019 05:13:32 +0100 Subject: [PATCH 12/20] remove last old test case classes --- tests/Functional/Block/ActionBlockServiceTest.php | 3 ++- tests/Functional/Block/ContainerBlockServiceTest.php | 3 ++- tests/Functional/Block/MenuBlockServiceTest.php | 3 ++- tests/Functional/Block/PhpcrBlockLoaderTest.php | 3 ++- tests/Functional/Block/ReferenceBlockServiceTest.php | 3 ++- tests/Functional/Block/SimpleBlockServiceTest.php | 3 ++- tests/Functional/Block/StringBlockServiceTest.php | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/Functional/Block/ActionBlockServiceTest.php b/tests/Functional/Block/ActionBlockServiceTest.php index 92c65285..c7bc99c1 100644 --- a/tests/Functional/Block/ActionBlockServiceTest.php +++ b/tests/Functional/Block/ActionBlockServiceTest.php @@ -11,6 +11,7 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Functional\Block; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContext; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Cmf\Bundle\BlockBundle\Block\ActionBlockService; @@ -19,7 +20,7 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Fragment\FragmentHandler; -class ActionBlockServiceTest extends \PHPUnit_Framework_TestCase +class ActionBlockServiceTest extends TestCase { /** * @var EngineInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/tests/Functional/Block/ContainerBlockServiceTest.php b/tests/Functional/Block/ContainerBlockServiceTest.php index 30d17d84..297f49bd 100644 --- a/tests/Functional/Block/ContainerBlockServiceTest.php +++ b/tests/Functional/Block/ContainerBlockServiceTest.php @@ -12,6 +12,7 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Functional\Block; use Doctrine\ODM\PHPCR\ChildrenCollection; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContext; use Sonata\BlockBundle\Block\BlockRendererInterface; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; @@ -20,7 +21,7 @@ use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock; use Symfony\Component\HttpFoundation\Response; -class ContainerBlockServiceTest extends \PHPUnit_Framework_TestCase +class ContainerBlockServiceTest extends TestCase { public function testExecutionOfDisabledBlock() { diff --git a/tests/Functional/Block/MenuBlockServiceTest.php b/tests/Functional/Block/MenuBlockServiceTest.php index e415bb8e..18e9eaf4 100644 --- a/tests/Functional/Block/MenuBlockServiceTest.php +++ b/tests/Functional/Block/MenuBlockServiceTest.php @@ -12,6 +12,7 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Functional\Block; use Knp\Menu\NodeInterface; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContext; use Sonata\BlockBundle\Block\BlockContextManagerInterface; use Sonata\BlockBundle\Block\BlockRendererInterface; @@ -20,7 +21,7 @@ use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\MenuBlock; use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode; -class MenuBlockServiceTest extends \PHPUnit_Framework_TestCase +class MenuBlockServiceTest extends TestCase { public function testExecutionOfDisabledBlock() { diff --git a/tests/Functional/Block/PhpcrBlockLoaderTest.php b/tests/Functional/Block/PhpcrBlockLoaderTest.php index a9898af5..49fa8abb 100644 --- a/tests/Functional/Block/PhpcrBlockLoaderTest.php +++ b/tests/Functional/Block/PhpcrBlockLoaderTest.php @@ -14,6 +14,7 @@ use Doctrine\Bundle\PHPCRBundle\ManagerRegistry; use Doctrine\ODM\PHPCR\DocumentManager; use Doctrine\ODM\PHPCR\UnitOfWork; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Model\BlockInterface; use Symfony\Cmf\Bundle\BlockBundle\Block\PhpcrBlockLoader; use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock; @@ -23,7 +24,7 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; -class PhpcrBlockLoaderTest extends \PHPUnit_Framework_TestCase +class PhpcrBlockLoaderTest extends TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject diff --git a/tests/Functional/Block/ReferenceBlockServiceTest.php b/tests/Functional/Block/ReferenceBlockServiceTest.php index a5bb525a..8670111e 100644 --- a/tests/Functional/Block/ReferenceBlockServiceTest.php +++ b/tests/Functional/Block/ReferenceBlockServiceTest.php @@ -11,6 +11,7 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Functional\Block; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContext; use Sonata\BlockBundle\Block\BlockContextManagerInterface; use Sonata\BlockBundle\Block\BlockRendererInterface; @@ -19,7 +20,7 @@ use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ReferenceBlock; use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock; -class ReferenceBlockServiceTest extends \PHPUnit_Framework_TestCase +class ReferenceBlockServiceTest extends TestCase { public function testExecutionOfDisabledBlock() { diff --git a/tests/Functional/Block/SimpleBlockServiceTest.php b/tests/Functional/Block/SimpleBlockServiceTest.php index dce7bdac..d4a833ba 100644 --- a/tests/Functional/Block/SimpleBlockServiceTest.php +++ b/tests/Functional/Block/SimpleBlockServiceTest.php @@ -11,12 +11,13 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Functional\Block; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContext; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Cmf\Bundle\BlockBundle\Block\SimpleBlockService; use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SimpleBlock; -class SimpleBlockServiceTest extends \PHPUnit_Framework_TestCase +class SimpleBlockServiceTest extends TestCase { public function testExecutionOfEnabledBlock() { diff --git a/tests/Functional/Block/StringBlockServiceTest.php b/tests/Functional/Block/StringBlockServiceTest.php index 55646f12..5016fe90 100644 --- a/tests/Functional/Block/StringBlockServiceTest.php +++ b/tests/Functional/Block/StringBlockServiceTest.php @@ -11,12 +11,13 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Tests\Functional\Block; +use PHPUnit\Framework\TestCase; use Sonata\BlockBundle\Block\BlockContext; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Cmf\Bundle\BlockBundle\Block\StringBlockService; use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\StringBlock; -class StringBlockServiceTest extends \PHPUnit_Framework_TestCase +class StringBlockServiceTest extends TestCase { public function testExecutionOfEnabledBlock() { From f1c97d549dde6992c7ef4b1a1ab1e80b4476c85c Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Thu, 28 Feb 2019 05:15:17 +0100 Subject: [PATCH 13/20] DevKit updates --- .php_cs.dist | 64 +++++++++++++++++++++++++++++++++++ .styleci.yml | 2 +- .travis.yml | 21 +++++++----- .travis/after_success_test.sh | 5 +++ .travis/install_lint.sh | 11 ++++++ .travis/install_test.sh | 19 +++++++++++ Makefile | 64 +++++++++++++++++++++++++++++------ README.md | 2 +- composer.json | 10 +++--- phpunit.xml.dist | 40 ++++++++++++++-------- src/Resources/meta/LICENSE | 2 +- 11 files changed, 197 insertions(+), 43 deletions(-) create mode 100644 .php_cs.dist create mode 100755 .travis/after_success_test.sh create mode 100755 .travis/install_lint.sh create mode 100755 .travis/install_test.sh diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 00000000..5759af56 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,64 @@ + true, + '@Symfony:risky' => true, + 'array_syntax' => [ + 'syntax' => 'short', + ], + 'combine_consecutive_issets' => true, + 'combine_consecutive_unsets' => true, + 'header_comment' => [ + 'header' => $header, + ], + 'no_extra_blank_lines' => true, + 'no_php4_constructor' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_class_elements' => true, + 'ordered_imports' => true, + 'phpdoc_order' => true, + '@PHP56Migration' => true, + '@PHP56Migration:risky' => true, + '@PHPUnit57Migration:risky' => true, + '@PHP70Migration' => true, + '@PHP70Migration:risky' => true, + '@PHPUnit60Migration:risky' => true, + '@PHP71Migration' => true, + '@PHP71Migration:risky' => true, + 'compact_nullable_typehint' => true, + 'void_return' => null, + 'strict_comparison' => true, + 'strict_param' => true, +]; + + +$finder = PhpCsFixer\Finder::create() + ->in(__DIR__) + ->exclude('Tests/Fixtures') + ->exclude('tests/Fixtures') + ->exclude('Resources/skeleton') + ->exclude('Resources/public/vendor') +; + +return PhpCsFixer\Config::create() + ->setFinder($finder) + ->setRiskyAllowed(true) + ->setRules($rules) + ->setUsingCache(true) +; diff --git a/.styleci.yml b/.styleci.yml index 2bdb04b1..c721eb61 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -7,7 +7,7 @@ ############################################################################ # This file is part of the Symfony CMF package. # # # -# (c) 2011-2017 Symfony CMF # +# (c) Symfony CMF # # # # For the full copyright and license information, please view the LICENSE # # file that was distributed with this source code. # diff --git a/.travis.yml b/.travis.yml index bbeb2907..69a41315 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ ############################################################################ # This file is part of the Symfony CMF package. # # # -# (c) 2011-2017 Symfony CMF # +# (c) Symfony CMF # # # # For the full copyright and license information, please view the LICENSE # # file that was distributed with this source code. # @@ -32,10 +32,12 @@ env: - SYMFONY_DEPRECATIONS_HELPER="/.*each.*/" - SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" - SYMFONY_PHPUNIT_VERSION=6 - - TEST_INSTALLATION=false + - PHPUNIT_VERSION=6 + - TARGET=test matrix: include: + - env: TARGET=lint - php: 7.3 env: STABILITY="dev" SYMFONY_VERSION=4.3.* - php: 7.3 @@ -43,16 +45,14 @@ matrix: - php: 7.1 env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=3.4.* SYMFONY_DEPRECATIONS_HELPER="/.*each.*/" - - php: 7.2 - env: SYMFONY_VERSION=4.0.* - php: 7.2 env: SYMFONY_VERSION=4.1.* - - env: TEST_INSTALLATION=true + - env: TARGET=test_installation fast_finish: true allow_failures: - php: 7.3 env: STABILITY="dev" SYMFONY_VERSION=4.3.* - - env: TEST_INSTALLATION=true + - env: TARGET=test_installation before_install: - phpenv config-rm xdebug.ini || true @@ -65,9 +65,12 @@ before_install: install: - phpenv config-add travis.php.ini - php -ini | grep memory_limit - - travis_wait composer update --prefer-dist $COMPOSER_FLAGS -script: - - if [ "${TEST_INSTALLATION}" == true ]; then make test_installation; else make test; fi + - if [ -x .travis/install_${TARGET}.sh ]; then .travis/install_${TARGET}.sh; fi; + +script: make $TARGET + +after_success: + - if [ -x .travis/after_success_${TARGET}.sh ]; then .travis/after_success_${TARGET}.sh; fi; notifications: irc: "irc.freenode.org#symfony-cmf" diff --git a/.travis/after_success_test.sh b/.travis/after_success_test.sh new file mode 100755 index 00000000..98374202 --- /dev/null +++ b/.travis/after_success_test.sh @@ -0,0 +1,5 @@ + +#!/usr/bin/env sh +set -ev + +coveralls -v diff --git a/.travis/install_lint.sh b/.travis/install_lint.sh new file mode 100755 index 00000000..864c751e --- /dev/null +++ b/.travis/install_lint.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +set -ev + +mkdir --parents "${HOME}/bin" + +wget "http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar" --output-document="${HOME}/bin/php-cs-fixer" +chmod u+x "${HOME}/bin/php-cs-fixer" + +composer global require sllh/composer-lint:@stable --prefer-dist --no-interaction + +gem install yaml-lint diff --git a/.travis/install_test.sh b/.travis/install_test.sh new file mode 100755 index 00000000..a0335009 --- /dev/null +++ b/.travis/install_test.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env sh +set -ev + +mkdir --parents "${HOME}/bin" + +wget "https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" --output-document="${HOME}/bin/phpunit" +chmod u+x "${HOME}/bin/phpunit" + +# Coveralls client install +wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar --output-document="${HOME}/bin/coveralls" +chmod u+x "${HOME}/bin/coveralls" + +# To be removed when these issues are resolved: +# https://github.com/composer/composer/issues/5355 +if [ "${COMPOSER_FLAGS}" = '--prefer-lowest' ]; then + composer update --prefer-dist --no-interaction --prefer-stable --quiet +fi + +composer update --prefer-dist --no-interaction --prefer-stable ${COMPOSER_FLAGS} diff --git a/Makefile b/Makefile index ebfcd797..e76ce013 100644 --- a/Makefile +++ b/Makefile @@ -7,34 +7,76 @@ ############################################################################ # This file is part of the Symfony CMF package. # # # -# (c) 2011-2017 Symfony CMF # +# (c) Symfony CMF # # # # For the full copyright and license information, please view the LICENSE # # file that was distributed with this source code. # ############################################################################ TESTING_SCRIPTS_DIR=vendor/symfony-cmf/testing/bin - -SYMFONY_PHPUNIT_VERSION=6 -SYMFONY_DEPRECATIONS_HELPER==/.*each.*/ CONSOLE=${TESTING_SCRIPTS_DIR}/console -SYMFONY_PHPUNIT_DIR=.phpunit -SYMFONY_PHPUNIT_REMOVE="symfony/yaml" VERSION=dev-master ifdef BRANCH VERSION=dev-${BRANCH} endif PACKAGE=symfony-cmf/block-bundle +HAS_XDEBUG=$(shell php --modules|grep --quiet xdebug;echo $$?) list: @echo 'test: will run all tests' @echo 'unit_tests: will run unit tests only' @echo 'functional_tests_phpcr: will run functional tests with PHPCR' - @echo 'test_installation: will run installation test' -include ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk -include ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk -include ${TESTING_SCRIPTS_DIR}/make/test_installation.mk + @echo 'test_installation: will run installation test'TEST_DEPENDENCIES := "" +EXTRA_INCLUDES:=$(wildcard ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk) +ifneq ($(strip $(EXTRA_INCLUDES)),) + contents := $(shell echo including extra rules $(EXTRA_INCLUDES)) + include $(EXTRA_INCLUDES) + TEST_DEPENDENCIES := $(TEST_DEPENDENCIES)" unit_tests" + endif +EXTRA_INCLUDES:=$(wildcard ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk) +ifneq ($(strip $(EXTRA_INCLUDES)),) + contents := $(shell echo including extra rules $(EXTRA_INCLUDES)) + include $(EXTRA_INCLUDES) + TEST_DEPENDENCIES := $(TEST_DEPENDENCIES)" functional_tests_phpcr" + endif +EXTRA_INCLUDES:=$(wildcard ${TESTING_SCRIPTS_DIR}/make/test_installation.mk) +ifneq ($(strip $(EXTRA_INCLUDES)),) + contents := $(shell echo including extra rules $(EXTRA_INCLUDES)) + include $(EXTRA_INCLUDES) + endif .PHONY: test -test: unit_tests functional_tests_phpcr +test: build/xdebug-filter.php$ +ifneq ($(strip $(wildcard ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk)),) + @make unit_tests +endif +ifneq ($(strip $(wildcard ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk)),) + @make functional_tests_phpcr +endif + +lint-php: + php-cs-fixer fix --ansi --verbose --diff --dry-run +.PHONY: lint-php + +lint: lint-composer lint-php +.PHONY: lint + +lint-composer: + composer validate +.PHONY: lint-composer + +cs-fix: cs-fix-php +.PHONY: cs-fix + +cs-fix-php: + php-cs-fixer fix --verbose +.PHONY: cs-fix-php + +build: + mkdir $@ + +build/xdebug-filter.php: phpunit.xml.dist build +ifeq ($(HAS_XDEBUG), 0) + phpunit --dump-xdebug-filter $@ +endif diff --git a/README.md b/README.md index fd23ee4f..97c34bb6 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ provides a few commonly used standard blocks, including the ability to edit them ## Requirements * PHP 7.1 / 7.2 / 7.3 -* Symfony 3.4 / 4.0 / 4.1 / 4.2 +* Symfony 3.4 / 4.1 / 4.2 * See also the `require` section of [composer.json](composer.json) ## Documentation diff --git a/composer.json b/composer.json index 99d49114..3a640e3c 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^7.1", - "symfony/framework-bundle": "^3.4 || ^4.0", + "symfony/framework-bundle": "^3.4 || ^4.1", "doctrine/phpcr-bundle": "^1.3 || ^2.0", "doctrine/phpcr-odm": "^1.4.2 || ^2.0", "sonata-project/block-bundle": "^3.11", @@ -30,10 +30,10 @@ "sonata-project/cache-bundle": "^2.4", "sonata-project/core-bundle": "^3.0", "twig/twig": "^1.14.2 || ^2.0", - "symfony/security-bundle": "^3.4 || ^4.0", - "symfony/twig-bundle": "^3.4 || ^4.0", - "symfony/asset": "^3.4 || ^4.0", - "symfony/templating": "^3.4 || ^4.0" + "symfony/security-bundle": "^3.4 || ^4.1", + "symfony/twig-bundle": "^3.4 || ^4.1", + "symfony/asset": "^3.4 || ^4.1", + "symfony/templating": "^3.4 || ^4.1" }, "suggest": { "sonata-project/cache-bundle": "To add caching support for block loading", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9e2fa8ea..d20f5260 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,26 +1,36 @@ + - - + + + + + ./tests/Unit - + - ./tests/WebTest ./tests/Functional + ./tests/Functional/Doctrine/Orm - + + + + + + src/ + + Resources/ + + + + + - - - src/ - - Resources/ - - - + + diff --git a/src/Resources/meta/LICENSE b/src/Resources/meta/LICENSE index d47232ec..dbff6eb8 100644 --- a/src/Resources/meta/LICENSE +++ b/src/Resources/meta/LICENSE @@ -2,7 +2,7 @@ Symfony CMF Block Bundle The MIT License - Copyright (c) 2011-2017 Symfony CMF + Copyright (c) Symfony CMF Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 2bbf4efe5824b4bc22332f27046cfe86ab2977ff Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Thu, 28 Feb 2019 20:26:38 +0100 Subject: [PATCH 14/20] change changelog entry --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c0a2373..cf9b5b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ Changelog ========= -3.0.0 (unreleased) ------------------- +2.2.0 (unreleased) +------------------ +* **2019-02-28**: Symfony 4.2 support without warnings 2.1.1 ----- From 93720afe23ca011e532cd5eddc327500934c8443 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Fri, 1 Mar 2019 15:48:32 +0100 Subject: [PATCH 15/20] DevKit updates --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69a41315..77a1266c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,8 +31,8 @@ env: global: - SYMFONY_DEPRECATIONS_HELPER="/.*each.*/" - SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" - - SYMFONY_PHPUNIT_VERSION=6 - - PHPUNIT_VERSION=6 + - SYMFONY_PHPUNIT_VERSION=7 + - PHPUNIT_VERSION=7 - TARGET=test matrix: From 5d49e319e31c6872e32dccc8dea71db0222d5f84 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Sun, 3 Mar 2019 07:38:17 +0100 Subject: [PATCH 16/20] increase sonata block bundle version --- CHANGELOG.md | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf9b5b58..9e0b5701 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ Changelog Release 2.0.0 -2.0.0-RC2 +2.0.0-RC2Mo --------- * **2017-02-10**: [BC BREAK] Removed the `ImagineBlock` as the CmfMediaBundle diff --git a/composer.json b/composer.json index 3a640e3c..9ef25ee0 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "symfony/framework-bundle": "^3.4 || ^4.1", "doctrine/phpcr-bundle": "^1.3 || ^2.0", "doctrine/phpcr-odm": "^1.4.2 || ^2.0", - "sonata-project/block-bundle": "^3.11", + "sonata-project/block-bundle": "^3.14", "symfony-cmf/core-bundle": "^2.0" }, "require-dev": { From 58d5216eb31149d24145922461b6500235835ba8 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Sun, 3 Mar 2019 23:55:18 +0100 Subject: [PATCH 17/20] use higher sonata block-bundle version --- .gitignore | 3 +++ composer.json | 9 ++++---- src/Controller/RssController.php | 3 +-- src/Twig/Extension/CmfBlockExtension.php | 27 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f5cd204f..c681ae63 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ vendor/ composer.lock tests/Fixtures/App/var !tests/Fixtures/App/var/.gitempty +build +.phpunit +.php_cs.cache diff --git a/composer.json b/composer.json index 9ef25ee0..620284ed 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,9 @@ "symfony/framework-bundle": "^3.4 || ^4.1", "doctrine/phpcr-bundle": "^1.3 || ^2.0", "doctrine/phpcr-odm": "^1.4.2 || ^2.0", - "sonata-project/block-bundle": "^3.14", - "symfony-cmf/core-bundle": "^2.0" + "sonata-project/block-bundle": "^3.15", + "symfony-cmf/core-bundle": "^2.0", + "twig/twig": "^1.14.2" }, "require-dev": { "symfony-cmf/testing": "^2.1.8", @@ -29,11 +30,11 @@ "symfony/phpunit-bridge": "^4.2.2", "sonata-project/cache-bundle": "^2.4", "sonata-project/core-bundle": "^3.0", - "twig/twig": "^1.14.2 || ^2.0", "symfony/security-bundle": "^3.4 || ^4.1", "symfony/twig-bundle": "^3.4 || ^4.1", "symfony/asset": "^3.4 || ^4.1", - "symfony/templating": "^3.4 || ^4.1" + "symfony/templating": "^3.4 || ^4.1", + "symfony/yaml": "^3.4 || ^4.1" }, "suggest": { "sonata-project/cache-bundle": "To add caching support for block loading", diff --git a/src/Controller/RssController.php b/src/Controller/RssController.php index 31206ce3..e4d2e179 100644 --- a/src/Controller/RssController.php +++ b/src/Controller/RssController.php @@ -16,7 +16,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Cmf\Bundle\BlockBundle\Model\FeedItem; use Symfony\Component\HttpFoundation\Response; -use Zend\Feed\Reader\Exception\RuntimeException; class RssController extends AbstractController { @@ -64,7 +63,7 @@ protected function getItems(BlockContextInterface $blockContext) try { $reader = $this->get('eko_feed.feed.reader'); $items = $reader->load($settings['url'])->populate($settings['itemClass']); - } catch (RuntimeException $e) { + } catch (\RuntimeException $e) { // feed import failed $this->get('logger')->debug(sprintf( 'RssBlock with id "%s" could not import feed from "%s", error: %s', diff --git a/src/Twig/Extension/CmfBlockExtension.php b/src/Twig/Extension/CmfBlockExtension.php index 6ed634cd..f13a58b6 100644 --- a/src/Twig/Extension/CmfBlockExtension.php +++ b/src/Twig/Extension/CmfBlockExtension.php @@ -12,6 +12,7 @@ namespace Symfony\Cmf\Bundle\BlockBundle\Twig\Extension; use Symfony\Cmf\Bundle\BlockBundle\Templating\Helper\CmfBlockHelper; +use Twig_Environment; /** * Utility function for blocks. @@ -42,4 +43,30 @@ public function getName() { return 'cmf_block'; } + + /** + * Initializes the runtime environment. + * + * This is where you can load some file that contains filter functions for instance. + * + * @param Twig_Environment $environment The current Twig_Environment instance + * + * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterace instead + */ + public function initRuntime(Twig_Environment $environment): void + { + // TODO: Implement initRuntime() method. + } + + /** + * Returns a list of global variables to add to the existing list. + * + * @return array An array of global variables + * + * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_GlobalsInterface instead + */ + public function getGlobals(): [] + { + return []; + } } From ea14d0484c1186750a5f40bee0ac4c045bf019fb Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Sun, 3 Mar 2019 23:59:22 +0100 Subject: [PATCH 18/20] some cs fixes for pHP --- src/Block/ActionBlockService.php | 13 +- src/Block/ContainerBlockService.php | 4 +- src/Block/MenuBlockService.php | 4 +- src/Block/PhpcrBlockLoader.php | 80 ++++----- src/Block/ReferenceBlockService.php | 4 +- src/Block/SimpleBlockService.php | 4 +- src/Block/StringBlockService.php | 4 +- src/Cache/BlockJsCache.php | 166 +++++++++--------- src/Cache/BlockSsiCache.php | 62 +++---- src/Cache/BlockVarnishCache.php | 62 +++---- src/CmfBlockBundle.php | 4 +- src/Controller/RssController.php | 6 +- src/DependencyInjection/CmfBlockExtension.php | 34 ++-- .../Compiler/ValidationPass.php | 4 +- src/DependencyInjection/Configuration.php | 4 +- src/Doctrine/Phpcr/AbstractBlock.php | 6 +- src/Doctrine/Phpcr/ActionBlock.php | 5 +- src/Doctrine/Phpcr/ContainerBlock.php | 6 +- src/Doctrine/Phpcr/MenuBlock.php | 4 +- src/Doctrine/Phpcr/ReferenceBlock.php | 4 +- src/Doctrine/Phpcr/RssBlock.php | 4 +- src/Doctrine/Phpcr/SimpleBlock.php | 4 +- src/Doctrine/Phpcr/SlideshowBlock.php | 4 +- src/Doctrine/Phpcr/StringBlock.php | 4 +- src/Model/AbstractBlock.php | 34 ++-- src/Model/FeedItem.php | 4 +- src/Templating/Helper/CmfBlockHelper.php | 4 +- src/Templating/Helper/EmbedBlocksParser.php | 6 +- src/Twig/Extension/CmfBlockExtension.php | 2 +- .../Block/ActionBlockServiceTest.php | 4 +- .../Block/ContainerBlockServiceTest.php | 4 +- .../Functional/Block/MenuBlockServiceTest.php | 4 +- .../Functional/Block/PhpcrBlockLoaderTest.php | 20 ++- .../Block/ReferenceBlockServiceTest.php | 4 +- .../Block/SimpleBlockServiceTest.php | 4 +- .../Block/StringBlockServiceTest.php | 4 +- tests/Unit/Cache/BlockJsCacheTest.php | 7 +- tests/Unit/Cache/BlockSsiCacheTest.php | 17 +- tests/Unit/Cache/BlockVarnishCacheTest.php | 17 +- .../DependencyInjection/XmlSchemaTest.php | 4 +- .../Templating/Helper/CmfBlockHelperTest.php | 4 +- .../Helper/EmbedBlocksParserTest.php | 8 +- .../Twig/Extension/CmfBlockExtensionTest.php | 4 +- .../WebTest/Render/ActionBlockRenderTest.php | 4 +- .../Render/ContainerBlockRenderTest.php | 4 +- .../Render/ReferenceBlockRenderTest.php | 4 +- .../WebTest/Render/SimpleBlockRenderTest.php | 4 +- .../WebTest/Render/StringBlockRenderTest.php | 4 +- 48 files changed, 379 insertions(+), 292 deletions(-) diff --git a/src/Block/ActionBlockService.php b/src/Block/ActionBlockService.php index 4d752503..9ba37838 100644 --- a/src/Block/ActionBlockService.php +++ b/src/Block/ActionBlockService.php @@ -1,9 +1,11 @@ getNotFoundBlock($configuration['name'], sprintf( "Document at '%s' is no Sonata\\BlockBundle\\Model\\BlockInterface but %s", $configuration['name'], - null === $block ? 'not existing' : get_class($block) + null === $block ? 'not existing' : \get_class($block) )); } @@ -140,7 +142,7 @@ public function load($configuration) */ public function support($configuration) { - if (!is_array($configuration)) { + if (!\is_array($configuration)) { return false; } @@ -151,6 +153,22 @@ public function support($configuration) return true; } + /** + * @return string|null service id of the empty block service, null if not set + */ + public function getEmptyBlockType() + { + return $this->emptyBlockType; + } + + /** + * @param string $type service id of the empty block service + */ + public function setEmptyBlockType($type = null) + { + $this->emptyBlockType = $type; + } + /** * Finds one block by the given name (PHPCR path). * @@ -197,8 +215,8 @@ protected function findByName($name) */ protected function isAbsolutePath($path) { - return is_string($path) - && strlen($path) > 0 + return \is_string($path) + && \strlen($path) > 0 && '/' === $path[0] ; } @@ -225,8 +243,16 @@ protected function determineAbsolutePath($name) ->getDocumentId($currentPage).'/'.$name ; } + } - return; + /** + * Get the object manager from the registry, based on the current managerName. + * + * @return \Doctrine\Common\Persistence\ObjectManager + */ + protected function getObjectManager() + { + return $this->managerRegistry->getManager($this->managerName); } /** @@ -238,9 +264,9 @@ protected function determineAbsolutePath($name) * @param string $name The block name that was not found or invalid * @param string $message The exception message if an exception should be raised * - * @return EmptyBlock - * * @throws BlockNotFoundException if there is no type defined for the empty block + * + * @return EmptyBlock */ private function getNotFoundBlock($name, $message = null) { @@ -259,30 +285,4 @@ private function getNotFoundBlock($name, $message = null) return $block; } - - /** - * @return string|null service id of the empty block service, null if not set - */ - public function getEmptyBlockType() - { - return $this->emptyBlockType; - } - - /** - * @param string $type service id of the empty block service - */ - public function setEmptyBlockType($type = null) - { - $this->emptyBlockType = $type; - } - - /** - * Get the object manager from the registry, based on the current managerName. - * - * @return \Doctrine\Common\Persistence\ObjectManager - */ - protected function getObjectManager() - { - return $this->managerRegistry->getManager($this->managerName); - } } diff --git a/src/Block/ReferenceBlockService.php b/src/Block/ReferenceBlockService.php index 01c50a29..cdf04272 100644 --- a/src/Block/ReferenceBlockService.php +++ b/src/Block/ReferenceBlockService.php @@ -1,9 +1,11 @@ validateKeys($keys); + + return new CacheElement($keys, $data, $ttl, $contextualKeys); + } + + /** + * @param \Symfony\Component\HttpFoundation\Request $request * - * @param array $keys + * @return \Symfony\Component\HttpFoundation\Response */ - private function validateKeys(array $keys) + public function cacheAction(Request $request) { - foreach (['block_id', 'updated_at'] as $key) { - if (!isset($keys[$key])) { - throw new \RuntimeException(sprintf('Please define a `%s` key', $key)); + $block = $this->blockLoader->load(['name' => $request->get('block_id')]); + + if (!$block) { + return new Response('', 404); + } + + $settings = $request->get(BlockContextManagerInterface::CACHE_KEY, []); + + if (!\is_array($settings)) { + throw new \RuntimeException(sprintf( + 'Query string parameter `%s` is not an array', + BlockContextManagerInterface::CACHE_KEY + )); + } + + $response = $this->blockRenderer->render( + $this->blockContextManager->get($block, $settings) + ); + $response->setPrivate(); // always set to private + + if ($this->sync) { + return $response; + } + + $response->setContent(sprintf(<<<'JS' + (function () { + var block = document.getElementById('block%s'), + div = document.createElement("div"), + parentNode = block.parentNode, + node, + replace = true; + + div.innerHTML = %s; + + for (var node in div.childNodes) { + if (div.childNodes[node] && div.childNodes[node].nodeType == 1) { + if (replace) { + parentNode.replaceChild(div.childNodes[node], block); + replace = false; + } else { + parentNode.appendChild(div.childNodes[node]); + } } } + })(); +JS +, $this->dashify($block->getId()), json_encode($response->getContent()))); + + $response->headers->set('Content-Type', 'application/javascript'); + + return $response; + } + + /** + * {@inheritdoc} + */ + public function isContextual() + { + return false; } /** @@ -183,90 +249,26 @@ protected function getAsync(array $keys) } /** - * {@inheritdoc} + * @param string $src + * + * @return mixed */ - public function set(array $keys, $data, $ttl = 84600, array $contextualKeys = []) + protected function dashify($src) { - $this->validateKeys($keys); - - return new CacheElement($keys, $data, $ttl, $contextualKeys); + return preg_replace('/[\/\.]/', '-', $src); } /** - * @param \Symfony\Component\HttpFoundation\Request $request + * @param array $keys * - * @return \Symfony\Component\HttpFoundation\Response + * @throws \RuntimeException */ - public function cacheAction(Request $request) + private function validateKeys(array $keys) { - $block = $this->blockLoader->load(['name' => $request->get('block_id')]); - - if (!$block) { - return new Response('', 404); - } - - $settings = $request->get(BlockContextManagerInterface::CACHE_KEY, []); - - if (!is_array($settings)) { - throw new \RuntimeException(sprintf( - 'Query string parameter `%s` is not an array', - BlockContextManagerInterface::CACHE_KEY - )); - } - - $response = $this->blockRenderer->render( - $this->blockContextManager->get($block, $settings) - ); - $response->setPrivate(); // always set to private - - if ($this->sync) { - return $response; - } - - $response->setContent(sprintf(<<<'JS' - (function () { - var block = document.getElementById('block%s'), - div = document.createElement("div"), - parentNode = block.parentNode, - node, - replace = true; - - div.innerHTML = %s; - - for (var node in div.childNodes) { - if (div.childNodes[node] && div.childNodes[node].nodeType == 1) { - if (replace) { - parentNode.replaceChild(div.childNodes[node], block); - replace = false; - } else { - parentNode.appendChild(div.childNodes[node]); - } + foreach (['block_id', 'updated_at'] as $key) { + if (!isset($keys[$key])) { + throw new \RuntimeException(sprintf('Please define a `%s` key', $key)); } } - })(); -JS -, $this->dashify($block->getId()), json_encode($response->getContent()))); - - $response->headers->set('Content-Type', 'application/javascript'); - - return $response; - } - - /** - * {@inheritdoc} - */ - public function isContextual() - { - return false; - } - - /** - * @param string $src - * - * @return mixed - */ - protected function dashify($src) - { - return preg_replace('/[\/\.]/', '-', $src); } } diff --git a/src/Cache/BlockSsiCache.php b/src/Cache/BlockSsiCache.php index 4fc91af5..837abf75 100644 --- a/src/Cache/BlockSsiCache.php +++ b/src/Cache/BlockSsiCache.php @@ -1,9 +1,11 @@ blockContextManager = $blockContextManager; } - /** - * @throws \RuntimeException - * - * @param array $keys - */ - private function validateKeys(array $keys) - { - foreach (['block_id', 'updated_at'] as $key) { - if (!isset($keys[$key])) { - throw new \RuntimeException(sprintf('Please define a `%s` key', $key)); - } - } - } - /** * {@inheritdoc} */ @@ -92,20 +80,6 @@ public function set(array $keys, $data, $ttl = 84600, array $contextualKeys = [] return new CacheElement($keys, $data, $ttl, $contextualKeys); } - /** - * @param array $keys - * - * @return string - */ - protected function computeHash(array $keys) - { - // values are casted into string for non numeric id - return hash('sha256', $this->token.serialize([ - 'block_id' => (string) $keys['block_id'], - 'updated_at' => (string) $keys['updated_at'], - ])); - } - /** * @param Request $request * @@ -130,7 +104,7 @@ public function cacheAction(Request $request) $settings = $request->get(BlockContextManagerInterface::CACHE_KEY, []); - if (!is_array($settings)) { + if (!\is_array($settings)) { throw new \RuntimeException(sprintf( 'Query string parameter `%s` is not an array', BlockContextManagerInterface::CACHE_KEY @@ -141,4 +115,32 @@ public function cacheAction(Request $request) $this->blockContextManager->get($block, $settings) ); } + + /** + * @param array $keys + * + * @return string + */ + protected function computeHash(array $keys) + { + // values are casted into string for non numeric id + return hash('sha256', $this->token.serialize([ + 'block_id' => (string) $keys['block_id'], + 'updated_at' => (string) $keys['updated_at'], + ])); + } + + /** + * @param array $keys + * + * @throws \RuntimeException + */ + private function validateKeys(array $keys) + { + foreach (['block_id', 'updated_at'] as $key) { + if (!isset($keys[$key])) { + throw new \RuntimeException(sprintf('Please define a `%s` key', $key)); + } + } + } } diff --git a/src/Cache/BlockVarnishCache.php b/src/Cache/BlockVarnishCache.php index 93a36735..c94e000d 100644 --- a/src/Cache/BlockVarnishCache.php +++ b/src/Cache/BlockVarnishCache.php @@ -1,9 +1,11 @@ fragmentHandler = $fragmentHandler; } - /** - * @throws \RuntimeException - * - * @param array $keys - */ - private function validateKeys(array $keys) - { - foreach (['block_id', 'updated_at'] as $key) { - if (!isset($keys[$key])) { - throw new \RuntimeException(sprintf('Please define a `%s` key', $key)); - } - } - } - /** * {@inheritdoc} */ @@ -119,20 +107,6 @@ public function set(array $keys, $data, $ttl = 84600, array $contextualKeys = [] return new CacheElement($keys, $data, $ttl, $contextualKeys); } - /** - * @param array $keys - * - * @return string - */ - protected function computeHash(array $keys) - { - // values are casted into string for non numeric id - return hash('sha256', $this->token.serialize([ - 'block_id' => (string) $keys['block_id'], - 'updated_at' => (string) $keys['updated_at'], - ])); - } - /** * @param Request $request * @@ -157,7 +131,7 @@ public function cacheAction(Request $request) $settings = $request->get(BlockContextManagerInterface::CACHE_KEY, []); - if (!is_array($settings)) { + if (!\is_array($settings)) { throw new \RuntimeException(sprintf( 'Query string parameter `%s` is not an array', BlockContextManagerInterface::CACHE_KEY @@ -168,4 +142,32 @@ public function cacheAction(Request $request) $this->blockContextManager->get($block, $settings) ); } + + /** + * @param array $keys + * + * @return string + */ + protected function computeHash(array $keys) + { + // values are casted into string for non numeric id + return hash('sha256', $this->token.serialize([ + 'block_id' => (string) $keys['block_id'], + 'updated_at' => (string) $keys['updated_at'], + ])); + } + + /** + * @param array $keys + * + * @throws \RuntimeException + */ + private function validateKeys(array $keys) + { + foreach (['block_id', 'updated_at'] as $key) { + if (!isset($keys[$key])) { + throw new \RuntimeException(sprintf('Please define a `%s` key', $key)); + } + } + } } diff --git a/src/CmfBlockBundle.php b/src/CmfBlockBundle.php index e814e095..74a54393 100644 --- a/src/CmfBlockBundle.php +++ b/src/CmfBlockBundle.php @@ -1,9 +1,11 @@ loadSonataCache($config, $loader, $container); } + /** + * Returns the base path for the XSD files. + * + * @return string The XSD base path + */ + public function getXsdValidationBasePath() + { + return __DIR__.'/../Resources/config/schema'; + } + + public function getNamespace() + { + return 'http://cmf.symfony.com/schema/dic/block'; + } + private function loadPhpcr(array $config, XmlFileLoader $loader, ContainerBuilder $container) { $container->setParameter($this->getAlias().'.backend_type_phpcr', true); @@ -132,19 +149,4 @@ private function loadSonataCache(array $config, XmlFileLoader $loader, Container $container->removeDefinition('cmf.block.cache.ssi'); } } - - /** - * Returns the base path for the XSD files. - * - * @return string The XSD base path - */ - public function getXsdValidationBasePath() - { - return __DIR__.'/../Resources/config/schema'; - } - - public function getNamespace() - { - return 'http://cmf.symfony.com/schema/dic/block'; - } } diff --git a/src/DependencyInjection/Compiler/ValidationPass.php b/src/DependencyInjection/Compiler/ValidationPass.php index 71a359de..ee9aae8c 100644 --- a/src/DependencyInjection/Compiler/ValidationPass.php +++ b/src/DependencyInjection/Compiler/ValidationPass.php @@ -1,9 +1,11 @@ getSettings() as $value) { - if (is_array($value)) { + if (\is_array($value)) { $context->addViolation('settings', 'A multidimensional array is not allowed, only use key-value pairs.'); } } diff --git a/src/Doctrine/Phpcr/ActionBlock.php b/src/Doctrine/Phpcr/ActionBlock.php index 9687d8fb..73ddaf5c 100644 --- a/src/Doctrine/Phpcr/ActionBlock.php +++ b/src/Doctrine/Phpcr/ActionBlock.php @@ -1,9 +1,11 @@ children) > 0; + return \count($this->children) > 0; } } diff --git a/src/Doctrine/Phpcr/MenuBlock.php b/src/Doctrine/Phpcr/MenuBlock.php index b24d55d6..d65e7e93 100644 --- a/src/Doctrine/Phpcr/MenuBlock.php +++ b/src/Doctrine/Phpcr/MenuBlock.php @@ -1,9 +1,11 @@ name; } /** @@ -155,7 +157,7 @@ public function getPosition() { $siblings = $this->getParentObject()->getChildren(); - return array_search($siblings->indexOf($this), $siblings->getKeys()); + return array_search($siblings->indexOf($this), $siblings->getKeys(), true); } /** @@ -330,8 +332,6 @@ public function getParent() if (($parent = $this->getParentObject()) instanceof BlockInterface) { return $parent; } - - return; } /** @@ -364,16 +364,6 @@ public function getTtl() return $this->ttl; } - /** - * toString ... - * - * @return string - */ - public function __toString() - { - return (string) $this->name; - } - /** * {@inheritdoc} */ @@ -453,4 +443,14 @@ public function setLocale($locale) return $this; } + + /** + * @param string $src + * + * @return string + */ + protected function dashify($src) + { + return preg_replace('/[\/\.]/', '-', $src); + } } diff --git a/src/Model/FeedItem.php b/src/Model/FeedItem.php index d1c5fbf4..93165b50 100644 --- a/src/Model/FeedItem.php +++ b/src/Model/FeedItem.php @@ -1,9 +1,11 @@ segmentize($text); foreach ($segments as &$segment) { - if (!is_array($segment)) { + if (!\is_array($segment)) { continue; } diff --git a/src/Twig/Extension/CmfBlockExtension.php b/src/Twig/Extension/CmfBlockExtension.php index f13a58b6..acdcaa26 100644 --- a/src/Twig/Extension/CmfBlockExtension.php +++ b/src/Twig/Extension/CmfBlockExtension.php @@ -65,7 +65,7 @@ public function initRuntime(Twig_Environment $environment): void * * @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_GlobalsInterface instead */ - public function getGlobals(): [] + public function getGlobals(): array { return []; } diff --git a/tests/Functional/Block/ActionBlockServiceTest.php b/tests/Functional/Block/ActionBlockServiceTest.php index c7bc99c1..eb85ad4b 100644 --- a/tests/Functional/Block/ActionBlockServiceTest.php +++ b/tests/Functional/Block/ActionBlockServiceTest.php @@ -1,9 +1,11 @@ registryMock, $this->pwcMock, $this->requestStackMock, null, 'emptyblocktype'); - $blockLoader->setManagerName('themanager'); - - return $blockLoader; - } - public function testSupport() { $blockLoader = $this->getSimpleBlockLoaderInstance(); @@ -270,6 +264,14 @@ public function testLoadWithAlternativeDocumentManager() $this->assertInstanceOf('Sonata\BlockBundle\Model\BlockInterface', $foundBlock); $this->assertEquals('alt-block', $foundBlock->getName()); } + + private function getSimpleBlockLoaderInstance() + { + $blockLoader = new PhpcrBlockLoader($this->registryMock, $this->pwcMock, $this->requestStackMock, null, 'emptyblocktype'); + $blockLoader->setManagerName('themanager'); + + return $blockLoader; + } } class MockContent diff --git a/tests/Functional/Block/ReferenceBlockServiceTest.php b/tests/Functional/Block/ReferenceBlockServiceTest.php index 8670111e..450889cc 100644 --- a/tests/Functional/Block/ReferenceBlockServiceTest.php +++ b/tests/Functional/Block/ReferenceBlockServiceTest.php @@ -1,9 +1,11 @@ expectException(\RuntimeException::class); + $router = $this->createMock(RouterInterface::class); $blockRenderer = $this->createMock(BlockRendererInterface::class); diff --git a/tests/Unit/Cache/BlockSsiCacheTest.php b/tests/Unit/Cache/BlockSsiCacheTest.php index 39e433cd..023a9864 100644 --- a/tests/Unit/Cache/BlockSsiCacheTest.php +++ b/tests/Unit/Cache/BlockSsiCacheTest.php @@ -1,9 +1,11 @@ expectException(\RuntimeException::class); + $router = $this->createMock(RouterInterface::class); $blockRenderer = $this->createMock(BlockRendererInterface::class); @@ -83,11 +86,10 @@ public function testInitCache() $this->assertEquals('', $cacheElement->getData()->getContent()); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ public function testAccessDenied() { + $this->expectException(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); + $token = 'My Token'; $keys = [ 'block_id' => '/cms/content/home/additionalInfoBlock', @@ -109,11 +111,10 @@ public function testAccessDenied() $cache->cacheAction($request); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ public function testBlockNotFound() { + $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); + $token = 'My Token'; $keys = [ 'block_id' => '/not/found', diff --git a/tests/Unit/Cache/BlockVarnishCacheTest.php b/tests/Unit/Cache/BlockVarnishCacheTest.php index 677cd30a..1527bdbb 100644 --- a/tests/Unit/Cache/BlockVarnishCacheTest.php +++ b/tests/Unit/Cache/BlockVarnishCacheTest.php @@ -1,9 +1,11 @@ expectException(\RuntimeException::class); + $router = $this->createMock(RouterInterface::class); $blockRenderer = $this->createMock(BlockRendererInterface::class); @@ -102,11 +105,10 @@ public function testInitCache() $this->assertEquals($content, $cacheElement->getData()->getContent()); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ public function testAccessDenied() { + $this->expectException(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException::class); + $token = 'My Token'; $keys = [ 'block_id' => '/cms/content/home/additionalInfoBlock', @@ -128,11 +130,10 @@ public function testAccessDenied() $cache->cacheAction($request); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ public function testBlockNotFound() { + $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); + $token = 'My Token'; $keys = [ 'block_id' => '/not/found', diff --git a/tests/Unit/DependencyInjection/XmlSchemaTest.php b/tests/Unit/DependencyInjection/XmlSchemaTest.php index c28c7b19..548d1814 100644 --- a/tests/Unit/DependencyInjection/XmlSchemaTest.php +++ b/tests/Unit/DependencyInjection/XmlSchemaTest.php @@ -1,9 +1,11 @@ Date: Mon, 4 Mar 2019 00:11:24 +0100 Subject: [PATCH 19/20] do no use an integer for uniqueid() --- src/DependencyInjection/Configuration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 6677ab1f..7d48ffe7 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -74,7 +74,7 @@ public function getConfigTreeBuilder() ->arrayNode('varnish') ->fixXmlConfig('server') ->children() - ->scalarNode('token')->defaultValue(hash('sha256', uniqid(mt_rand(), true)))->end() + ->scalarNode('token')->defaultValue(hash('sha256', uniqid((string) mt_rand(), true)))->end() ->scalarNode('version')->defaultValue(2)->end() ->arrayNode('servers') ->prototype('scalar')->end() @@ -83,7 +83,7 @@ public function getConfigTreeBuilder() ->end() ->arrayNode('ssi') ->children() - ->scalarNode('token')->defaultValue(hash('sha256', uniqid(mt_rand(), true)))->end() + ->scalarNode('token')->defaultValue(hash('sha256', uniqid((string) mt_rand(), true)))->end() ->end() ->end() ->end() From f80e7fc1d46ca02491d646eb9e5585d8655a8264 Mon Sep 17 00:00:00 2001 From: electricmaxxx Date: Mon, 4 Mar 2019 00:14:13 +0100 Subject: [PATCH 20/20] add changes from down --- src/Twig/Extension/CmfBlockExtension.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Twig/Extension/CmfBlockExtension.php b/src/Twig/Extension/CmfBlockExtension.php index acdcaa26..731644c5 100644 --- a/src/Twig/Extension/CmfBlockExtension.php +++ b/src/Twig/Extension/CmfBlockExtension.php @@ -1,9 +1,11 @@