Skip to content

Commit 7a44f15

Browse files
authored
Updated travis config (#90)
* Test on symfony 4 * sort packages * Fixed tests * Removed debug code * Adding doctrine annotations and force new versions of PHPUnut * typo * Better deps * Bugfix * serializer-bundle does not exists =) * cs * Better specify versions * Test fix on sf2.7 * minor * cs
1 parent 24325ab commit 7a44f15

6 files changed

+132
-51
lines changed

.travis.yml

+57-31
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,75 @@
11
language: php
2+
23
sudo: false
3-
dist: trusty
44

5-
php:
6-
- 7.1
7-
- 7.0
8-
- 5.6
9-
- hhvm
5+
cache:
6+
directories:
7+
- $HOME/.composer/cache/files
8+
- $HOME/symfony-bridge/.phpunit
109

1110
env:
12-
global:
13-
- COMPOSER_COMMAND="composer install --prefer-dist"
14-
- TEST_COMMAND="php vendor/bin/phpunit"
15-
- COVERAGE=false
16-
matrix:
17-
- SYMFONY_VERSION=2.7.*
18-
- SYMFONY_VERSION=2.8.*
19-
- SYMFONY_VERSION=3.1.*
20-
- SYMFONY_VERSION=3.2.*
11+
global:
12+
- TEST_COMMAND="composer test"
13+
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
14+
- SYMFONY_DEPRECATIONS_HELPER="weak"
2115

2216
branches:
23-
except:
24-
- /^analysis-.*$/
25-
- /^patch-.*$/
17+
except:
18+
- /^analysis-.*$/
2619

2720
matrix:
28-
fast_finish: true
29-
include:
30-
- php: 5.6
31-
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.*
21+
fast_finish: true
22+
include:
23+
# Minimum supported Symfony version and latest PHP version
24+
- php: 7.2
25+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak"
26+
- php: 5.6
27+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak"
3228

33-
cache:
34-
directories:
35-
- $HOME/.composer/cache
29+
# Test the latest stable release
30+
- php: 5.6
31+
- php: 7.0
32+
- php: 7.1
33+
- php: 7.2
34+
env: COVERAGE=true TEST_COMMAND="composer test-ci"
35+
36+
# Test LTS versions
37+
- php: 7.2
38+
env: DEPENDENCIES="dunglas/symfony-lock:^2 symfony/property-access:^2.8"
39+
- php: 7.2
40+
env: DEPENDENCIES="dunglas/symfony-lock:^3"
41+
- php: 7.2
42+
env: DEPENDENCIES="dunglas/symfony-lock:^4"
43+
44+
# Latest commit to master
45+
- php: 7.2
46+
env: STABILITY="dev"
47+
48+
allow_failures:
49+
# dev stability is allowed to fail.
50+
- env: STABILITY="dev"
3651

3752
before_install:
38-
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-rm xdebug.ini; fi;
39-
- pip install --user codecov
40-
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
53+
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
54+
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
55+
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
56+
- pip install --user codecov
4157

4258
install:
43-
- travis_retry ${COMPOSER_COMMAND} --no-interaction
59+
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
60+
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
61+
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
62+
- vendor/bin/simple-phpunit install
4463

4564
script:
46-
- $TEST_COMMAND
65+
- composer validate --strict --no-check-lock
66+
- $TEST_COMMAND
4767

4868
after_success:
49-
- if [[ "$COVERAGE" = true ]]; then codecov; fi
69+
- if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
70+
- if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
71+
- if [[ "$COVERAGE" = true ]]; then codecov; fi
72+
73+
after_script:
74+
- wget http://tnyholm.se/reporter.phar
75+
- php reporter.phar build:upload

composer.json

