IntlDateFormatterTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Intl\Tests\DateFormatter\Verification;
  11. use Symfony\Component\Intl\DateFormatter\IntlDateFormatter;
  12. use Symfony\Component\Intl\Tests\DateFormatter\AbstractIntlDateFormatterTest;
  13. use Symfony\Component\Intl\Util\IntlTestHelper;
  14. /**
  15. * Verifies that {@link AbstractIntlDateFormatterTest} matches the behavior of
  16. * the {@link \IntlDateFormatter} class in a specific version of ICU.
  17. *
  18. * @author Bernhard Schussek <bschussek@gmail.com>
  19. */
  20. class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
  21. {
  22. protected function setUp()
  23. {
  24. IntlTestHelper::requireFullIntl($this, false);
  25. parent::setUp();
  26. }
  27. /**
  28. * @dataProvider formatTimezoneProvider
  29. */
  30. public function testFormatTimezone($pattern, $timezone, $expected)
  31. {
  32. IntlTestHelper::requireFullIntl($this, '59.1');
  33. parent::testFormatTimezone($pattern, $timezone, $expected);
  34. }
  35. public function testFormatUtcAndGmtAreSplit()
  36. {
  37. IntlTestHelper::requireFullIntl($this, '59.1');
  38. parent::testFormatUtcAndGmtAreSplit();
  39. }
  40. /**
  41. * @dataProvider dateAndTimeTypeProvider
  42. */
  43. public function testDateAndTimeType($timestamp, $datetype, $timetype, $expected)
  44. {
  45. IntlTestHelper::requireFullIntl($this, '59.1');
  46. parent::testDateAndTimeType($timestamp, $datetype, $timetype, $expected);
  47. }
  48. protected function getDateFormatter($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
  49. {
  50. IntlTestHelper::requireFullIntl($this, '55.1');
  51. if (!$formatter = new \IntlDateFormatter($locale, $datetype, $timetype, $timezone, $calendar, $pattern)) {
  52. throw new \InvalidArgumentException(intl_get_error_message());
  53. }
  54. return $formatter;
  55. }
  56. protected function getIntlErrorMessage()
  57. {
  58. return intl_get_error_message();
  59. }
  60. protected function getIntlErrorCode()
  61. {
  62. return intl_get_error_code();
  63. }
  64. protected function isIntlFailure($errorCode)
  65. {
  66. return intl_is_failure($errorCode);
  67. }
  68. }