IntlTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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_Extension_IntlTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @requires extension intl
  14. * @requires PHP 5.5
  15. */
  16. public function testLocalizedDateFilterWithDateTimeZone()
  17. {
  18. class_exists('Twig_Extensions_Extension_Intl');
  19. $env = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
  20. $date = twig_localized_date_filter($env, new DateTime('2015-01-01T00:00:00', new DateTimeZone('UTC')), 'short', 'long', 'en', '+01:00');
  21. $this->assertEquals('1/1/15 1:00:00 AM GMT+01:00', $date);
  22. }
  23. /**
  24. * @requires extension intl
  25. * @requires PHP 5.5
  26. */
  27. public function testLocalizedDateFilterWithDateTimeZoneZ()
  28. {
  29. class_exists('Twig_Extensions_Extension_Intl');
  30. $env = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock();
  31. $date = twig_localized_date_filter($env, new DateTime('2017-11-19T00:00:00Z'), 'short', 'long', 'fr', 'Z');
  32. $this->assertEquals('19/11/2017 00:00:00 UTC', $date);
  33. }
  34. }