WordPress.org

Make WordPress Core

Changeset 36766


Ignore:
Timestamp:
02/28/2016 08:48:58 PM (6 years ago)
Author:
SergeyBiryukov
Message:

L10n: Add unit tests for _n_noop() and _nx_noop().

Props realloc.
Fixes #35961.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/l10n.php

    r36718 r36766  
    66 */
    77class Tests_L10n extends WP_UnitTestCase {
     8
     9    /**
     10     * @ticket 35961
     11     */
     12    function test_n_noop() {
     13        $text_domain   = 'text-domain';
     14        $nooped_plural = _n_noop( '%s post', '%s posts', $text_domain );
     15
     16        $this->assertNotEmpty( $nooped_plural['domain'] );
     17        $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) );
     18        $this->assertEquals( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) );
     19        $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) );
     20    }
     21
     22    /**
     23     * @ticket 35961
     24     */
     25    function test_nx_noop() {
     26        $text_domain   = 'text-domain';
     27        $nooped_plural = _nx_noop( '%s post', '%s posts', 'my-context', $text_domain );
     28
     29        $this->assertNotEmpty( $nooped_plural['domain'] );
     30        $this->assertNotEmpty( $nooped_plural['context'] );
     31        $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) );
     32        $this->assertEquals( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) );
     33        $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) );
     34    }
    835
    936    function test_load_unload_textdomain() {
Note: See TracChangeset for help on using the changeset viewer.