1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12use Twig\Compiler;
13use Twig\Environment;
14
15class Twig_Tests_CompilerTest extends \PHPUnit\Framework\TestCase
16{
17    public function testReprNumericValueWithLocale()
18    {
19        $compiler = new Compiler(new Environment($this->getMockBuilder('\Twig\Loader\LoaderInterface')->getMock()));
20
21        $locale = setlocale(LC_NUMERIC, 0);
22        if (false === $locale) {
23            $this->markTestSkipped('Your platform does not support locales.');
24        }
25
26        $required_locales = ['fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'];
27        if (false === setlocale(LC_NUMERIC, $required_locales)) {
28            $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $required_locales));
29        }
30
31        $this->assertEquals('1.2', $compiler->repr(1.2)->getSource());
32        $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
33
34        setlocale(LC_NUMERIC, $locale);
35    }
36}
37