From 694630372c40ea3f21dd42870f18bb6cdb21ad34 Mon Sep 17 00:00:00 2001 From: Gilles Gauthier Date: Wed, 18 Dec 2019 09:14:27 +0100 Subject: [PATCH] Update to SF 4.4, SF5 (#5) * up to sf 4.4, 5.0 --- .travis.yml | 47 ++++++------------- .../LexikCronFileGeneratorExtensionTest.php | 3 ++ .../Functional/ForwardCompatTestCaseTrait.php | 34 ++++++++++++++ Tests/Functional/TestCase.php | 10 +--- Tests/Functional/app/config/base_config.yml | 1 + .../app/config/empty_cron_config.yml | 1 + composer.json | 14 +++--- phpunit.xml.dist | 10 +++- 8 files changed, 71 insertions(+), 49 deletions(-) create mode 100644 Tests/Functional/ForwardCompatTestCaseTrait.php diff --git a/.travis.yml b/.travis.yml index 6f35ea2..abee7a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,51 +1,32 @@ language: php -sudo: false + +dist: trusty + cache: directories: - - $HOME/.composer/cache/files - - $HOME/symfony-bridge/.phpunit - -env: - global: - - PHPUNIT_FLAGS="-v" - - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" + - $HOME/.composer/cache matrix: fast_finish: true include: - # Minimum supported dependencies with the latest and oldest PHP version - - php: 7.2 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" - - php: 7.0 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors" - - # Test the latest stable release - - php: 7.0 - - php: 7.1 - - php: 7.2 - env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" - - # Latest commit to master - - php: 7.2 - env: STABILITY="dev" - - allow_failures: - # Dev-master is allowed to fail. - - env: STABILITY="dev" + - php: 7.3 + env: SYMFONY_VERSION=3.4.* + - php: 7.3 + env: SYMFONY_VERSION=4.3.* + - php: 7.3 + env: SYMFONY_VERSION=4.4.* + - php: 7.3 + env: SYMFONY_VERSION=5.0.* before_install: - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi - - if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; - - if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi; + - if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi; install: - # To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355 - - if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi + - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi; - composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction - ./vendor/bin/simple-phpunit install script: - composer validate --strict --no-check-lock - # simple-phpunit is the PHPUnit wrapper provided by the PHPUnit Bridge component and - # it helps with testing legacy code and deprecations (composer require symfony/phpunit-bridge) - ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS diff --git a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php index ee7c9d7..beea65a 100644 --- a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php +++ b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php @@ -26,6 +26,7 @@ public function testLoadConfiguration() ], 'twig' => [ 'strict_variables' => true, + 'exception_controller' => null, // to be removed in 5.0 ], 'lexik_cron_file_generator' => [ 'env_available' => [ @@ -80,6 +81,7 @@ private function createContainer(array $configs = []) 'FrameworkBundle' => FrameworkBundle::class, 'LexikCronFileGeneratorBundle' => LexikCronFileGeneratorBundle::class, ], + 'env(base64:default::SYMFONY_DECRYPTION_SECRET)' => 'dummy', ])); $container->set( @@ -104,6 +106,7 @@ public function registerContainerConfiguration(LoaderInterface $loader) $container->loadFromExtension($extension, $config); } + return $container; } diff --git a/Tests/Functional/ForwardCompatTestCaseTrait.php b/Tests/Functional/ForwardCompatTestCaseTrait.php new file mode 100644 index 0000000..af32cdc --- /dev/null +++ b/Tests/Functional/ForwardCompatTestCaseTrait.php @@ -0,0 +1,34 @@ +hasReturnType()) { + eval(' + namespace Lexik\Bundle\CronFileGeneratorBundle\Tests\Functional; + /** + * @internal + */ + trait ForwardCompatTestCaseTrait + { + protected function tearDown(): void + { + static::ensureKernelShutdown(); + static::$kernel = null; + } + } + '); +} else { + /** + * @internal + */ + trait ForwardCompatTestCaseTrait + { + protected function tearDown() + { + static::ensureKernelShutdown(); + static::$kernel = null; + } + } +} diff --git a/Tests/Functional/TestCase.php b/Tests/Functional/TestCase.php index eff64d4..fb8d15b 100644 --- a/Tests/Functional/TestCase.php +++ b/Tests/Functional/TestCase.php @@ -7,6 +7,8 @@ abstract class TestCase extends WebTestCase { + use ForwardCompatTestCaseTrait; + protected static $client; /** @@ -27,12 +29,4 @@ protected function setUp() $fs = new Filesystem(); $fs->remove(\sys_get_temp_dir().'/LexikCronFileGeneratorBundle/'); } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - static::$kernel = null; - } } diff --git a/Tests/Functional/app/config/base_config.yml b/Tests/Functional/app/config/base_config.yml index c344ede..b63e6a7 100644 --- a/Tests/Functional/app/config/base_config.yml +++ b/Tests/Functional/app/config/base_config.yml @@ -7,6 +7,7 @@ framework: twig: strict_variables: false default_path: './Resources/views' + exception_controller: null lexik_cron_file_generator: env_available: diff --git a/Tests/Functional/app/config/empty_cron_config.yml b/Tests/Functional/app/config/empty_cron_config.yml index 1b6fc67..1e53d81 100644 --- a/Tests/Functional/app/config/empty_cron_config.yml +++ b/Tests/Functional/app/config/empty_cron_config.yml @@ -7,6 +7,7 @@ framework: twig: strict_variables: false default_path: './Resources/views' + exception_controller: null lexik_cron_file_generator: env_available: diff --git a/composer.json b/composer.json index 8d5faf9..1a999e9 100644 --- a/composer.json +++ b/composer.json @@ -12,16 +12,16 @@ ], "require": { "php": "^7.0", - "symfony/console": "^3.4|^4.0", - "symfony/framework-bundle": "^3.4|^4.0", - "symfony/twig-bundle": "^3.4|^4.0", - "twig/twig": "~1.34|~2.4" + "symfony/console": "^3.4|^4.0|^5.0", + "symfony/framework-bundle": "^3.4|^4.0|^5.0", + "symfony/twig-bundle": "^3.4|^4.0|^5.0", + "twig/twig": "~1.34|~2.4|^3.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^1.1|^2.8", - "symfony/phpunit-bridge": "^3.4|^4.0", - "symfony/yaml": "^3.4|^4.0", - "symfony/var-dumper": "^3.4|^4.0" + "symfony/phpunit-bridge": "^3.4|^4.0|^5.0", + "symfony/yaml": "^3.4|^4.0|^5.0", + "symfony/var-dumper": "^3.4|^4.0|^5.0" }, "autoload": { "psr-4": { "Lexik\\Bundle\\CronFileGeneratorBundle\\": "" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ea5e2cd..5930985 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,4 +26,12 @@ - \ No newline at end of file + + + + + + + + +