Skip to content

Commit 6343e79

Browse files
bocharsky-bwNyholm
authored andcommitted
An attempt to make all tests green again so we can moving forward and merge PRs (#313)
* Downgrade Sf Translation component to avoid BC * Allow new major versions of matthiasnoback's libs * Pass an empty string instead of NULL as a 2nd arg to Source * Downgrade Twig to fix tests * Use ArrayLoader instead of deprecated Twig_Loader_Array * Fix a few more deprecation notices * Show but do not fail tests on deprecations * Remove unused namespace * Require Twig ^1.34,<2.8 on TrevisCI * Require twig/twig:^1.34,<1.39 on CI and fix BC * Require Twig <1.39 || <2.8 to fix more incompatibilities * Fix more BC breaks * Bump PHPUnit bridge: ^3.4 -> ^3.4.19 * Tweak Twig to '<1.39 || ^2.0,<2.8' * Bump PHP to 5.6 * Disable Composer limit
1 parent ffca135 commit 6343e79

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
global:
1414
- TEST_COMMAND="composer test"
1515
- SYMFONY_PHPUNIT_VERSION="6.3"
16+
- COMPOSER_MEMORY_LIMIT=-1
1617

1718
matrix:
1819
fast_finish: true
@@ -24,11 +25,11 @@ matrix:
2425
# Test with lowest dependencies
2526
- php: 7.1
2627
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" SYMFONY_PHPUNIT_VERSION="5.7"
27-
- php: 5.5
28+
- php: 5.6
2829
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" SYMFONY_PHPUNIT_VERSION="5.7"
2930

3031
# Test the latest stable release
31-
- php: 5.5
32+
- php: 5.6
3233
env: SYMFONY_PHPUNIT_VERSION="5.7"
3334
- php: 5.6
3435
env: SYMFONY_PHPUNIT_VERSION="5.7"
@@ -44,7 +45,7 @@ matrix:
4445
- php: 7.2
4546
env: DEPENDENCIES="dunglas/symfony-lock:^4"
4647
- php: 7.0
47-
env: DEPENDENCIES="dunglas/symfony-lock:^2 twig/twig:^1.34 symfony/property-access:^2.8"
48+
env: DEPENDENCIES="dunglas/symfony-lock:^2 twig/twig:^1.34,<1.39 symfony/property-access:^2.8"
4849

4950
# Latest commit to master
5051
- php: 7.2

Controller/WebUIController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1818
use Symfony\Component\Intl\Intl;
19+
use Symfony\Component\Intl\Locales;
1920
use Symfony\Component\Translation\MessageCatalogue;
2021
use Translation\Bundle\Exception\MessageValidationException;
2122
use Translation\Bundle\Service\StorageService;
@@ -250,7 +251,9 @@ private function getMessageFromRequest(Request $request)
250251
private function getLocale2LanguageMap()
251252
{
252253
$configuredLocales = $this->getParameter('php_translation.locales');
253-
$names = Intl::getLocaleBundle()->getLocaleNames('en');
254+
$names = class_exists(Locales::class)
255+
? Locales::getNames('en')
256+
: Intl::getLocaleBundle()->getLocaleNames('en');
254257
$map = [];
255258
foreach ($configuredLocales as $l) {
256259
$map[$l] = isset($names[$l]) ? $names[$l] : $l;

Tests/Unit/Twig/BaseTwigTestCase.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Translation\IdentityTranslator;
1717
use Symfony\Bridge\Twig\Extension\TranslationExtension as SymfonyTranslationExtension;
1818
use Translation\Bundle\Twig\TranslationExtension;
19+
use Twig\Loader\ArrayLoader;
1920

2021
/**
2122
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
@@ -26,10 +27,13 @@ final protected function parse($file, $debug = false)
2627
{
2728
$content = file_get_contents(__DIR__.'/Fixture/'.$file);
2829

29-
$env = new \Twig_Environment(new \Twig_Loader_Array([]));
30+
$loader = class_exists(ArrayLoader::class)
31+
? new ArrayLoader()
32+
: new \Twig_Loader_Array([]);
33+
$env = new \Twig_Environment($loader);
3034
$env->addExtension(new SymfonyTranslationExtension($translator = new IdentityTranslator(new MessageSelector())));
3135
$env->addExtension(new TranslationExtension($translator, $debug));
3236

33-
return $env->parse($env->tokenize(new \Twig_Source($content, null)))->getNode('body');
37+
return $env->parse($env->tokenize(new \Twig_Source($content, '')))->getNode('body');
3438
}
3539
}

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313
"php": "^5.5 || ^7.0",
1414
"symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0",
1515
"symfony/validator": "^2.7 || ^3.0 || ^4.0",
16-
"symfony/translation": "^2.7 || ^3.0 || ^4.0",
16+
"symfony/translation": "^2.7 || ^3.0 || ^4.0,<4.2",
1717
"symfony/twig-bundle": "^2.7 || ^3.0 || ^4.0",
1818
"symfony/finder": "^2.7 || ^3.0 || ^4.0",
1919
"symfony/intl": "^2.7 || ^3.0 || ^4.0",
2020

2121
"php-translation/common": "^1.0",
2222
"php-translation/symfony-storage": "^1.0",
2323
"php-translation/extractor": "^1.3",
24-
"nyholm/nsa": "^1.1"
24+
"nyholm/nsa": "^1.1",
25+
"twig/twig": "<1.39 || ^2.0,<2.8"
2526
},
2627
"require-dev": {
27-
"symfony/phpunit-bridge": "^3.4 || ^4.0",
28+
"symfony/phpunit-bridge": "^3.4.19 || ^4.0",
2829
"php-translation/translator": "^1.0",
2930
"php-http/curl-client": "^1.7",
3031
"php-http/message": "^1.6",
@@ -35,8 +36,8 @@
3536
"symfony/templating": "^2.7 || ^3.0 || ^4.0",
3637
"symfony/dependency-injection": "^2.7 || ^3.0 || ^4.0",
3738
"symfony/web-profiler-bundle": "^2.7 || ^3.0 || ^4.0",
38-
"matthiasnoback/symfony-dependency-injection-test": "^1.2 || ^2.3",
39-
"matthiasnoback/symfony-config-test": "^2.2 || ^3.1",
39+
"matthiasnoback/symfony-dependency-injection-test": "^1.2 || ^2.3 || ^3.0",
40+
"matthiasnoback/symfony-config-test": "^2.2 || ^3.1 || ^4.0",
4041
"guzzlehttp/psr7": "^1.4",
4142
"nyholm/symfony-bundle-test": "^1.2.3"
4243
},

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
<php>
1717
<env name="ENV" value="test" />
18+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="verbose=1" />
1819
</php>
1920

2021
<formatter type="clover" usefile="false"/>

0 commit comments

Comments
 (0)