From 05484792ee77fc28dab6323a3a68731333a116ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFck=20Piera?= Date: Tue, 2 Jan 2018 18:42:48 +0100 Subject: [PATCH] Drop SF 2 and add SF 4 compatibility (#32) * Drop SF 2 and add SF 4 compatibility * Add dev dependency on prophecy and update tests fixtures --- .travis.yml | 45 +++++++++++-------- CHANGELOG.md | 5 +++ CONTRIBUTING.md | 4 +- Makefile | 8 ++++ composer.json | 21 ++++----- .../Symfony/Resources/config/services.yml | 1 + .../Fixtures/symfony/app/AppKernel.php | 6 +-- .../app/config/config_greater_than_3-0.yml | 8 ---- .../app/config/config_lower_than_3-0.yml | 6 --- .../Fixtures/symfony/app/config/routing.yml | 2 +- .../symfony/src/Controller/AppController.php | 5 +++ 11 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 Makefile delete mode 100644 tests/Functional/Fixtures/symfony/app/config/config_greater_than_3-0.yml delete mode 100644 tests/Functional/Fixtures/symfony/app/config/config_lower_than_3-0.yml diff --git a/.travis.yml b/.travis.yml index 0b0c22f..129102a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,36 +1,43 @@ language: php -sudo: false +php: + - 7.0 + - 7.1 -cache: - directories: - - $HOME/.composer/cache +env: + global: + - TARGET=test + - SYMFONY_PHPUNIT_REMOVE="symfony/yaml" matrix: + fast_finish: true include: - php: 7.0 - env: check_cs=true + env: TARGET=cs_dry_run + - php: 7.0 + env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak + # test 3.4 LTS - php: 7.0 - env: deps=low + env: SYMFONY_VERSION=3.4.* + # test the latest release (including beta releases) - php: 7.1 - env: deps=high + env: DEPENDENCIES=beta -env: - global: - - deps=high - - check_cs=false - - SYMFONY_PHPUNIT_REMOVE="symfony/yaml" +sudo: false + +cache: + directories: + - $HOME/.composer/cache -install: - - if [ "$deps" = "low" ]; then composer --prefer-dist --prefer-lowest update; fi; - - if [ "$deps" != "low" ]; then composer --prefer-dist update; fi; +before_install: + - if [ "$DEPENDENCIES" = "beta" ]; then perl -pi -e 's/^}$/,"minimum-stability":"beta"}/' composer.json; fi; + - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi; + - echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; -before_script: - - composer install --no-interaction +install: composer update --prefer-dist --no-interaction $COMPOSER_FLAGS script: - - vendor/bin/simple-phpunit - - if [ "$check_cs" = "true" ]; then vendor/bin/php-cs-fixer fix --config=.php_cs --dry-run --diff; fi; + - make $TARGET branches: only: diff --git a/CHANGELOG.md b/CHANGELOG.md index f3c3928..7d2a0fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changes between versions +## Not yet released + +* Dropped compatibility with Symfony < 3.0 +* Added compatibility with Symfony 4.0 + ## 0.5.1 (2017-12-28) * Fix Symfony 3.4 / 4.0 compatibility with DataCollector diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7f646e..74356d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,7 +48,7 @@ changes, improvements or alternatives may be given). Run the tests using the following script: ```shell -composer test +make test ``` ## Standard code @@ -57,7 +57,7 @@ Use [PHP CS fixer](http://cs.sensiolabs.org/) to make your code compliant with this project's coding standards: ```shell -vendor/bin/php-cs-fixer fix . +make cs ``` ## Keeping your fork up-to-date diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..792a502 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +cs: + ./vendor/bin/php-cs-fixer fix --verbose + +cs_dry_run: + ./vendor/bin/php-cs-fixer fix --verbose --dry-run + +test: + ./vendor/bin/simple-phpunit diff --git a/composer.json b/composer.json index 5ceadc4..6dc8c0f 100644 --- a/composer.json +++ b/composer.json @@ -32,13 +32,15 @@ "doctrine/doctrine-bundle": "~1.6", "doctrine/orm": "~2.5", "friendsofphp/php-cs-fixer": "~2.2", - "symfony/config": "~2.7|~3.0", - "symfony/dependency-injection": "~2.7|~3.0", - "symfony/framework-bundle": "~2.7.25|~2.8.15|~3.0", - "symfony/http-kernel": "~2.7|~3.0", - "symfony/phpunit-bridge": "^3.3", - "symfony/twig-bundle": "~2.7|~3.0", - "symfony/yaml": "~2.7|~3.0" + "phpdocumentor/reflection-docblock": "^4.0", + "phpspec/prophecy": "^1.7", + "symfony/config": "~3.0|~4.0", + "symfony/dependency-injection": "~3.0|~4.0", + "symfony/framework-bundle": "~3.0|~4.0", + "symfony/http-kernel": "~3.0|~4.0", + "symfony/phpunit-bridge": "^3.3|~4.0", + "symfony/twig-bundle": "~3.0|~4.0", + "symfony/yaml": "~3.0|~4.0" }, "config": { "sort-packages": true @@ -47,10 +49,5 @@ "branch-alias": { "dev-master": "0.x-dev" } - }, - "scripts": { - "test": [ - "SYMFONY_PHPUNIT_REMOVE=\"symfony/yaml\" vendor/bin/simple-phpunit" - ] } } diff --git a/src/Bridge/Symfony/Resources/config/services.yml b/src/Bridge/Symfony/Resources/config/services.yml index b801443..01ad4d5 100644 --- a/src/Bridge/Symfony/Resources/config/services.yml +++ b/src/Bridge/Symfony/Resources/config/services.yml @@ -10,6 +10,7 @@ services: seo_override.subscriber: class: Joli\SeoOverride\Bridge\Symfony\Subscriber\SeoSubscriber + public: true arguments: - '@seo_override.manager' - '@seo_override.blacklister.default' # Service declared in the DIC extension diff --git a/tests/Functional/Fixtures/symfony/app/AppKernel.php b/tests/Functional/Fixtures/symfony/app/AppKernel.php index dee7f8b..73931e6 100644 --- a/tests/Functional/Fixtures/symfony/app/AppKernel.php +++ b/tests/Functional/Fixtures/symfony/app/AppKernel.php @@ -36,10 +36,6 @@ public function getLogDir() public function registerContainerConfiguration(LoaderInterface $loader) { - if (version_compare(self::VERSION, '3.0.0', '<')) { - $loader->load($this->getRootDir().'/config/config_lower_than_3-0.yml'); - } else { - $loader->load($this->getRootDir().'/config/config_greater_than_3-0.yml'); - } + $loader->load($this->getRootDir().'/config/config.yml'); } } diff --git a/tests/Functional/Fixtures/symfony/app/config/config_greater_than_3-0.yml b/tests/Functional/Fixtures/symfony/app/config/config_greater_than_3-0.yml deleted file mode 100644 index b23403b..0000000 --- a/tests/Functional/Fixtures/symfony/app/config/config_greater_than_3-0.yml +++ /dev/null @@ -1,8 +0,0 @@ -imports: - - { resource: config.yml } - -framework: - templating: - enabled: false - assets: - enabled: false diff --git a/tests/Functional/Fixtures/symfony/app/config/config_lower_than_3-0.yml b/tests/Functional/Fixtures/symfony/app/config/config_lower_than_3-0.yml deleted file mode 100644 index ae535d2..0000000 --- a/tests/Functional/Fixtures/symfony/app/config/config_lower_than_3-0.yml +++ /dev/null @@ -1,6 +0,0 @@ -imports: - - { resource: config.yml } - -framework: - templating: - engines: ['twig'] diff --git a/tests/Functional/Fixtures/symfony/app/config/routing.yml b/tests/Functional/Fixtures/symfony/app/config/routing.yml index 7fd729c..5b64d4b 100644 --- a/tests/Functional/Fixtures/symfony/app/config/routing.yml +++ b/tests/Functional/Fixtures/symfony/app/config/routing.yml @@ -1,7 +1,7 @@ index: path: / defaults: - _controller: FrameworkBundle:Template:template + _controller: app.controller:templateAction template: index.html.twig error: diff --git a/tests/Functional/Fixtures/symfony/src/Controller/AppController.php b/tests/Functional/Fixtures/symfony/src/Controller/AppController.php index 0c32850..2c12a83 100644 --- a/tests/Functional/Fixtures/symfony/src/Controller/AppController.php +++ b/tests/Functional/Fixtures/symfony/src/Controller/AppController.php @@ -8,6 +8,11 @@ class AppController extends Controller { + public function templateAction(string $template) + { + return new Response($this->renderView($template), 200); + } + public function errorAction() { return new Response($this->renderView('error.html.twig'), 400);