Skip to content

An attempt to make all tests green again so we can moving forward and merge PRs #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
global:
- TEST_COMMAND="composer test"
- SYMFONY_PHPUNIT_VERSION="6.3"
- COMPOSER_MEMORY_LIMIT=-1

matrix:
fast_finish: true
Expand All @@ -24,11 +25,11 @@ matrix:
# Test with lowest dependencies
- php: 7.1
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" SYMFONY_PHPUNIT_VERSION="5.7"
- php: 5.5
- php: 5.6
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" SYMFONY_PHPUNIT_VERSION="5.7"

# Test the latest stable release
- php: 5.5
- php: 5.6
env: SYMFONY_PHPUNIT_VERSION="5.7"
- php: 5.6
env: SYMFONY_PHPUNIT_VERSION="5.7"
Expand All @@ -44,7 +45,7 @@ matrix:
- php: 7.2
env: DEPENDENCIES="dunglas/symfony-lock:^4"
- php: 7.0
env: DEPENDENCIES="dunglas/symfony-lock:^2 twig/twig:^1.34 symfony/property-access:^2.8"
env: DEPENDENCIES="dunglas/symfony-lock:^2 twig/twig:^1.34,<1.39 symfony/property-access:^2.8"

# Latest commit to master
- php: 7.2
Expand Down
5 changes: 4 additions & 1 deletion Controller/WebUIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Locales;
use Symfony\Component\Translation\MessageCatalogue;
use Translation\Bundle\Exception\MessageValidationException;
use Translation\Bundle\Service\StorageService;
Expand Down Expand Up @@ -250,7 +251,9 @@ private function getMessageFromRequest(Request $request)
private function getLocale2LanguageMap()
{
$configuredLocales = $this->getParameter('php_translation.locales');
$names = Intl::getLocaleBundle()->getLocaleNames('en');
$names = class_exists(Locales::class)
? Locales::getNames('en')
: Intl::getLocaleBundle()->getLocaleNames('en');
$map = [];
foreach ($configuredLocales as $l) {
$map[$l] = isset($names[$l]) ? $names[$l] : $l;
Expand Down
8 changes: 6 additions & 2 deletions Tests/Unit/Twig/BaseTwigTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Translation\IdentityTranslator;
use Symfony\Bridge\Twig\Extension\TranslationExtension as SymfonyTranslationExtension;
use Translation\Bundle\Twig\TranslationExtension;
use Twig\Loader\ArrayLoader;

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

$env = new \Twig_Environment(new \Twig_Loader_Array([]));
$loader = class_exists(ArrayLoader::class)
? new ArrayLoader()
: new \Twig_Loader_Array([]);
$env = new \Twig_Environment($loader);
$env->addExtension(new SymfonyTranslationExtension($translator = new IdentityTranslator(new MessageSelector())));
$env->addExtension(new TranslationExtension($translator, $debug));

return $env->parse($env->tokenize(new \Twig_Source($content, null)))->getNode('body');
return $env->parse($env->tokenize(new \Twig_Source($content, '')))->getNode('body');
}
}
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
"php": "^5.5 || ^7.0",
"symfony/framework-bundle": "^2.7 || ^3.0 || ^4.0",
"symfony/validator": "^2.7 || ^3.0 || ^4.0",
"symfony/translation": "^2.7 || ^3.0 || ^4.0",
"symfony/translation": "^2.7 || ^3.0 || ^4.0,<4.2",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terrible idea here. See #323

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point, but at that time without a proper fix this was not so bad idea, it helped to push things forward in this bundle and merge many PRs awaiting green tests. Totally agree we should revert this change back, but also we should make tests green and properly fix the problem in this bundle on Sf 4.2+

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be it's time to fix it? I think we have make tests green in #323 with help of @nicolas-grekas because it's apparently a BC break introduced with 4.2+ version of Symfony

"symfony/twig-bundle": "^2.7 || ^3.0 || ^4.0",
"symfony/finder": "^2.7 || ^3.0 || ^4.0",
"symfony/intl": "^2.7 || ^3.0 || ^4.0",

"php-translation/common": "^1.0",
"php-translation/symfony-storage": "^1.0",
"php-translation/extractor": "^1.3",
"nyholm/nsa": "^1.1"
"nyholm/nsa": "^1.1",
"twig/twig": "<1.39 || ^2.0,<2.8"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same really bad idea. This is opting out from any maintenance efforts and preventing users to upgrade.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, reverted in #324 - most probably tests will fail so we will need to fix them before merging

},
"require-dev": {
"symfony/phpunit-bridge": "^3.4 || ^4.0",
"symfony/phpunit-bridge": "^3.4.19 || ^4.0",
"php-translation/translator": "^1.0",
"php-http/curl-client": "^1.7",
"php-http/message": "^1.6",
Expand All @@ -35,8 +36,8 @@
"symfony/templating": "^2.7 || ^3.0 || ^4.0",
"symfony/dependency-injection": "^2.7 || ^3.0 || ^4.0",
"symfony/web-profiler-bundle": "^2.7 || ^3.0 || ^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^1.2 || ^2.3",
"matthiasnoback/symfony-config-test": "^2.2 || ^3.1",
"matthiasnoback/symfony-dependency-injection-test": "^1.2 || ^2.3 || ^3.0",
"matthiasnoback/symfony-config-test": "^2.2 || ^3.1 || ^4.0",
"guzzlehttp/psr7": "^1.4",
"nyholm/symfony-bundle-test": "^1.2.3"
},
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<php>
<env name="ENV" value="test" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="verbose=1" />
</php>

<formatter type="clover" usefile="false"/>
Expand Down