Make WordPress Core

Changeset 36563


Ignore:
Timestamp:
02/17/2016 10:01:11 PM (9 years ago)
Author:
ocean90
Message:

Tests: Add test for wp_get_installed_translations().

Introduces language files in /tests/phpunit/data/language. Each file includes the header and 5 translations.

Props realloc for initial patch.
Fixes #35284.

Location:
trunk/tests/phpunit
Files:
15 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/bootstrap.php

    r35350 r36563  
    2626define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
    2727define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' );
     28
     29define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' );
    2830
    2931if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) )
  • trunk/tests/phpunit/tests/l10n.php

    r36538 r36563  
    4747        $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
    4848    }
     49
     50    /**
     51     * @ticket 35284
     52     */
     53    function test_wp_get_installed_translations_for_core() {
     54        $installed_translations = wp_get_installed_translations( 'core' );
     55        $this->assertInternalType( 'array', $installed_translations );
     56        $textdomains_expected = array( 'admin', 'admin-network', 'continents-cities', 'default' );
     57        $this->assertEqualSets( $textdomains_expected, array_keys( $installed_translations ) );
     58
     59        $this->assertNotEmpty( $installed_translations['default']['en_GB'] );
     60        $data_en_GB = $installed_translations['default']['en_GB'];
     61        $this->assertEquals( '2016-01-14 21:14:29+0000', $data_en_GB['PO-Revision-Date'] );
     62        $this->assertEquals( 'Development (4.4.x)', $data_en_GB['Project-Id-Version'] );
     63        $this->assertEquals( 'GlotPress/1.0-alpha-1100', $data_en_GB['X-Generator'] );
     64
     65        $this->assertNotEmpty( $installed_translations['admin']['es_ES'] );
     66        $data_es_ES = $installed_translations['admin']['es_ES'];
     67        $this->assertEquals( '2015-12-22 20:26:46+0000', $data_es_ES['PO-Revision-Date'] );
     68        $this->assertEquals( 'Administration', $data_es_ES['Project-Id-Version'] );
     69        $this->assertEquals( 'GlotPress/1.0-alpha-1100', $data_es_ES['X-Generator'] );
     70    }
    4971}
Note: See TracChangeset for help on using the changeset viewer.