CompilerTest.php 1.0KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. class Twig_Tests_CompilerTest extends PHPUnit_Framework_TestCase
  11. {
  12. public function testReprNumericValueWithLocale()
  13. {
  14. $compiler = new Twig_Compiler(new Twig_Environment());
  15. $locale = setlocale(LC_NUMERIC, 0);
  16. if (false === $locale) {
  17. $this->markTestSkipped('Your platform does not support locales.');
  18. }
  19. $required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
  20. if (false === setlocale(LC_ALL, $required_locales)) {
  21. $this->markTestSkipped('Could not set any of required locales: ' . implode(", ", $required_locales));
  22. }
  23. $this->assertEquals('1.2', $compiler->repr(1.2)->getSource());
  24. $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
  25. setlocale(LC_ALL, $locale);
  26. }
  27. }