Make WordPress Core

Ticket #34688: 34688.diff

File 34688.diff, 6.0 KB (added by swissspidy, 10 years ago)
  • new file tests/phpunit/tests/locale.php

    diff --git tests/phpunit/tests/locale.php tests/phpunit/tests/locale.php
    new file mode 100644
    index 0000000..85ec055
    - +  
     1<?php
     2
     3/**
     4 * @group locale
     5 */
     6class Tests_Locale extends WP_UnitTestCase {
     7        /**
     8         * @var WP_Locale
     9         */
     10        protected $locale;
     11
     12        public function setUp() {
     13                $this->locale = new WP_Locale();
     14        }
     15
     16        public function test_rtl_src_admin_notice() {
     17                $this->expectOutputRegex( '#<div class="error"><p>.*</p></div>#' );
     18                $this->locale->rtl_src_admin_notice();
     19        }
     20
     21        public function test_get_weekday() {
     22                $this->assertEquals( __( 'Sunday' ), $this->locale->get_weekday( 0 ) );
     23                $this->assertEquals( __( 'Monday' ), $this->locale->get_weekday( 1 ) );
     24                $this->assertEquals( __( 'Tuesday' ), $this->locale->get_weekday( 2 ) );
     25                $this->assertEquals( __( 'Wednesday' ), $this->locale->get_weekday( 3 ) );
     26                $this->assertEquals( __( 'Thursday' ), $this->locale->get_weekday( 4 ) );
     27                $this->assertEquals( __( 'Friday' ), $this->locale->get_weekday( 5 ) );
     28                $this->assertEquals( __( 'Saturday' ), $this->locale->get_weekday( 6 ) );
     29        }
     30
     31        /**
     32         * @expectedException PHPUnit_Framework_Error_Notice
     33         */
     34        public function test_get_weekday_undefined_index() {
     35                $this->locale->get_weekday( 7 );
     36        }
     37
     38        public function test_get_weekday_initial() {
     39                $this->assertEquals( __( 'S' ), $this->locale->get_weekday_initial( __( 'Sunday' ) ) );
     40                $this->assertEquals( __( 'M' ), $this->locale->get_weekday_initial( __( 'Monday' ) ) );
     41                $this->assertEquals( __( 'T' ), $this->locale->get_weekday_initial( __( 'Tuesday' ) ) );
     42                $this->assertEquals( __( 'W' ), $this->locale->get_weekday_initial( __( 'Wednesday' ) ) );
     43                $this->assertEquals( __( 'T' ), $this->locale->get_weekday_initial( __( 'Thursday' ) ) );
     44                $this->assertEquals( __( 'F' ), $this->locale->get_weekday_initial( __( 'Friday' ) ) );
     45                $this->assertEquals( __( 'S' ), $this->locale->get_weekday_initial( __( 'Saturday' ) ) );
     46        }
     47
     48        public function test_get_weekday_abbrev() {
     49                $this->assertEquals( __( 'Sun' ), $this->locale->get_weekday_abbrev( __( 'Sunday' ) ) );
     50                $this->assertEquals( __( 'Mon' ), $this->locale->get_weekday_abbrev( __( 'Monday' ) ) );
     51                $this->assertEquals( __( 'Tue' ), $this->locale->get_weekday_abbrev( __( 'Tuesday' ) ) );
     52                $this->assertEquals( __( 'Wed' ), $this->locale->get_weekday_abbrev( __( 'Wednesday' ) ) );
     53                $this->assertEquals( __( 'Thu' ), $this->locale->get_weekday_abbrev( __( 'Thursday' ) ) );
     54                $this->assertEquals( __( 'Fri' ), $this->locale->get_weekday_abbrev( __( 'Friday' ) ) );
     55                $this->assertEquals( __( 'Sat' ), $this->locale->get_weekday_abbrev( __( 'Saturday' ) ) );
     56        }
     57
     58        public function test_get_month() {
     59                $this->assertEquals( __( 'January' ), $this->locale->get_month( 1 ) );
     60                $this->assertEquals( __( 'February' ), $this->locale->get_month( 2 ) );
     61                $this->assertEquals( __( 'March' ), $this->locale->get_month( 3 ) );
     62                $this->assertEquals( __( 'April' ), $this->locale->get_month( 4 ) );
     63                $this->assertEquals( __( 'May' ), $this->locale->get_month( 5 ) );
     64                $this->assertEquals( __( 'June' ), $this->locale->get_month( 6 ) );
     65                $this->assertEquals( __( 'July' ), $this->locale->get_month( 7 ) );
     66                $this->assertEquals( __( 'August' ), $this->locale->get_month( 8 ) );
     67                $this->assertEquals( __( 'September' ), $this->locale->get_month( 9 ) );
     68                $this->assertEquals( __( 'October' ), $this->locale->get_month( 10 ) );
     69                $this->assertEquals( __( 'November' ), $this->locale->get_month( 11 ) );
     70                $this->assertEquals( __( 'December' ), $this->locale->get_month( 12 ) );
     71        }
     72
     73        public function test_get_month_leading_zero() {
     74                $this->assertEquals( __( 'January' ), $this->locale->get_month( '01' ) );
     75                $this->assertEquals( __( 'February' ), $this->locale->get_month( '02' ) );
     76                $this->assertEquals( __( 'March' ), $this->locale->get_month( '03' ) );
     77                $this->assertEquals( __( 'April' ), $this->locale->get_month( '04' ) );
     78                $this->assertEquals( __( 'May' ), $this->locale->get_month( '05' ) );
     79                $this->assertEquals( __( 'June' ), $this->locale->get_month( '06' ) );
     80                $this->assertEquals( __( 'July' ), $this->locale->get_month( '07' ) );
     81                $this->assertEquals( __( 'August' ), $this->locale->get_month( '08' ) );
     82                $this->assertEquals( __( 'September' ), $this->locale->get_month( '09' ) );
     83        }
     84
     85        public function test_get_month_abbrev() {
     86                $this->assertEquals( __( 'Jan' ), $this->locale->get_month_abbrev( __( 'January' ) ) );
     87                $this->assertEquals( __( 'Feb' ), $this->locale->get_month_abbrev( __( 'February' ) ) );
     88                $this->assertEquals( __( 'Mar' ), $this->locale->get_month_abbrev( __( 'March' ) ) );
     89                $this->assertEquals( __( 'Apr' ), $this->locale->get_month_abbrev( __( 'April' ) ) );
     90                $this->assertEquals( __( 'May' ), $this->locale->get_month_abbrev( __( 'May' ) ) );
     91                $this->assertEquals( __( 'Jun' ), $this->locale->get_month_abbrev( __( 'June' ) ) );
     92                $this->assertEquals( __( 'Jul' ), $this->locale->get_month_abbrev( __( 'July' ) ) );
     93                $this->assertEquals( __( 'Aug' ), $this->locale->get_month_abbrev( __( 'August' ) ) );
     94                $this->assertEquals( __( 'Sep' ), $this->locale->get_month_abbrev( __( 'September' ) ) );
     95                $this->assertEquals( __( 'Oct' ), $this->locale->get_month_abbrev( __( 'October' ) ) );
     96                $this->assertEquals( __( 'Nov' ), $this->locale->get_month_abbrev( __( 'November' ) ) );
     97                $this->assertEquals( __( 'Dec' ), $this->locale->get_month_abbrev( __( 'December' ) ) );
     98        }
     99
     100        public function test_get_meridiem() {
     101                $this->assertEquals( __( 'am' ), $this->locale->get_meridiem( 'am' ) );
     102                $this->assertEquals( __( 'AM' ), $this->locale->get_meridiem( 'AM' ) );
     103                $this->assertEquals( __( 'pm' ), $this->locale->get_meridiem( 'pm' ) );
     104                $this->assertEquals( __( 'PM' ), $this->locale->get_meridiem( 'PM' ) );
     105        }
     106
     107        public function test_is_rtl() {
     108                $this->assertFalse( $this->locale->is_rtl() );
     109                $this->locale->text_direction = 'foo';
     110                $this->assertFalse( $this->locale->is_rtl() );
     111                $this->locale->text_direction = 'rtl';
     112                $this->assertTrue( $this->locale->is_rtl() );
     113        }
     114}