diff --git a/.travis.yml b/.travis.yml index dfa28c1..4bc508e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,75 @@ language: php + sudo: false -dist: trusty -php: - - 7.1 - - 7.0 - - 5.6 - - hhvm +cache: + directories: + - $HOME/.composer/cache/files + - $HOME/symfony-bridge/.phpunit env: - global: - - COMPOSER_COMMAND="composer install --prefer-dist" - - TEST_COMMAND="php vendor/bin/phpunit" - - COVERAGE=false - matrix: - - SYMFONY_VERSION=2.7.* - - SYMFONY_VERSION=2.8.* - - SYMFONY_VERSION=3.1.* - - SYMFONY_VERSION=3.2.* + global: + - TEST_COMMAND="composer test" + - SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit" + - SYMFONY_DEPRECATIONS_HELPER="weak" branches: - except: - - /^analysis-.*$/ - - /^patch-.*$/ + except: + - /^analysis-.*$/ matrix: - fast_finish: true - include: - - php: 5.6 - env: COMPOSER_COMMAND="composer update --prefer-lowest --prefer-stable" COVERAGE=true TEST_COMMAND="php -dzend_extension=xdebug.so vendor/bin/phpunit --coverage-clover=coverage.xml" SYMFONY_VERSION=2.7.* + fast_finish: true + include: + # Minimum supported Symfony version and latest PHP version + - php: 7.2 + env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" + - php: 5.6 + env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" -cache: - directories: - - $HOME/.composer/cache + # Test the latest stable release + - php: 5.6 + - php: 7.0 + - php: 7.1 + - php: 7.2 + env: COVERAGE=true TEST_COMMAND="composer test-ci" + + # Test LTS versions + - php: 7.2 + env: DEPENDENCIES="dunglas/symfony-lock:^2 symfony/property-access:^2.8" + - php: 7.2 + env: DEPENDENCIES="dunglas/symfony-lock:^3" + - php: 7.2 + env: DEPENDENCIES="dunglas/symfony-lock:^4" + + # Latest commit to master + - php: 7.2 + env: STABILITY="dev" + + allow_failures: + # dev stability is allowed to fail. + - env: STABILITY="dev" before_install: - - if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-rm xdebug.ini; fi; - - pip install --user codecov - - composer require symfony/symfony:${SYMFONY_VERSION} --no-update + - 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; + - pip install --user codecov install: - - travis_retry ${COMPOSER_COMMAND} --no-interaction + # 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 + - composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction + - vendor/bin/simple-phpunit install script: - - $TEST_COMMAND + - composer validate --strict --no-check-lock + - $TEST_COMMAND after_success: - - if [[ "$COVERAGE" = true ]]; then codecov; fi + - if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi + - if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi + - if [[ "$COVERAGE" = true ]]; then codecov; fi + +after_script: + - wget http://tnyholm.se/reporter.phar + - php reporter.phar build:upload diff --git a/composer.json b/composer.json index 4c23021..a9ac720 100644 --- a/composer.json +++ b/composer.json @@ -25,19 +25,27 @@ ], "require": { "php": "^5.6 || ^7.0", - "symfony/framework-bundle": "^2.7 || ^3.0", - "symfony/var-dumper": "^3.3", - "cache/taggable-cache": "^1.0", "cache/session-handler": "^1.0", - "nyholm/nsa": "^1.1" + "cache/taggable-cache": "^1.0", + "nyholm/nsa": "^1.1", + "symfony/config": "^2.7 || ^3.0 || ^4.0", + "symfony/console": "^2.7 || ^3.0 || ^4.0", + "symfony/dependency-injection": "^2.7 || ^3.0 || ^4.0", + "symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0", + "symfony/http-foundation": "^2.7 || ^3.0 || ^4.0", + "symfony/http-kernel": "^2.7 || ^3.0 || ^4.0", + "symfony/var-dumper": "^2.7 || ^3.3 || ^4.0" }, "require-dev": { - "phpunit/phpunit": "^5.7.17", - "symfony/symfony": "^2.7 || ^3.0", - "cache/psr-6-doctrine-bridge": "^3.0", "cache/array-adapter": "^1.0", + "cache/psr-6-doctrine-bridge": "^3.0", + "doctrine/annotations": "^1.0", + "matthiasnoback/symfony-dependency-injection-test": "^1.1 || ^2.3", "nyholm/symfony-bundle-test": "^1.2", - "matthiasnoback/symfony-dependency-injection-test": "^1.0" + "symfony/phpunit-bridge": "^3.3 || ^4.0", + "symfony/routing": "^2.7 || ^3.0 || ^4.0", + "symfony/serializer": "^2.7 || ^3.0 || ^4.0", + "symfony/validator": "^2.7 || ^3.0 || ^4.0" }, "suggest": { "cache/adapter-bundle": "To register PSR-6 compliant cache implementations as services.", @@ -52,5 +60,12 @@ "psr-4": { "Cache\\CacheBundle\\Tests\\": "tests/" } + }, + "scripts": { + "test": "vendor/bin/simple-phpunit", + "test-ci": "vendor/bin/simple-phpunit --coverage-text --coverage-clover=build/coverage.xml" + }, + "config": { + "sort-packages": true } } diff --git a/tests/Functional/BundleInitializationTest.php b/tests/Functional/BundleInitializationTest.php index a0a935e..5f24762 100644 --- a/tests/Functional/BundleInitializationTest.php +++ b/tests/Functional/BundleInitializationTest.php @@ -17,6 +17,7 @@ use Cache\CacheBundle\Routing\CachingRouter; use Cache\SessionHandler\Psr6SessionHandler; use Nyholm\BundleTest\BaseBundleTestCase; +use Symfony\Component\HttpKernel\Kernel; /** * @author Tobias Nyholm @@ -33,6 +34,10 @@ protected function setUp() parent::setUp(); $kernel = $this->createKernel(); $kernel->addConfigFile(__DIR__.'/config.yml'); + + if (Kernel::MAJOR_VERSION < 4) { + $kernel->addConfigFile(__DIR__.'/sf2_and_3.yml'); + } } public function testInitBundle() @@ -41,10 +46,13 @@ public function testInitBundle() $container = $this->getContainer(); $this->assertTrue($container->hasParameter('cache.provider_service_ids')); - $this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.annotation')); - $this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.serializer')); - $this->assertInstanceOf(SymfonyValidatorBridge::class, $container->get('cache.service.validation')); - $this->assertInstanceOf(Psr6SessionHandler::class, $container->get('cache.service.session')); - $this->assertInstanceOf(CachingRouter::class, $container->get('cache.service.router')); + + if (Kernel::MAJOR_VERSION < 4) { + $this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.annotation')); + $this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.serializer')); + $this->assertInstanceOf(SymfonyValidatorBridge::class, $container->get('cache.service.validation')); + $this->assertInstanceOf(Psr6SessionHandler::class, $container->get('cache.service.session')); + $this->assertInstanceOf(CachingRouter::class, $container->get('cache.service.router')); + } } } diff --git a/tests/Functional/DummyNormalizer.php b/tests/Functional/DummyNormalizer.php new file mode 100644 index 0000000..eba0227 --- /dev/null +++ b/tests/Functional/DummyNormalizer.php @@ -0,0 +1,27 @@ +, Tobias Nyholm + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace Cache\CacheBundle\Tests\Functional; + +use Symfony\Component\Serializer\Normalizer\NormalizerInterface; + +class DummyNormalizer implements NormalizerInterface +{ + public function normalize($object, $format = null, array $context = []) + { + return []; + } + + public function supportsNormalization($data, $format = null) + { + return false; + } +} diff --git a/tests/Functional/config.yml b/tests/Functional/config.yml index 75d87b9..bf02c4c 100644 --- a/tests/Functional/config.yml +++ b/tests/Functional/config.yml @@ -2,6 +2,11 @@ services: array_cache: class: Cache\Adapter\PHPArray\ArrayCachePool + dummy_normalizer: + class: Cache\CacheBundle\Tests\Functional\DummyNormalizer + tags: + - { name: serializer.normalizer } + cache: session: enabled: true @@ -29,10 +34,3 @@ cache: service_id: 'array_cache' use_tagging: true -framework: - annotations: - cache: 'cache.service.annotation' - serializer: - cache: 'cache.service.serializer' - validation: - cache: 'cache.service.validation' diff --git a/tests/Functional/sf2_and_3.yml b/tests/Functional/sf2_and_3.yml new file mode 100644 index 0000000..df18346 --- /dev/null +++ b/tests/Functional/sf2_and_3.yml @@ -0,0 +1,7 @@ +framework: + annotations: + cache: 'cache.service.annotation' + serializer: + cache: 'cache.service.serializer' + validation: + cache: 'cache.service.validation'