| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | /** |
|---|
| 5 | * Test functions against date_i18n. |
|---|
| 6 | * Tested scenarios: |
|---|
| 7 | * 1) |
|---|
| 8 | * 2) |
|---|
| 9 | * 3) |
|---|
| 10 | * 4) |
|---|
| 11 | * 5) |
|---|
| 12 | * @group functions.php |
|---|
| 13 | */ |
|---|
| 14 | class Tests_Functions_date_i18n extends WP_UnitTestCase { |
|---|
| 15 | |
|---|
| 16 | function test_date_i18n() { |
|---|
| 17 | |
|---|
| 18 | $this->assertEquals( ' 16-Apr-30', date_i18n( ' y-M-t' ) ); |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | function test_date_i18n_back_slash() { |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | $this->assertEquals( '16Mt', date_i18n( 'y\M\t' ) ); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | function test_date_i18n_bdate_DATE_ATOM() { |
|---|
| 28 | |
|---|
| 29 | $now = date( 'Y-m-d\TH:i:sP' ); |
|---|
| 30 | $this->assertEquals( $now, date_i18n( 'Y-m-d\TH:i:sP' ) ); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | function test_date_i18n_foward_slash() { |
|---|
| 34 | |
|---|
| 35 | $this->assertEquals( '16/Apr/30', date_i18n( 'y/M/t' ) ); |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | function test_date_i18n_no_space() { |
|---|
| 40 | |
|---|
| 41 | $this->assertEquals( 'Apr-30', date_i18n( 'M-t' ) ); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | function test_date_i18n_space() { |
|---|
| 45 | |
|---|
| 46 | $this->assertEquals( ' Apr-30', date_i18n( ' M-t' ) ); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | function test_date_i18n_DATE_W3C() { |
|---|
| 50 | $now = date( DATE_W3C ); |
|---|
| 51 | $this->assertEquals( $now , date_i18n( DATE_W3C, get_the_date( 'U' ) ) ); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | function test_date_i18n_DATE_W3C_no_option() { |
|---|
| 55 | $now = date( DATE_W3C ); |
|---|
| 56 | $timezone_string = get_option( 'timezone_string' ); |
|---|
| 57 | delete_option( 'timezone_string' ); |
|---|
| 58 | $this->assertEquals( $now, date_i18n( DATE_W3C, get_the_date( 'U' ) ) ); |
|---|
| 59 | |
|---|
| 60 | update_option( 'timezone_string', $timezone_string ); |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | function test_date_i18n_all_the_leters() { |
|---|
| 64 | |
|---|
| 65 | $this->assertEquals( 'Tue-April-Tuesday-Apr-am-AM-+00:00-0-+0000-GMT-0-UTC' , date_i18n( 'D-F-l-M-a-A-P-I-O-T-Z-e' ), strtotime( '2016-04-18' ) ); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | } |
|---|