From f53faa23afdd01d1c8e39b26f3a6388749930b75 Mon Sep 17 00:00:00 2001 From: Christophe BOUCAUT Date: Fri, 17 Aug 2018 10:59:54 +0200 Subject: [PATCH 1/5] Upgrade to SF 3.4.14. Fix code and add phpunit in require-dev. --- README.md | 5 +++++ Routing/Router.php | 2 +- Tests/Routing/I18nRouteCollectionBuilderTest.php | 2 +- composer.json | 5 +++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c8b113c97..a78301af1 100644 --- a/README.md +++ b/README.md @@ -324,6 +324,11 @@ geneanet_i18n_routing: id: my_attribute_translator ``` +## Run tests + +Run ```vendor/bin/phpunit Tests/```. +NB : You need to install php-sqlite3. + ## License This bundle is under the MIT license. See the complete license in the bundle: diff --git a/Routing/Router.php b/Routing/Router.php index e13f7b1f3..906ee0a26 100644 --- a/Routing/Router.php +++ b/Routing/Router.php @@ -175,7 +175,7 @@ public function setDefaultLocale($locale) * * @throws RouteNotFoundException When the route doesn't exists */ - protected function generateI18n($name, $locale, $parameters, $referenceType) + protected function generateI18n($name, $locale, $parameters, $referenceType = self::ABSOLUTE_PATH) { try { return $this->router->generate($name.'.'.$locale, $parameters, $referenceType); diff --git a/Tests/Routing/I18nRouteCollectionBuilderTest.php b/Tests/Routing/I18nRouteCollectionBuilderTest.php index 5a371a549..631348a7e 100644 --- a/Tests/Routing/I18nRouteCollectionBuilderTest.php +++ b/Tests/Routing/I18nRouteCollectionBuilderTest.php @@ -24,7 +24,7 @@ public function testCollection($name, $locales, $defaults, $requirements, $optio $defaults['_locale'] = $locale; $options['compiler_class'] = 'Symfony\\Component\\Routing\\RouteCompiler'; - $this->assertEquals($pattern, $route->getPattern(), '(pattern)'); + $this->assertEquals($pattern, $route->getPath(), '(path)'); $this->assertEquals($defaults, $route->getDefaults(), '(defaults)'); $this->assertEquals($requirements, $route->getRequirements(), '(requirements)'); $this->assertEquals($options, $route->getOptions(), '(options)'); diff --git a/composer.json b/composer.json index 69a7bb6a6..91866e3c1 100644 --- a/composer.json +++ b/composer.json @@ -32,10 +32,11 @@ } ], "require": { - "symfony/framework-bundle": "~2.6" + "symfony/framework-bundle": "~2.6|~3.4.14" }, "require-dev": { - "doctrine/dbal": "~2.0" + "doctrine/dbal": "~2.0", + "phpunit/phpunit": "~4.8.36" }, "suggest": { "doctrine/dbal": "~2.0" From 9a53b040a77815457d7255dee07e83eca09038aa Mon Sep 17 00:00:00 2001 From: Christophe BOUCAUT Date: Tue, 21 Aug 2018 17:10:53 +0200 Subject: [PATCH 2/5] Removed phpunit custom autoloader --- Tests/autoload.php.dist | 22 ---------------------- Tests/bootstrap.php | 7 ------- phpunit.xml.dist | 2 +- 3 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 Tests/autoload.php.dist delete mode 100644 Tests/bootstrap.php diff --git a/Tests/autoload.php.dist b/Tests/autoload.php.dist deleted file mode 100644 index ffe95f988..000000000 --- a/Tests/autoload.php.dist +++ /dev/null @@ -1,22 +0,0 @@ - - + ./Tests From ff1042f87c353f14ecf5017376cdbb8a3300ead3 Mon Sep 17 00:00:00 2001 From: Christophe BOUCAUT Date: Tue, 21 Aug 2018 17:21:04 +0200 Subject: [PATCH 3/5] Travis test PHP 7 and lowest dependencies --- .travis.yml | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f0b435ef..9d8b34a70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,23 +5,42 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 - hhvm +sudo: false + matrix: + include: + - php: 5.3 + env: | + COMPOSER_FLAGS='--prefer-stable --prefer-lowest' + SYMFONY_VERSION=2.3.* + - php: 5.6 + env: | + SYMFONY_VERSION=2.7.* + - php: 5.6 + env: | + SYMFONY_VERSION=2.8.* + - php: 5.6 + env: | + SYMFONY_VERSION=3.4.14 + env: - SYMFONY_VERSION=2.6.* - SYMFONY_VERSION=2.7.* - SYMFONY_VERSION=dev-master before_script: - - composer self-update - - composer require symfony/symfony:${SYMFONY_VERSION} --no-update - - sh -c "if [ '$TRAVIS_PHP_VERSION' = 'hhvm' ]; then composer remove doctrine/dbal --dev --no-interaction --no-update; fi;" - - composer update --no-interaction --prefer-source + # Update composer + - travis_retry composer self-update --no-interaction; + # Set symfony version dependency + - if [ "${SYMFONY_VERSION}" != "" ]; then composer require --no-update symfony/symfony=${SYMFONY_VERSION}; fi; + # Install composer dependencies + - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction;s script: - - phpunit --coverage-text + - vendor/bin/phpunit --coverage-text -matrix: - allow_failures: - - php: hhvm - - env: SYMFONY_VERSION=dev-master +cache: + directories: + - $HOME/.composer/cache From 066edf6c2290acf3fd5db6b746eb79a9a84d1729 Mon Sep 17 00:00:00 2001 From: Christophe BOUCAUT Date: Tue, 21 Aug 2018 17:29:36 +0200 Subject: [PATCH 4/5] Updated dependencies to only the minimum required --- composer.json | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 91866e3c1..be3cb4c25 100644 --- a/composer.json +++ b/composer.json @@ -32,14 +32,20 @@ } ], "require": { - "symfony/framework-bundle": "~2.6|~3.4.14" + "symfony/routing": "~2.6 || ~3.4.14", + "symfony/config": "~2.6 || ~3.4.14" }, "require-dev": { - "doctrine/dbal": "~2.0", + "doctrine/dbal": "~2.2", + + "symfony/dependency-injection": "~2.6 || ~3.4.14", + "symfony/http-kernel": "~2.6 || ~3.4.14", + "symfony/translation": "~2.6 || ~3.4.14", + "phpunit/phpunit": "~4.8.36" }, "suggest": { - "doctrine/dbal": "~2.0" + "doctrine/dbal": "~2.2" }, "autoload": { "psr-0": { "Geneanet\\I18nRoutingBundle": "" } From 700b0af39ce94b4d7e54305afa85f31ea4399223 Mon Sep 17 00:00:00 2001 From: Christophe BOUCAUT Date: Wed, 22 Aug 2018 09:47:34 +0200 Subject: [PATCH 5/5] Fixed a Symfony 3 compatibility --- DependencyInjection/GeneanetI18nRoutingExtension.php | 4 ++++ Resources/config/dbal.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/GeneanetI18nRoutingExtension.php b/DependencyInjection/GeneanetI18nRoutingExtension.php index 6d320224a..d0a8b3342 100644 --- a/DependencyInjection/GeneanetI18nRoutingExtension.php +++ b/DependencyInjection/GeneanetI18nRoutingExtension.php @@ -37,6 +37,10 @@ public function load(array $configs, ContainerBuilder $container) case 'doctrine_dbal': $loader->load('dbal.xml'); + + $def = $container->getDefinition('geneanet_i18n_routing.doctrine_dbal.connection'); + $def->setFactory(array(new Reference('doctrine'), 'getConnection')); + $this->configureCacheDefinition($config['cache'], $container); $container->setAlias('geneanet_i18n_routing.translator', 'geneanet_i18n_routing.translator.doctrine_dbal'); diff --git a/Resources/config/dbal.xml b/Resources/config/dbal.xml index 90fd1f5ed..55a777694 100644 --- a/Resources/config/dbal.xml +++ b/Resources/config/dbal.xml @@ -22,7 +22,7 @@ - + %geneanet_i18n_routing.doctrine_dbal.connection_name%