Make WordPress Core

Ticket #34688: 34688.patch

File 34688.patch, 1.8 KB (added by realloc, 10 years ago)

Tests for WP_Locale

  • tests/phpunit/tests/locale.php

     
    11<?php
    22
    33/**
    4  * @group l10n
    5  * @group i18n
     4 * @group locale
    65 */
    7 class Tests_L10n extends WP_UnitTestCase {
     6class Tests_Locale extends WP_UnitTestCase {
    87
    9         function test_load_unload_textdomain() {
    10                 $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
    11                 $this->assertFalse( unload_textdomain( 'wp-tests-domain' ) );
     8        /**
     9         * Test WP_Locale's normal cases
     10         */
     11        function test_locale() {
     12                $locale = new WP_Locale();
    1213
    13                 $file = DIR_TESTDATA . '/pomo/simple.mo';
    14                 $this->assertTrue( load_textdomain( 'wp-tests-domain', $file ) );
    15                 $this->assertTrue( is_textdomain_loaded( 'wp-tests-domain' ) );
    16                 $this->assertTrue( unload_textdomain( 'wp-tests-domain' ) );
    17                 $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
     14                $this->assertEquals( __( 'January' ), $locale->get_month( 1 ) );
     15                $this->assertEquals( __( 'February' ), $locale->get_month( '02' ) );
     16
     17                $this->assertEquals( __( 'Sunday' ), $locale->get_weekday( 0 ) );
     18                $this->assertEquals( __( 'S' ), $locale->get_weekday_initial( __( 'Sunday') ) );
     19                $this->assertEquals( __( 'Sun' ), $locale->get_weekday_abbrev( __( 'Sunday' ) ) );
     20
     21                $this->assertEquals( __( 'January' ), $locale->get_month( 1 ) );
     22                $this->assertEquals( __( 'Jan' ), $locale->get_month_abbrev( __( 'January' ) ) );
     23
     24                $this->assertEquals( __( 'am' ), $locale->get_meridiem( _('am') ) );
     25
     26                return $locale;
    1827        }
     28
     29        /**
     30         * @param WP_Locale $locale
     31         * @depends test_locale
     32         */
     33        function test_rtl_src_admin_notice( $locale ) {
     34                $this->expectOutputRegex( '#<div class="error"><p>.*</p></div>#' );
     35                $locale->rtl_src_admin_notice();
     36        }
    1937}