date.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @group formatting
  4. * @group datetime
  5. */
  6. class Tests_Formatting_Date extends WP_UnitTestCase {
  7. /**
  8. * Unpatched, this test passes only when Europe/London is not observing DST.
  9. *
  10. * @ticket 20328
  11. */
  12. function test_get_date_from_gmt_outside_of_dst() {
  13. update_option( 'timezone_string', 'Europe/London' );
  14. $gmt = $local = '2012-01-01 12:34:56';
  15. $this->assertEquals( $local, get_date_from_gmt( $gmt ) );
  16. }
  17. /**
  18. * Unpatched, this test passes only when Europe/London is observing DST.
  19. *
  20. * @ticket 20328
  21. */
  22. function test_get_date_from_gmt_during_dst() {
  23. update_option( 'timezone_string', 'Europe/London' );
  24. $gmt = '2012-06-01 12:34:56';
  25. $local = '2012-06-01 13:34:56';
  26. $this->assertEquals( $local, get_date_from_gmt( $gmt ) );
  27. }
  28. /**
  29. * @ticket 20328
  30. */
  31. function test_get_gmt_from_date_outside_of_dst() {
  32. update_option( 'timezone_string', 'Europe/London' );
  33. $local = $gmt = '2012-01-01 12:34:56';
  34. $this->assertEquals( $gmt, get_gmt_from_date( $local ) );
  35. }
  36. /**
  37. * @ticket 20328
  38. */
  39. function test_get_gmt_from_date_during_dst() {
  40. update_option( 'timezone_string', 'Europe/London' );
  41. $local = '2012-06-01 12:34:56';
  42. $gmt = '2012-06-01 11:34:56';
  43. $this->assertEquals( $gmt, get_gmt_from_date( $local ) );
  44. }
  45. }