+23-8
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,27 @@
2525
],
2626
"require": {
2727
"php": "^5.6 || ^7.0",
28-
"symfony/framework-bundle": "^2.7 || ^3.0",
29-
"symfony/var-dumper": "^3.3",
30-
"cache/taggable-cache": "^1.0",
3128
"cache/session-handler": "^1.0",
32-
"nyholm/nsa": "^1.1"
29+
"cache/taggable-cache": "^1.0",
30+
"nyholm/nsa": "^1.1",
31+
"symfony/config": "^2.7 || ^3.0 || ^4.0",
32+
"symfony/console": "^2.7 || ^3.0 || ^4.0",
33+
"symfony/dependency-injection": "^2.7 || ^3.0 || ^4.0",
34+
"symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0",
35+
"symfony/http-foundation": "^2.7 || ^3.0 || ^4.0",
36+
"symfony/http-kernel": "^2.7 || ^3.0 || ^4.0",
37+
"symfony/var-dumper": "^2.7 || ^3.3 || ^4.0"
3338
},
3439
"require-dev": {
35-
"phpunit/phpunit": "^5.7.17",
36-
"symfony/symfony": "^2.7 || ^3.0",
37-
"cache/psr-6-doctrine-bridge": "^3.0",
3840
"cache/array-adapter": "^1.0",
41+
"cache/psr-6-doctrine-bridge": "^3.0",
42+
"doctrine/annotations": "^1.0",
43+
"matthiasnoback/symfony-dependency-injection-test": "^1.1 || ^2.3",
3944
"nyholm/symfony-bundle-test": "^1.2",
40-
"matthiasnoback/symfony-dependency-injection-test": "^1.0"
45+
"symfony/phpunit-bridge": "^3.3 || ^4.0",
46+
"symfony/routing": "^2.7 || ^3.0 || ^4.0",
47+
"symfony/serializer": "^2.7 || ^3.0 || ^4.0",
48+
"symfony/validator": "^2.7 || ^3.0 || ^4.0"
4149
},
4250
"suggest": {
4351
"cache/adapter-bundle": "To register PSR-6 compliant cache implementations as services.",
@@ -52,5 +60,12 @@
5260
"psr-4": {
5361
"Cache\\CacheBundle\\Tests\\": "tests/"
5462
}
63+
},
64+
"scripts": {
65+
"test": "vendor/bin/simple-phpunit",
66+
"test-ci": "vendor/bin/simple-phpunit --coverage-text --coverage-clover=build/coverage.xml"
67+
},
68+
"config": {
69+
"sort-packages": true
5570
}
5671
}

tests/Functional/BundleInitializationTest.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Cache\CacheBundle\Routing\CachingRouter;
1818
use Cache\SessionHandler\Psr6SessionHandler;
1919
use Nyholm\BundleTest\BaseBundleTestCase;
20+
use Symfony\Component\HttpKernel\Kernel;
2021

2122
/**
2223
* @author Tobias Nyholm <[email protected]>
@@ -33,6 +34,10 @@ protected function setUp()
3334
parent::setUp();
3435
$kernel = $this->createKernel();
3536
$kernel->addConfigFile(__DIR__.'/config.yml');
37+
38+
if (Kernel::MAJOR_VERSION < 4) {
39+
$kernel->addConfigFile(__DIR__.'/sf2_and_3.yml');
40+
}
3641
}
3742

3843
public function testInitBundle()
@@ -41,10 +46,13 @@ public function testInitBundle()
4146
$container = $this->getContainer();
4247

4348
$this->assertTrue($container->hasParameter('cache.provider_service_ids'));
44-
$this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.annotation'));
45-
$this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.serializer'));
46-
$this->assertInstanceOf(SymfonyValidatorBridge::class, $container->get('cache.service.validation'));
47-
$this->assertInstanceOf(Psr6SessionHandler::class, $container->get('cache.service.session'));
48-
$this->assertInstanceOf(CachingRouter::class, $container->get('cache.service.router'));
49+
50+
if (Kernel::MAJOR_VERSION < 4) {
51+
$this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.annotation'));
52+
$this->assertInstanceOf(DoctrineCacheBridge::class, $container->get('cache.service.serializer'));
53+
$this->assertInstanceOf(SymfonyValidatorBridge::class, $container->get('cache.service.validation'));
54+
$this->assertInstanceOf(Psr6SessionHandler::class, $container->get('cache.service.session'));
55+
$this->assertInstanceOf(CachingRouter::class, $container->get('cache.service.router'));
56+
}
4957
}
5058
}

tests/Functional/DummyNormalizer.php

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-cache\cache-bundle package.
5+
*
6+
* (c) 2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Cache\CacheBundle\Tests\Functional;
13+
14+
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
15+
16+
class DummyNormalizer implements NormalizerInterface
17+
{
18+
public function normalize($object, $format = null, array $context = [])
19+
{
20+
return [];
21+
}
22+
23+
public function supportsNormalization($data, $format = null)
24+
{
25+
return false;
26+
}
27+
}

tests/Functional/config.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ services:
22
array_cache:
33
class: Cache\Adapter\PHPArray\ArrayCachePool
44

5+
dummy_normalizer:
6+
class: Cache\CacheBundle\Tests\Functional\DummyNormalizer
7+
tags:
8+
- { name: serializer.normalizer }
9+
510
cache:
611
session:
712
enabled: true
@@ -29,10 +34,3 @@ cache:
2934
service_id: 'array_cache'
3035
use_tagging: true
3136

32-
framework:
33-
annotations:
34-
cache: 'cache.service.annotation'
35-
serializer:
36-
cache: 'cache.service.serializer'
37-
validation:
38-
cache: 'cache.service.validation'

tests/Functional/sf2_and_3.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
framework:
2+
annotations:
3+
cache: 'cache.service.annotation'
4+
serializer:
5+
cache: 'cache.service.serializer'
6+
validation:
7+
cache: 'cache.service.validation'

0 commit comments

Comments
 (0)